use of com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl in project intellij-community by JetBrains.
the class LoaderFactory method createClassLoader.
private static ClassLoader createClassLoader(final String runClasspath, final String moduleName) {
final ArrayList<URL> urls = new ArrayList<>();
final VirtualFileManager manager = VirtualFileManager.getInstance();
final JarFileSystemImpl fileSystem = (JarFileSystemImpl) JarFileSystem.getInstance();
final StringTokenizer tokenizer = new StringTokenizer(runClasspath, File.pathSeparator);
while (tokenizer.hasMoreTokens()) {
final String s = tokenizer.nextToken();
try {
VirtualFile vFile = manager.findFileByUrl(VfsUtil.pathToUrl(s));
final File realFile = fileSystem.getMirroredFile(vFile);
urls.add(realFile != null ? realFile.toURI().toURL() : new File(s).toURI().toURL());
} catch (Exception e) {
// ignore ?
}
}
try {
urls.add(new File(PathUtil.getJarPathForClass(Spacer.class)).toURI().toURL());
} catch (MalformedURLException ignored) {
// ignore
}
final URL[] _urls = urls.toArray(new URL[urls.size()]);
return new DesignTimeClassLoader(Arrays.asList(_urls), LoaderFactory.class.getClassLoader(), moduleName);
}
use of com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl in project intellij-community by JetBrains.
the class JarFileSystemTest method testJarHandlerDoNotCreateCopyWhenListingArchive.
@Test
public void testJarHandlerDoNotCreateCopyWhenListingArchive() throws Exception {
File jar = IoTestUtil.createTestJar(tempDir.newFile("test.jar"));
JarHandler handler = new JarHandler(jar.getPath());
FileAttributes attributes = handler.getAttributes(JarFile.MANIFEST_NAME);
assertNotNull(attributes);
assertEquals(0, attributes.length);
assertTimestampsEqual(jar.lastModified(), attributes.lastModified);
if (((JarFileSystemImpl) JarFileSystem.getInstance()).isMakeCopyOfJar(jar)) {
// for performance reasons we create file copy on windows when we read contents and have the handle open to the copy
Field resolved = handler.getClass().getDeclaredField("myFileWithMirrorResolved");
resolved.setAccessible(true);
assertTrue(resolved.get(handler) == null);
}
}
Aggregations