This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[BC] Patch: FYI: override the CodeSource location
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 10 Aug 2004 14:05:01 -0600
- Subject: [BC] Patch: FYI: override the CodeSource location
- Reply-to: tromey at redhat dot com
I'm checking this in on the BC branch.
If we are looking to load a class from x.jar, and instead see
GCJLIBS/x.jar.so, we should still set the CodeSource for classes
loaded from the .so to say that they came from the .jar. This makes
sense because it doesn't matter that the code actually comes from a
.so, and because some user code uses the CodeSource for other things.
With this patch I can compile just startup.jar from Eclipse 2.1,
like so:
gcj -fPIC -fjni -findirect-dispatch -shared -g \
-o GCJLIBS/startup.jar.so startup.jar
... and the resulting Eclipse starts up fine and does load the code
from the .so.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/net/URLClassLoader.java (URLLoader(URLClassLoader, URL,
URL)): New constructor.
(SoURLLoader): Likewise.
(JarURLLoader): Create SoURLLoader with override URL.
Index: java/net/URLClassLoader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLClassLoader.java,v
retrieving revision 1.16.18.2
diff -u -r1.16.18.2 URLClassLoader.java
--- java/net/URLClassLoader.java 5 Aug 2004 17:39:06 -0000 1.16.18.2
+++ java/net/URLClassLoader.java 10 Aug 2004 20:08:53 -0000
@@ -188,9 +188,14 @@
URLLoader(URLClassLoader classloader, URL baseURL)
{
+ this(classloader, baseURL, baseURL);
+ }
+
+ URLLoader(URLClassLoader classloader, URL baseURL, URL overrideURL)
+ {
this.classloader = classloader;
this.baseURL = baseURL;
- this.noCertCodeSource = new CodeSource(baseURL, null);
+ this.noCertCodeSource = new CodeSource(overrideURL, null);
}
/**
@@ -327,10 +332,9 @@
File soFile = new File (libDirName + File.separator + f.getName()
+ ".so");
if (soFile != null && soFile.isFile())
- this.soURLLoader =
- new SoURLLoader
- (classloader,
- new URL ("file", null, soFile.getCanonicalPath()));
+ this.soURLLoader
+ = new SoURLLoader (classloader, soFile.toURL(),
+ baseURL);
}
}
}
@@ -521,7 +525,12 @@
SoURLLoader(URLClassLoader classloader, URL url)
{
- super(classloader, url);
+ this(classloader, url, url);
+ }
+
+ SoURLLoader(URLClassLoader classloader, URL url, URL overrideURL)
+ {
+ super(classloader, url, overrideURL);
helper = SharedLibHelper.findHelper(classloader, url.getFile(),
noCertCodeSource);
}