summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArchie Cobbs <archie@dellroad.org>2005-03-19 23:07:55 +0000
committerArchie Cobbs <archie@dellroad.org>2005-03-19 23:07:55 +0000
commitd80a44cef8648585309737ae7c7daa78012fb3d3 (patch)
tree43e96938142fdcaa6af80a4f887c57c9a25b01e9
parent683f56ec74dd0ee6c5a416a7fb5a42238e885476 (diff)
downloadclasspath-d80a44cef8648585309737ae7c7daa78012fb3d3.tar.gz
* vm/reference/java/lang/VMClassLoader.java: handle ZIP files
on the boot loader class path in getResources()
-rw-r--r--ChangeLog5
-rw-r--r--vm/reference/java/lang/VMClassLoader.java57
2 files changed, 54 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index bfcbd567a..be04384f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-03-17 Archie Cobbs <archie@dellroad.org>
+
+ * vm/reference/java/lang/VMClassLoader.java: handle ZIP files
+ on the boot loader class path in getResources()
+
2005-03-19 Audrius Meskauskas <audriusa@bluewin.ch>
* org/omg/CORBA/AnySeqHolder.java,
diff --git a/vm/reference/java/lang/VMClassLoader.java b/vm/reference/java/lang/VMClassLoader.java
index a3058e5a4..203cc062d 100644
--- a/vm/reference/java/lang/VMClassLoader.java
+++ b/vm/reference/java/lang/VMClassLoader.java
@@ -42,14 +42,16 @@ package java.lang;
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 @@ final class VMClassLoader
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();