[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] Fix for VMClassLoader.getResource()
From: |
Archie Cobbs |
Subject: |
[cp-patches] Fix for VMClassLoader.getResource() |
Date: |
Thu, 17 Mar 2005 09:40:08 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.3) Gecko/20041129 |
VMClassLoader.getResource() does not handle ZIP files on the boot loader
class path. The attached patch fixes this.
2005-03-17 Archie Cobbs <address@hidden>
* 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();
- [cp-patches] Fix for VMClassLoader.getResource(),
Archie Cobbs <=