|
Fix for VMClassLoader.getResource(): msg#00136java.classpath.patches
VMClassLoader.getResource() does not handle ZIP files on the boot loader class path. The attached patch fixes this. 2005-03-17 Archie Cobbs <archie@xxxxxxxxxxxx> * vm/reference/java/lang/VMClassLoader.java: handle ZIP files on the boot loader class path in getResources() I'll commit later today unless there are any issues. Thanks, -Archie __________________________________________________________________________ Archie Cobbs * CTO, Awarix * http://www.awarix.com Index: vm/reference/java/lang/VMClassLoader.java =================================================================== RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/VMClassLoader.java,v retrieving revision 1.23 diff -u -r1.23 VMClassLoader.java --- vm/reference/java/lang/VMClassLoader.java 12 Feb 2005 14:26:02 -0000 1.23 +++ vm/reference/java/lang/VMClassLoader.java 17 Mar 2005 15:39:39 -0000 @@ -42,14 +42,16 @@ import gnu.classpath.SystemProperties; import java.io.File; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.security.ProtectionDomain; import java.util.Enumeration; -import java.util.Map; import java.util.HashMap; +import java.util.Map; import java.util.StringTokenizer; import java.util.Vector; +import java.util.zip.ZipFile; /** * java.lang.VMClassLoader is a package-private helper for VMs to implement @@ -164,16 +166,55 @@ Vector v = new Vector(); while (st.hasMoreTokens()) { - File file = new File(st.nextToken(), name); - if (!file.exists()) - continue; - try + File file = new File(st.nextToken()); + if (file.isDirectory()) { - v.add(new URL("file://" + file.getAbsolutePath())); + try + { + v.add(new URL("file://" + + new File(file, name).getAbsolutePath())); + } + catch (MalformedURLException e) + { + throw new Error(e); + } } - catch (MalformedURLException e) + else if (file.isFile()) { - throw new Error(e); + ZipFile zip; + try + { + zip = new ZipFile(file); + } + catch (IOException e) + { + continue; + } + String zname = name.startsWith("/") ? name.substring(1) : name; + try + { + if (zip.getEntry(zname) == null) + continue; + } + finally + { + try + { + zip.close(); + } + catch (IOException e) + { + } + } + try + { + v.add(new URL("jar:file://" + + file.getAbsolutePath() + "!/" + zname)); + } + catch (MalformedURLException e) + { + throw new Error(e); + } } } return v.elements(); _______________________________________________ Classpath-patches mailing list Classpath-patches@xxxxxxx http://lists.gnu.org/mailman/listinfo/classpath-patches
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | FYI: HTML parser compatibility fixes, Meskauskas Audrius |
|---|---|
| Next by Date: | Re: [commit-cp] classpath ChangeLog.usermap, Tom Tromey |
| Previous by Thread: | FYI: HTML parser compatibility fixes, Meskauskas Audrius |
| Next by Thread: | Re: Fix for VMClassLoader.getResource(), Tom Tromey |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |