2525
2626package sun .net .www .protocol .jar ;
2727
28- import java .io .InputStream ;
29- import java .io .IOException ;
30- import java .io .FileNotFoundException ;
3128import java .io .BufferedInputStream ;
32- import java .net .URL ;
33- import java .net .URLConnection ;
29+ import java .io .FileNotFoundException ;
30+ import java .io .IOException ;
31+ import java .io .InputStream ;
3432import java .net .MalformedURLException ;
35- import java .net .UnknownServiceException ;
36- import java .util .Enumeration ;
37- import java .util .Map ;
33+ import java .net .URL ;
34+ import java .security .Permission ;
3835import java .util .List ;
36+ import java .util .Map ;
3937import java .util .jar .JarEntry ;
4038import java .util .jar .JarFile ;
41- import java .util .jar .Manifest ;
42- import java .security .Permission ;
4339
4440/**
4541 * @author Benjamin Renaud
4642 * @since 1.2
4743 */
4844public class JarURLConnection extends java .net .JarURLConnection {
4945
50- private static final boolean debug = false ;
51-
5246 /* the Jar file factory. It handles both retrieval and caching.
5347 */
5448 private static final JarFileFactory factory = JarFileFactory .getInstance ();
5549
56- /* the url for the Jar file */
57- private URL jarFileURL ;
58-
59- /* the permission to get this JAR file. This is the actual, ultimate,
60- * permission, returned by the jar file factory.
61- */
62- private Permission permission ;
63-
64- /* the url connection for the JAR file */
65- private URLConnection jarFileURLConnection ;
66-
67- /* the entry name, if any */
68- private String entryName ;
69-
7050 /* the JarEntry */
7151 private JarEntry jarEntry ;
7252
@@ -80,12 +60,10 @@ public JarURLConnection(URL url, Handler handler)
8060 throws MalformedURLException , IOException {
8161 super (url );
8262
83- jarFileURL = getJarFileURL ();
84- jarFileURLConnection = jarFileURL .openConnection ();
63+ jarFileURLConnection = getJarFileURL ().openConnection ();
8564 // whether, or not, the embedded URL should use the cache will depend
8665 // on this instance's cache value
8766 jarFileURLConnection .setUseCaches (useCaches );
88- entryName = getEntryName ();
8967 }
9068
9169 public JarFile getJarFile () throws IOException {
@@ -120,7 +98,7 @@ public void close () throws IOException {
12098 public void connect () throws IOException {
12199 if (!connected ) {
122100 boolean useCaches = getUseCaches ();
123- String entryName = this . entryName ;
101+ String entryName = getEntryName () ;
124102
125103 /* the factory call will do the security checks */
126104 URL url = getJarFileURL ();
@@ -176,6 +154,7 @@ public InputStream getInputStream() throws IOException {
176154
177155 InputStream result = null ;
178156
157+ String entryName = getEntryName ();
179158 if (entryName == null ) {
180159 throw new IOException ("no entry name specified" );
181160 } else {
@@ -216,7 +195,7 @@ public Object getContent() throws IOException {
216195 Object result = null ;
217196
218197 connect ();
219- if (entryName == null ) {
198+ if (getEntryName () == null ) {
220199 result = jarFile ;
221200 } else {
222201 result = super .getContent ();
@@ -226,6 +205,7 @@ public Object getContent() throws IOException {
226205
227206 public String getContentType () {
228207 if (contentType == null ) {
208+ String entryName = getEntryName ();
229209 if (entryName == null ) {
230210 contentType = "x-java/jar" ;
231211 } else {
0 commit comments