GCJ version: % gij4 --version gij (GNU libgcj) version 4.0.0 20050217 (Red Hat 4.0.0-0.27) Test class: public class Test { public static void main(String[] args) { System.out.println(Test.class.getProtectionDomain(). getCodeSource().getLocation()); } } With Sun VM 1.4.2_06 I get: % j2sdk1.4.2_06/bin/java Test file:/home/bkonrath/ With GCJ I get: % gij4 Test file:./ I also noticed that the SUN vm returns a URL that has symlinks resolved. Let me know if you need more info or if I should file this bug somewhere else.
Created attachment 9352 [details] Proposed patch This patch makes your test program emit an absolute path. I'm not sure it's 100% correct. For instance, perhaps we should canonicalize the path in addition to makeing it absolute. Also, perhaps this should happen in URLClassLoader instead of the system loader. Hopefully a discussion will happen on this thread: http://gcc.gnu.org/ml/java-patches/2005-q3/msg00144.html
This is a classpath issue and should be moved to classpath/classpath but I cannot move it for some reason.
Moving to classpath/classpath.
(In reply to comment #1) > Created an attachment (id=9352) > Proposed patch > > This patch makes your test program emit an absolute path. > > I'm not sure it's 100% correct. For instance, perhaps we should canonicalize > the path in addition to makeing it absolute. Also, perhaps this should happen > in URLClassLoader instead of the system loader. Hopefully a discussion will > happen on this thread: > > http://gcc.gnu.org/ml/java-patches/2005-q3/msg00144.html > I just checked in a patch for a related fix. The test case look like this: public class bug { public static void main (String args[]) throws Exception { String urlString = bug.class.getClassLoader().getResource("bug.class").toExternalForm (); System.out.println (urlString); } } Before patch: $ gij bug file:./bug.class After patch: $ gij bug file:/home/green/FSF/HEAD/bug.class Unfortunately it doesn't fix this bug (although the original patch attached to this bug _does_). I'll figure out what else is needed for this bug. AG
Subject: Bug 20198 CVSROOT: /cvsroot/classpath Module name: classpath Branch: Changes by: Anthony Green <green@savannah.gnu.org> 05/09/16 22:52:18 Modified files: . : ChangeLog java/net : URLClassLoader.java Log message: 2005-09-15 Anthony Green <green@redhat.com> PR libgcj/20198 * java/net/URLClassLoader.java (FileURLLoader.getResource): File resources should all have canonicalized names. CVSWeb URLs: http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.4834&tr2=1.4835&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/java/net/URLClassLoader.java.diff?tr1=1.36&tr2=1.37&r1=text&r2=text
Testing a patch.
Subject: Bug 20198 Author: tromey Date: Tue Jan 17 19:59:29 2006 New Revision: 109837 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109837 Log: PR classpath/20198: * java/net/URLClassLoader.java (FileURLLoader): Added argument. (JarURLLoader): Likewise. (addURLImpl): Canonicalize file URLs. Modified: branches/gcc-4_1-branch/libjava/ChangeLog branches/gcc-4_1-branch/libjava/java/net/URLClassLoader.java
Subject: Bug 20198 Author: tromey Date: Tue Jan 17 23:25:12 2006 New Revision: 109844 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109844 Log: PR classpath/20198: * java/net/URLClassLoader.java (FileURLLoader): Added argument. (JarURLLoader): Likewise. (addURLImpl): Canonicalize file URLs. Modified: trunk/libjava/ChangeLog trunk/libjava/java/net/URLClassLoader.java
Fixed in classpath cvs; also in gcc 4.1.
Subject: Bug 20198 CVSROOT: /cvsroot/classpath Module name: classpath Branch: Changes by: Tom Tromey <tromey@savannah.gnu.org> 06/01/18 00:19:13 Modified files: . : ChangeLog java/net : URLClassLoader.java Log message: PR classpath/20198: * java/net/URLClassLoader.java (FileURLLoader): Added argument. (JarURLLoader): Likewise. (addURLImpl): Canonicalize file URLs. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.6106&tr2=1.6107&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/java/net/URLClassLoader.java.diff?tr1=1.43&tr2=1.44&r1=text&r2=text