Index: ChangeLog =================================================================== RCS file: /cvsroot/classpath/classpath/ChangeLog,v retrieving revision 1.1745 diff -u -b -B -r1.1745 ChangeLog --- ChangeLog 4 Jan 2004 20:39:18 -0000 1.1745 +++ ChangeLog 4 Jan 2004 21:07:26 -0000 @@ -1,5 +1,15 @@ 2004-01-04 Michael Koch + * java/net/JarURLConnection.java + (jarFileURLConnection): New field. + * gnu/java/net/protocol/jar/Connection.java + (Connection): Made class final. + (Connection): Made constructor protected. + (getJarFile): Check doInput. + (getInputStream): Likewise. + +2004-01-04 Michael Koch + * java/util/HashMap.java (HashMap(Map)): As above. (putAllInternal): As above. * java/util/Hashtable.java (Hashtable(Map)): Use putAll, not Index: java/net/JarURLConnection.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/net/JarURLConnection.java,v retrieving revision 1.16 diff -u -b -B -r1.16 JarURLConnection.java --- java/net/JarURLConnection.java 12 Oct 2003 17:24:37 -0000 1.16 +++ java/net/JarURLConnection.java 4 Jan 2004 21:07:26 -0000 @@ -79,6 +79,13 @@ private final URL jarFileURL; /** + * The connection to the jar file itself. A JarURLConnection + * can represent an entry in a jar file or an entire jar file. In + * either case this describes just the jar file itself. + */ + protected URLConnection jarFileURLConnection; + + /** * This is the jar file "entry name" or portion after the "!/" in the * URL which represents the pathname inside the actual jar file. */ Index: gnu/java/net/protocol/jar/Connection.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/net/protocol/jar/Connection.java,v retrieving revision 1.3 diff -u -b -B -r1.3 Connection.java --- gnu/java/net/protocol/jar/Connection.java 2 Dec 2003 09:05:23 -0000 1.3 +++ gnu/java/net/protocol/jar/Connection.java 4 Jan 2004 21:07:26 -0000 @@ -44,6 +44,7 @@ import java.io.IOException; import java.net.JarURLConnection; import java.net.MalformedURLException; +import java.net.ProtocolException; import java.net.URL; import java.net.URLConnection; import java.util.Hashtable; @@ -57,7 +58,7 @@ * * @author Kresten Krab Thorup */ -public class Connection extends JarURLConnection +public final class Connection extends JarURLConnection { private JarFile jar_file; private JarEntry jar_entry; @@ -120,14 +121,15 @@ } } - public Connection(URL url) + protected Connection(URL url) throws MalformedURLException { super(url); } - public void connect() throws IOException + public synchronized void connect() throws IOException { + // Call is ignored if already connected. if (connected) return; @@ -147,23 +149,29 @@ connected = true; } - public JarFile getJarFile() throws IOException + public InputStream getInputStream() throws IOException { if (!connected) connect(); - return jar_file; + if (! doInput) + throw new ProtocolException("Can't open InputStream if doInput is false"); + + if (jar_entry == null) + throw new IOException (jar_url + " couldn't be found."); + + return jar_file.getInputStream (jar_entry); } - public InputStream getInputStream() throws IOException + public synchronized JarFile getJarFile() throws IOException { if (!connected) connect(); - if (jar_entry == null) - throw new IOException (jar_url + " couldn't be found."); + if (! doInput) + throw new ProtocolException("Can't open JarFile if doInput is false"); - return jar_file.getInputStream (jar_entry); + return jar_file; } public int getContentLength()