equal
deleted
inserted
replaced
83 if (result == null) { |
83 if (result == null) { |
84 local_result = URLJarFile.getJarFile(url, this); |
84 local_result = URLJarFile.getJarFile(url, this); |
85 synchronized (instance) { |
85 synchronized (instance) { |
86 result = getCachedJarFile(url); |
86 result = getCachedJarFile(url); |
87 if (result == null) { |
87 if (result == null) { |
88 fileCache.put(URLUtil.urlNoFragString(url), local_result); |
88 fileCache.put(urlKey(url), local_result); |
89 urlCache.put(local_result, url); |
89 urlCache.put(local_result, url); |
90 result = local_result; |
90 result = local_result; |
91 } else { |
91 } else { |
92 if (local_result != null) { |
92 if (local_result != null) { |
93 local_result.close(); |
93 local_result.close(); |
111 */ |
111 */ |
112 public void close(JarFile jarFile) { |
112 public void close(JarFile jarFile) { |
113 synchronized (instance) { |
113 synchronized (instance) { |
114 URL urlRemoved = urlCache.remove(jarFile); |
114 URL urlRemoved = urlCache.remove(jarFile); |
115 if (urlRemoved != null) |
115 if (urlRemoved != null) |
116 fileCache.remove(URLUtil.urlNoFragString(urlRemoved)); |
116 fileCache.remove(urlKey(urlRemoved)); |
117 } |
117 } |
118 } |
118 } |
119 |
119 |
120 private JarFile getCachedJarFile(URL url) { |
120 private JarFile getCachedJarFile(URL url) { |
121 assert Thread.holdsLock(instance); |
121 assert Thread.holdsLock(instance); |
122 JarFile result = fileCache.get(URLUtil.urlNoFragString(url)); |
122 JarFile result = fileCache.get(urlKey(url)); |
123 |
123 |
124 /* if the JAR file is cached, the permission will always be there */ |
124 /* if the JAR file is cached, the permission will always be there */ |
125 if (result != null) { |
125 if (result != null) { |
126 Permission perm = getPermission(result); |
126 Permission perm = getPermission(result); |
127 if (perm != null) { |
127 if (perm != null) { |
147 } |
147 } |
148 } |
148 } |
149 return result; |
149 return result; |
150 } |
150 } |
151 |
151 |
|
152 private String urlKey(URL url) { |
|
153 String urlstr = URLUtil.urlNoFragString(url); |
|
154 if ("runtime".equals(url.getRef())) urlstr += "#runtime"; |
|
155 return urlstr; |
|
156 } |
|
157 |
152 private Permission getPermission(JarFile jarFile) { |
158 private Permission getPermission(JarFile jarFile) { |
153 try { |
159 try { |
154 URLConnection uc = getConnection(jarFile); |
160 URLConnection uc = getConnection(jarFile); |
155 if (uc != null) |
161 if (uc != null) |
156 return uc.getPermission(); |
162 return uc.getPermission(); |