summaryrefslogtreecommitdiff
path: root/libjava/gnu
diff options
context:
space:
mode:
authormark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2002-12-09 00:04:00 +0000
committermark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2002-12-09 00:04:00 +0000
commit7a8b6aa6ff1178434f8b82b829b9a62d13650aa5 (patch)
tree6e19dd042b0e115509080d56c741014c959ca437 /libjava/gnu
parentf3782e9bd70c6eae9d91d261c091686ac4dc8c0b (diff)
downloadgcc-7a8b6aa6ff1178434f8b82b829b9a62d13650aa5.tar.gz
* gnu/gcj/protocol/jar/Connection.java (getJarFile): download and
cache remote jar files. * gnu/gcj/runtime/VMClassLoader.java: Don't construct jar URL, only add File.separator to URL when it is a directory. * java/lang/ClassLoader.java: Add Classpath javadoc. (parent): final. (getParent): Add (disabled) security check. (findLibrary): New default method. * java/net/JarURLConnection.java (getManifest): Implement. (getInputStream): Only create InputStream when entry exists. (getHeaders): Only use jarFileURLConnection or JarEntry to set length when they exist. * java/net/URLClassLoader.java: New/Rewritten version from Classpath. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@59949 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/gnu')
-rw-r--r--libjava/gnu/gcj/protocol/jar/Connection.java31
-rw-r--r--libjava/gnu/gcj/runtime/VMClassLoader.java21
2 files changed, 23 insertions, 29 deletions
diff --git a/libjava/gnu/gcj/protocol/jar/Connection.java b/libjava/gnu/gcj/protocol/jar/Connection.java
index 60641182f3a..c9db04997dc 100644
--- a/libjava/gnu/gcj/protocol/jar/Connection.java
+++ b/libjava/gnu/gcj/protocol/jar/Connection.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation
+/* Copyright (C) 1999, 2002 Free Software Foundation
This file is part of libgcj.
@@ -9,19 +9,21 @@ details. */
package gnu.gcj.protocol.jar;
import java.net.URL;
+import java.net.URLConnection;
import java.net.JarURLConnection;
import java.net.URLStreamHandler;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.File;
+import java.io.FileOutputStream;
import java.util.jar.JarFile;
+import java.util.zip.ZipFile;
import java.util.Hashtable;
/**
* Written using on-line Java Platform 1.2 API Specification.
- * Status: Needs a way to download jar files and store them in the local file
- * system. I don't know how to do that in a portable way. For now, it can only handle
- * connections to a jar:file: url's.
*
* @author Kresten Krab Thorup <krab@gnu.org>
* @date Aug 10, 1999.
@@ -70,14 +72,19 @@ public class Connection extends JarURLConnection
}
else
{
- /*
- FIXME: Here we need to download and cache the jar
- file in the local file system! Stupid design. Why
- can't we just create a JarFile from a bag of bytes?
- */
-
- throw new java.io.IOException("cannot create jar file from " +
- jarFileURL);
+ URLConnection urlconn = jarFileURL.openConnection();
+ InputStream is = urlconn.getInputStream();
+ byte[] buf = new byte[4*1024];
+ File f = File.createTempFile("cache", "jar");
+ FileOutputStream fos = new FileOutputStream(f);
+ int len = 0;
+ while((len = is.read(buf)) != -1)
+ fos.write(buf, 0, len);
+ fos.close();
+ // Always verify the Manifest, open read only and delete when done.
+ // XXX ZipFile.OPEN_DELETE not yet implemented.
+ // jf = new JarFile(f, true, ZipFile.OPEN_READ | ZipFile.OPEN_DELETE);
+ jarfile = new JarFile(f, true, ZipFile.OPEN_READ);
}
return jarfile;
diff --git a/libjava/gnu/gcj/runtime/VMClassLoader.java b/libjava/gnu/gcj/runtime/VMClassLoader.java
index 77d21606621..fd0c32c2c57 100644
--- a/libjava/gnu/gcj/runtime/VMClassLoader.java
+++ b/libjava/gnu/gcj/runtime/VMClassLoader.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2001 Free Software Foundation
+/* Copyright (C) 1999, 2001, 2002 Free Software Foundation
This file is part of libgcj.
@@ -33,23 +33,10 @@ public final class VMClassLoader extends java.net.URLClassLoader
String e = st.nextToken ();
try
{
- if (e.endsWith(".jar") || e.endsWith (".zip"))
- {
- File archive = new File (e);
- try {
- p.addElement(new URL("jar", "", -1, "file://"
- + archive.getCanonicalPath ()
- + "!/"));
- } catch (IOException ex) {
- // empty
- }
- }
- else if (e.endsWith ("/"))
- p.addElement (new URL("file", "", -1, e));
- else if (new File (e).isDirectory ())
- p.addElement (new URL("file", "", -1, e + "/"));
+ if (!e.endsWith (File.separator) && new File (e).isDirectory ())
+ p.addElement (new URL("file", "", -1, e + File.separator));
else
- /* Ignore path element. */;
+ p.addElement (new URL("file", "", -1, e));
}
catch (java.net.MalformedURLException x)
{