diff options
author | Andy Clement <aclement@pivotal.io> | 2018-10-11 11:21:54 -0700 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2018-10-11 11:21:54 -0700 |
commit | 5eea7c541aeb642f0c35cab2c6a16cec779b8b72 (patch) | |
tree | fe6909693ecff3ad139aa0c3d69b1d94e9fc8c77 /weaver | |
parent | b0bd12a6f1efa815445ba3c9356d9781b4f1baaf (diff) | |
download | aspectj-5eea7c541aeb642f0c35cab2c6a16cec779b8b72.tar.gz aspectj-5eea7c541aeb642f0c35cab2c6a16cec779b8b72.zip |
537678: Lazy initialization of jrt filesystem
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java b/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java index 14fb6e9ac..f8a36ba98 100644 --- a/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java +++ b/weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java @@ -153,6 +153,7 @@ public class ClassPathManager { return null; } + @Override public String toString() { StringBuffer buf = new StringBuffer(); boolean start = true; @@ -220,11 +221,13 @@ public class ClassPathManager { this.file = file; } + @Override public InputStream getInputStream() throws IOException { fis = new FileInputStream(file); return fis; } + @Override public void close() { try { if (fis != null) @@ -236,6 +239,7 @@ public class ClassPathManager { } } + @Override public String getPath() { return file.getPath(); } @@ -252,6 +256,7 @@ public class ClassPathManager { this.dirPath = dirPath; } + @Override public ClassFile find(String name) { File f = new File(dirPath + File.separator + name.replace('.', File.separatorChar) + ".class"); if (f.isFile()) @@ -260,6 +265,7 @@ public class ClassPathManager { return null; } + @Override public String toString() { return dirPath; } @@ -275,11 +281,13 @@ public class ClassPathManager { this.entry = entry; } + @Override public InputStream getInputStream() throws IOException { is = zipFile.getZipFile().getInputStream(entry); return is; } + @Override public void close() { try { if (is != null) @@ -291,6 +299,7 @@ public class ClassPathManager { } } + @Override public String getPath() { return entry.getName(); } @@ -307,7 +316,7 @@ public class ClassPathManager { */ static class JImageEntry extends Entry { - private final static FileSystem fs = FileSystems.getFileSystem(JRT_URI); + private static FileSystem fs = null; private final static Map<String, Path> fileCache = new SoftHashMap<String, Path>(); @@ -316,6 +325,13 @@ public class ClassPathManager { private static boolean packageCacheInitialized = false; public JImageEntry() { + if (fs == null) { + try { + fs = FileSystems.getFileSystem(JRT_URI); + } catch (Throwable t) { + throw new IllegalStateException("Unexpectedly unable to initialize a JRT filesystem", t); + } + } buildPackageMap(); } @@ -394,6 +410,7 @@ public class ClassPathManager { return locator.found; } + @Override public ClassFile find(String name) throws IOException { String fileName = name.replace('.', '/') + ".class"; Path file = fileCache.get(fileName); @@ -448,6 +465,7 @@ public class ClassPathManager { return zipFile; } + @Override public ClassFile find(String name) throws IOException { ensureOpen(); String key = name.replace('.', '/') + ".class"; @@ -502,7 +520,7 @@ public class ClassPathManager { public void closeSomeArchives(int n) { for (int i = n - 1; i >= 0; i--) { - ZipFile zf = (ZipFile) openArchives.get(i); + ZipFile zf = openArchives.get(i); try { zf.close(); } catch (IOException e) { @@ -525,6 +543,7 @@ public class ClassPathManager { } } + @Override public String toString() { return file.getName(); } |