|
From: Nigel T. <fu...@f2...> - 2008-12-06 08:10:27
|
Hello jEdit developers,
I've noticed that JARClassLoader's URLs are not understood by Ant's Locator.
This causes the javah ant task to fail if the ant target is invoked from
AntFarm using jEdit's JVM.
The problem arises as the javah task first obtains a class object with a
call to Class.forName("com.sun.tools.javah.oldjavah.Main") and then asks
Ant's Locator to find the path to this class' containing jar file (which
the javah task uses as a means to locate tools.jar).
See:
org.apache.tools.ant.launch.Locator
org.apache.tools.ant.taskdefs.optional.javah.SunJavah
This becomes a problem when Ant is run from AntFarm in jEdits JVM as the
class com.sun.tools.javah.oldjavah.Main is loaded using the JARClassLoader.
Ant's Locator then calls the JARClassLoader's getResource(String name)
and tries to determine the path to the jar file from the returned URL.
However JARClassLoader returns a URL like this
"jeditresource:/tools.jar!/com/sun/tools/javah/oldjavah/Main.class"
But Locator does not understand the jeditresource: protocol (and even if
it did the URL lacks the full path information to tools.jar anyway).
Subsequently the javah task then invokes java without tools.jar in the
classpath resulting in
java.lang.NoClassDefFoundError: com/sun/tools/javah/oldjavah/Main
For a quick fix I tweaked my build of jEdit so that JARClassLoader
returns URLs in the form
“jar:file:/usr/lib/jvm/java-6-sun-1.6.0.10/lib/tools.jar!/com/sun/tools/javah/oldjavah/Main.class”
which are then understood by Locator and thus fixes the javah task, but
I don't know what other problems this may introduce.
I'd like to fix this properly and contribute the fix back to the
community. I would appreciate your thoughts on whether you think it best to:
a) modify Ant that ships with the AntPlugin (so that Locator understands
JARClassLoader URLs) ; or
b) modify JARClassLoader (so that it returns URLs Ant understands).
Nigel
|