@Override @Nullable Resource getResource(String name, boolean flag) { JarMemoryLoader loader = myMemoryLoader != null ? myMemoryLoader.get() : null; if (loader != null) { Resource resource = loader.getResource(name); if (resource != null) return resource; } try { ZipFile zipFile = getZipFile(); try { ZipEntry entry = zipFile.getEntry(name); if (entry != null) { return MemoryResource.load(getBaseURL(), zipFile, entry, myAttributes); } } finally { releaseZipFile(zipFile); } } catch (Exception e) { error("file: " + myCanonicalFile, e); } return null; }
JarLoader( URL url, @SuppressWarnings("unused") boolean canLockJar, int index, boolean preloadJarContents) throws IOException { super(new URL("jar", "", -1, url + "!/"), index); myCanonicalFile = new File(FileUtil.unquote(url.getFile())).getCanonicalFile(); myCanLockJar = canLockJar; ZipFile zipFile = getZipFile(); // IOException from opening is propagated to caller if zip file isn't valid, try { myAttributes = getAttributes(zipFile); if (preloadJarContents) { JarMemoryLoader loader = JarMemoryLoader.load(zipFile, getBaseURL(), myAttributes); if (loader != null) { myMemoryLoader = new SoftReference<JarMemoryLoader>(loader); } } } finally { releaseZipFile(zipFile); } }