Przeglądaj źródła

537678: Lazy initialization of jrt filesystem

tags/V1_9_2RC3
Andy Clement 5 lat temu
rodzic
commit
5eea7c541a

+ 21
- 2
weaver/src/org/aspectj/weaver/bcel/ClassPathManager.java Wyświetl plik

return null; return null;
} }


@Override
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
boolean start = true; boolean start = true;
this.file = file; this.file = file;
} }


@Override
public InputStream getInputStream() throws IOException { public InputStream getInputStream() throws IOException {
fis = new FileInputStream(file); fis = new FileInputStream(file);
return fis; return fis;
} }


@Override
public void close() { public void close() {
try { try {
if (fis != null) if (fis != null)
} }
} }


@Override
public String getPath() { public String getPath() {
return file.getPath(); return file.getPath();
} }
this.dirPath = dirPath; this.dirPath = dirPath;
} }


@Override
public ClassFile find(String name) { public ClassFile find(String name) {
File f = new File(dirPath + File.separator + name.replace('.', File.separatorChar) + ".class"); File f = new File(dirPath + File.separator + name.replace('.', File.separatorChar) + ".class");
if (f.isFile()) if (f.isFile())
return null; return null;
} }


@Override
public String toString() { public String toString() {
return dirPath; return dirPath;
} }
this.entry = entry; this.entry = entry;
} }


@Override
public InputStream getInputStream() throws IOException { public InputStream getInputStream() throws IOException {
is = zipFile.getZipFile().getInputStream(entry); is = zipFile.getZipFile().getInputStream(entry);
return is; return is;
} }


@Override
public void close() { public void close() {
try { try {
if (is != null) if (is != null)
} }
} }


@Override
public String getPath() { public String getPath() {
return entry.getName(); return entry.getName();
} }
*/ */
static class JImageEntry extends Entry { 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>(); private final static Map<String, Path> fileCache = new SoftHashMap<String, Path>();


private static boolean packageCacheInitialized = false; private static boolean packageCacheInitialized = false;


public JImageEntry() { 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(); buildPackageMap();
} }
return locator.found; return locator.found;
} }


@Override
public ClassFile find(String name) throws IOException { public ClassFile find(String name) throws IOException {
String fileName = name.replace('.', '/') + ".class"; String fileName = name.replace('.', '/') + ".class";
Path file = fileCache.get(fileName); Path file = fileCache.get(fileName);
return zipFile; return zipFile;
} }


@Override
public ClassFile find(String name) throws IOException { public ClassFile find(String name) throws IOException {
ensureOpen(); ensureOpen();
String key = name.replace('.', '/') + ".class"; String key = name.replace('.', '/') + ".class";


public void closeSomeArchives(int n) { public void closeSomeArchives(int n) {
for (int i = n - 1; i >= 0; i--) { for (int i = n - 1; i >= 0; i--) {
ZipFile zf = (ZipFile) openArchives.get(i);
ZipFile zf = openArchives.get(i);
try { try {
zf.close(); zf.close();
} catch (IOException e) { } catch (IOException e) {
} }
} }


@Override
public String toString() { public String toString() {
return file.getName(); return file.getName();
} }

Ładowanie…
Anuluj
Zapisz