equal
deleted
inserted
replaced
93 if (result == null) { |
93 if (result == null) { |
94 local_result = URLJarFile.getJarFile(url, this); |
94 local_result = URLJarFile.getJarFile(url, this); |
95 synchronized (instance) { |
95 synchronized (instance) { |
96 result = getCachedJarFile(url); |
96 result = getCachedJarFile(url); |
97 if (result == null) { |
97 if (result == null) { |
98 fileCache.put(URLUtil.urlNoFragString(url), local_result); |
98 fileCache.put(urlKey(url), local_result); |
99 urlCache.put(local_result, url); |
99 urlCache.put(local_result, url); |
100 result = local_result; |
100 result = local_result; |
101 } else { |
101 } else { |
102 if (local_result != null) { |
102 if (local_result != null) { |
103 local_result.close(); |
103 local_result.close(); |
121 */ |
121 */ |
122 public void close(JarFile jarFile) { |
122 public void close(JarFile jarFile) { |
123 synchronized (instance) { |
123 synchronized (instance) { |
124 URL urlRemoved = urlCache.remove(jarFile); |
124 URL urlRemoved = urlCache.remove(jarFile); |
125 if (urlRemoved != null) |
125 if (urlRemoved != null) |
126 fileCache.remove(URLUtil.urlNoFragString(urlRemoved)); |
126 fileCache.remove(urlKey(urlRemoved)); |
127 } |
127 } |
128 } |
128 } |
129 |
129 |
130 private JarFile getCachedJarFile(URL url) { |
130 private JarFile getCachedJarFile(URL url) { |
131 assert Thread.holdsLock(instance); |
131 assert Thread.holdsLock(instance); |
132 JarFile result = fileCache.get(URLUtil.urlNoFragString(url)); |
132 JarFile result = fileCache.get(urlKey(url)); |
133 |
133 |
134 /* if the JAR file is cached, the permission will always be there */ |
134 /* if the JAR file is cached, the permission will always be there */ |
135 if (result != null) { |
135 if (result != null) { |
136 Permission perm = getPermission(result); |
136 Permission perm = getPermission(result); |
137 if (perm != null) { |
137 if (perm != null) { |
157 } |
157 } |
158 } |
158 } |
159 return result; |
159 return result; |
160 } |
160 } |
161 |
161 |
|
162 private String urlKey(URL url) { |
|
163 String urlstr = URLUtil.urlNoFragString(url); |
|
164 if ("runtime".equals(url.getRef())) urlstr += "#runtime"; |
|
165 return urlstr; |
|
166 } |
|
167 |
162 private Permission getPermission(JarFile jarFile) { |
168 private Permission getPermission(JarFile jarFile) { |
163 try { |
169 try { |
164 URLConnection uc = getConnection(jarFile); |
170 URLConnection uc = getConnection(jarFile); |
165 if (uc != null) |
171 if (uc != null) |
166 return uc.getPermission(); |
172 return uc.getPermission(); |