-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
5.0
-
x86
-
windows_xp
Name: js151677 Date: 09/13/2004
FULL PRODUCT VERSION :
java version "1.5.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP Home edition
A DESCRIPTION OF THE PROBLEM :
I am trying to use javadoc from another java program using the following
com.sun.tools.javadoc.Main.execute("javadoc", logWriter,logWriter, logWriter, "com.sun.tools.doclets.standard.Standard", docuCall2);
the above call woks if I have included tools.jar into the classpath at pogram startup time. If instead tools.jar is added to a URLClassLoader() and then the call is made I have the following error into the log file of javadoc.
<---- end of javadoc command ---->
javadoc: error - Cannot find doclet class com.sun.tools.doclets.standard.Standard
REGRESSION. Last worked in version tiger-rc
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a simple program bootstrap eg:
Boot.java
define a classloader in it
runtimeLoader = new URLClassLoader(runtimeClassPath, bootLoader);
where runtimeClassPath has tools.ja in it
2) do a newInstance of the class that will then call the javadoc, eg:
Class mainClass = Class.forName("bluej.Main", true, runtimeLoader);
Object main = mainClass.newInstance();
note that mainClass is loaded with the runtimeClassLoader that has tools.jar int it.
3) Try to use the javadoc from the bluej.Main eg:
com.sun.tools.javadoc.Main.execute("javadoc", logWriter,logWriter, logWriter, "com.sun.tools.doclets.standard.Standard", docuCall2);
Note that the failure is not into com.sun.tools.javadoc.Main.execute but into com.sun.tools.javadoc.DocletInvoker
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the invoked javadoc should produce the correct result.
ACTUAL -
An error message is reported.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Class documentation
<---- javadoc command: ---->
C:\Programmi\Java\jdk1.5.0\bin\javadoc.exe
-author
-version
-nodeprecated
-package
-source
1.5
-noindex
-notree
-nohelp
-nonavbar
-d
C:\Documents and Settings\admin\Documenti\shapes\doc
-classpath
C:\home\bluej\bluej\lib\junit.jar
C:\Documents and Settings\admin\Documenti\shapes\Test.java
<---- end of javadoc command ---->
javadoc: error - Cannot find doclet class com.sun.tools.doclets.standard.Standard
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
I have to cut the application, I will do it if requested.
It may be of help to look into DocletInvoker in particular:
public DocletInvoker(Messager messager1, String s, String s1)
{
messager = messager1;
docletClassName = s;
String s2 = null;
s2 = appendPath(System.getProperty("env.class.path"), s2);
s2 = appendPath(System.getProperty("java.class.path"), s2);
s2 = appendPath(s1, s2);
URL aurl[] = pathToURLs(s2);
appClassLoader = new URLClassLoader(aurl);
// appClassLoader = DocletInvoker.class.getClassLoader();
It can be seen that the javadoc classLoader is made of two parts, but that does not work correctly. If instead of
appClassLoader = new URLClassLoader(aurl);
we use
appClassLoader = DocletInvoker.class.getClassLoader();
then the javadoc does indeed produces the ight result
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Include tools.ja in the classpath.
This however equires a futher bat file to run our application and makes it much less WORA than it can be.
If we do not have to set the classpath we can run a bluej.jar with a simple doubleclick and it can pick up the latest JDK by itself.
Not only, but we may ship our java application without achitecture dependent parts, simply a pure java.
(Incident Review ID: 310604)
======================================================================