Search in sources :

Example 1 with JarHandler

use of com.intellij.openapi.vfs.impl.jar.JarHandler 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);
    }
}
Also used : Field(java.lang.reflect.Field) JarFileSystemImpl(com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl) JarFile(java.util.jar.JarFile) JarHandler(com.intellij.openapi.vfs.impl.jar.JarHandler) FileAttributes(com.intellij.openapi.util.io.FileAttributes) Test(org.junit.Test)

Aggregations

FileAttributes (com.intellij.openapi.util.io.FileAttributes)1 JarFileSystemImpl (com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl)1 JarHandler (com.intellij.openapi.vfs.impl.jar.JarHandler)1 Field (java.lang.reflect.Field)1 JarFile (java.util.jar.JarFile)1 Test (org.junit.Test)1