bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gjdoc/23917] gjdoc doesn't handle the -classpath option correctly


From: vadimn at redhat dot com
Subject: [Bug gjdoc/23917] gjdoc doesn't handle the -classpath option correctly
Date: 4 Nov 2005 16:17:13 -0000


------- Comment #4 from vadimn at redhat dot com  2005-11-04 16:17 -------
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#forName%28java.lang.String%29
says

  : Returns the Class object associated with the class or interface
  : with the given string name. Invoking this method is equivalent to:
  : 
  :   Class.forName(className, true, currentLoader)
  :  
  : 
  : where currentLoader denotes the defining class loader of the
  : current class.


So,

| $ cvs status src/gnu/classpath/tools/gjdoc/RootDocImpl.java | grep Working
|    Working revision:    1.23
| $ cat -n src/gnu/classpath/tools/gjdoc/RootDocImpl.java | head -1196 | tail
-9
|   1188              try {
|   1189                 Class clazz = Class.forName(scheduledClassName);
|   1190                 printWarning("Cannot locate class " +
scheduledClassName + " on file system, falling back to reflection.");
|   1191                 ClassDoc result = new ClassDocReflectedImpl(clazz);
|   1192                 return result;
|   1193              }
|   1194              catch (Throwable ignore) {
|   1195                
unlocatableReflectedClassNames.add(scheduledClassName);
|   1196              }

if you're saying that Class.forName at line 1189 should be replaced
with

|   Class clazz = Class.forName(scheduledClassName,
|                               false,
|                               RootDocImpl.class.getClassLoader());
|

... then I agree.


Additionally, the following piece of code may not be too hard to fix
either:

| $ cvs status src/gnu/classpath/tools/gjdoc/Main.java | grep Working
|    Working revision:    1.75
| $ cat -n src/gnu/classpath/tools/gjdoc/Main.java | head -1478 | tail -9
|   1470      options.put("-classpath", new OptionProcessor(2)
|   1471        {
|   1472          void process(String[] args)
|   1473          {
|   1474            reporter.printWarning("-classpath option could not be
passed to the VM.  Faking it with ");
|   1475            reporter.printWarning("   
System.setProperty(\"java.class.path\", \"" + args[0] + "\");");
|   1476            System.setProperty("java.class.path", args[0]);
|   1477          }
|   1478        });


Instead of what we currently do at line 1476, we can create a custom
URLClassLoader and initialize it with the list of URLs specified by
the -classpath option.  We can later use this custom classloader for
resolving "scheduled" classes in
src/gnu/classpath/tools/gjdoc/RootDocImpl.java.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23917





reply via email to

[Prev in Thread] Current Thread [Next in Thread]