diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 569ac7af0c1b..fa595e20de73 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -20,11 +20,7 @@
-
-
-
-
-
+
diff --git a/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java b/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java
index 7937bec6bc8f..f92d61b29096 100644
--- a/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java
+++ b/java/openapi/src/com/intellij/openapi/roots/libraries/JarVersionDetectionUtil.java
@@ -80,7 +80,7 @@ public class JarVersionDetectionUtil {
return null;
}
try {
- final ZipEntry zipEntry = zipFile.getEntry(JarFile.MANIFEST_NAME);
+ final com.intellij.openapi.vfs.JarFile.JarEntry zipEntry = zipFile.getEntry(JarFile.MANIFEST_NAME);
if (zipEntry == null) {
return null;
}
diff --git a/platform/core-api/src/com/intellij/openapi/vfs/JarFile.java b/platform/core-api/src/com/intellij/openapi/vfs/JarFile.java
index 33f2e1c17b81..be4ec5be6e23 100644
--- a/platform/core-api/src/com/intellij/openapi/vfs/JarFile.java
+++ b/platform/core-api/src/com/intellij/openapi/vfs/JarFile.java
@@ -20,16 +20,22 @@ import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
-import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
* Encapsulates operations with .jar file
*/
public interface JarFile {
- ZipEntry getEntry(String name);
- InputStream getInputStream(ZipEntry entry) throws IOException;
- Enumeration extends ZipEntry> entries();
+ interface JarEntry {
+ String getName();
+ long getSize();
+ long getTime();
+ boolean isDirectory();
+ }
+
+ JarEntry getEntry(String name);
+ InputStream getInputStream(JarEntry entry) throws IOException;
+ Enumeration extends JarEntry> entries();
@Nullable ZipFile getZipFile();
}
diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandlerBase.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandlerBase.java
index 433fc1f55c77..e063890effdd 100644
--- a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandlerBase.java
+++ b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/JarHandlerBase.java
@@ -69,9 +69,9 @@ public class JarHandlerBase {
map = new THashMap();
if (zip != null) {
map.put("", new EntryInfo("", null, true));
- final Enumeration extends ZipEntry> entries = zip.entries();
+ final Enumeration extends JarFile.JarEntry> entries = zip.entries();
while (entries.hasMoreElements()) {
- ZipEntry entry = entries.nextElement();
+ JarFile.JarEntry entry = entries.nextElement();
final String name = entry.getName();
final boolean isDirectory = name.endsWith("/");
getOrCreate(isDirectory ? name.substring(0, name.length() - 1) : name, isDirectory, map);
@@ -104,20 +104,70 @@ public class JarHandlerBase {
protected JarFile createJarFile() {
try {
final ZipFile zipFile = new ZipFile(getMirrorFile(getOriginalFile()));
+
+ class MyJarEntry implements JarFile.JarEntry {
+ private ZipEntry myEntry;
+
+ MyJarEntry(ZipEntry entry) {
+ myEntry = entry;
+ }
+
+ public ZipEntry getEntry() {
+ return myEntry;
+ }
+
+ @Override
+ public String getName() {
+ return myEntry.getName();
+ }
+
+ @Override
+ public long getSize() {
+ return myEntry.getSize();
+ }
+
+ @Override
+ public long getTime() {
+ return myEntry.getTime();
+ }
+
+ @Override
+ public boolean isDirectory() {
+ return myEntry.isDirectory();
+ }
+ }
+
return new JarFile() {
@Override
- public ZipEntry getEntry(String name) {
- return zipFile.getEntry(name);
+ public JarFile.JarEntry getEntry(String name) {
+ ZipEntry entry = zipFile.getEntry(name);
+ if (entry == null)
+ return null;
+ return new MyJarEntry(entry);
}
@Override
- public InputStream getInputStream(ZipEntry entry) throws IOException {
- return zipFile.getInputStream(entry);
+ public InputStream getInputStream(JarFile.JarEntry entry) throws IOException {
+ return zipFile.getInputStream(((MyJarEntry)entry).myEntry);
}
@Override
- public Enumeration extends ZipEntry> entries() {
- return zipFile.entries();
+ public Enumeration extends JarFile.JarEntry> entries() {
+ final Enumeration extends ZipEntry> entries = zipFile.entries();
+ return new Enumeration() {
+ @Override
+ public boolean hasMoreElements() {
+ return entries.hasMoreElements();
+ }
+
+ @Override
+ public JarEntry nextElement() {
+ ZipEntry entry = entries.nextElement();
+ if (entry == null)
+ return null;
+ return new MyJarEntry(entry);
+ }
+ };
}
@Override
@@ -187,7 +237,7 @@ public class JarHandlerBase {
}
@Nullable
- private ZipEntry convertToEntry(VirtualFile file) {
+ private JarFile.JarEntry convertToEntry(VirtualFile file) {
String path = getRelativePath(file);
final JarFile jar = getJar();
return jar != null ? jar.getEntry(path) : null;
@@ -195,7 +245,7 @@ public class JarHandlerBase {
public long getLength(@NotNull final VirtualFile file) {
synchronized (lock) {
- final ZipEntry entry = convertToEntry(file);
+ final JarFile.JarEntry entry = convertToEntry(file);
return entry != null ? entry.getSize() : 0;
}
}
@@ -208,7 +258,7 @@ public class JarHandlerBase {
@NotNull
public byte[] contentsToByteArray(@NotNull final VirtualFile file) throws IOException {
synchronized (lock) {
- final ZipEntry entry = convertToEntry(file);
+ final JarFile.JarEntry entry = convertToEntry(file);
if (entry == null) {
return new byte[0];
}
@@ -231,7 +281,7 @@ public class JarHandlerBase {
public long getTimeStamp(@NotNull final VirtualFile file) {
if (file.getParent() == null) return getOriginalFile().lastModified(); // Optimization
synchronized (lock) {
- final ZipEntry entry = convertToEntry(file);
+ final JarFile.JarEntry entry = convertToEntry(file);
return entry != null ? entry.getTime() : -1L;
}
}
@@ -257,7 +307,7 @@ public class JarHandlerBase {
@Nullable
public FileAttributes getAttributes(@NotNull final VirtualFile file) {
synchronized (lock) {
- final ZipEntry entry = convertToEntry(file);
+ final JarFile.JarEntry entry = convertToEntry(file);
return entry != null ? new FileAttributes(entry.isDirectory(), false, false, entry.getSize(), entry.getTime(), false) : null;
}
}
diff --git a/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java b/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java
index fdf5d8044391..59fc46c7f6ad 100644
--- a/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java
+++ b/platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java
@@ -44,7 +44,6 @@ import java.util.List;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
-import java.util.zip.ZipEntry;
public class JdkUtil {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.projectRoots.JdkUtil");
@@ -96,7 +95,7 @@ public class JdkUtil {
return null;
}
try {
- ZipEntry entry = manifestJarFile.getEntry(JarFile.MANIFEST_NAME);
+ com.intellij.openapi.vfs.JarFile.JarEntry entry = manifestJarFile.getEntry(JarFile.MANIFEST_NAME);
if (entry == null) {
return null;
}