diff --git a/platform/util/src/com/intellij/util/lang/ClassPath.java b/platform/util/src/com/intellij/util/lang/ClassPath.java index 2b1e99c7e792..65fea39be520 100644 --- a/platform/util/src/com/intellij/util/lang/ClassPath.java +++ b/platform/util/src/com/intellij/util/lang/ClassPath.java @@ -150,34 +150,34 @@ public class ClassPath { @Nullable private Loader getLoader(final URL url, int index) throws IOException { - String s; + String path; if (myAcceptUnescapedUrls) { - s = url.getFile(); + path = url.getFile(); } else { try { - s = url.toURI().getSchemeSpecificPart(); + path = url.toURI().getSchemeSpecificPart(); } catch (URISyntaxException thisShouldNotHappen) { //noinspection CallToPrintStackTrace thisShouldNotHappen.printStackTrace(); - s = url.getFile(); + path = url.getFile(); } } Loader loader = null; - if (s != null && new File(s).isDirectory()) { - if (URLUtil.FILE_PROTOCOL.equals(url.getProtocol())) { + if (path != null && URLUtil.FILE_PROTOCOL.equals(url.getProtocol())) { + File file = new File(path); + if (file.isDirectory()) { loader = new FileLoader(url, index); } - } - else { - JarLoader jarLoader = new JarLoader(url, myCanLockJars, index); - if (myPreloadJarContents) { - jarLoader.preLoadClasses(); + else if (file.isFile()) { + loader = new JarLoader(url, myCanLockJars, index); + if (myPreloadJarContents) { + ((JarLoader)loader).preloadClasses(); + } } - loader = jarLoader; } if (loader != null && myCanUseCache) { diff --git a/platform/util/src/com/intellij/util/lang/FileLoader.java b/platform/util/src/com/intellij/util/lang/FileLoader.java index d15926fcd698..7c5ae225f1f5 100644 --- a/platform/util/src/com/intellij/util/lang/FileLoader.java +++ b/platform/util/src/com/intellij/util/lang/FileLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,17 +29,10 @@ class FileLoader extends Loader { private static int misses; private static int hits; - @SuppressWarnings({"HardCodedStringLiteral"}) FileLoader(URL url, int index) throws IOException { super(url, index); - if (!"file".equals(url.getProtocol())) { - throw new IllegalArgumentException("url"); - } - else { - final String s = FileUtil.unquote(url.getFile()); - myRootDir = new File(s); - myRootDirAbsolutePath = myRootDir.getAbsolutePath(); - } + myRootDir = new File(FileUtil.unquote(url.getFile())); + myRootDirAbsolutePath = myRootDir.getAbsolutePath(); } private void buildPackageCache(final File dir, ClasspathCache cache) { diff --git a/platform/util/src/com/intellij/util/lang/JarLoader.java b/platform/util/src/com/intellij/util/lang/JarLoader.java index a789409a125b..6dcbef212b4c 100644 --- a/platform/util/src/com/intellij/util/lang/JarLoader.java +++ b/platform/util/src/com/intellij/util/lang/JarLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,9 +43,7 @@ class JarLoader extends Loader { @NotNull protected ZipFile calc() { try { - final ZipFile zipFile = doGetZipFile(); - if (zipFile == null) throw new RuntimeException("Can't load zip file"); - return zipFile; + return doGetZipFile(); } catch (IOException e) { throw new RuntimeException(e); @@ -59,7 +57,7 @@ class JarLoader extends Loader { myCanLockJar = canLockJar; } - void preLoadClasses() { + void preloadClasses() { ZipFile zipFile = null; try { zipFile = acquireZipFile(); @@ -102,19 +100,8 @@ class JarLoader extends Loader { } } - @Nullable private ZipFile doGetZipFile() throws IOException { - if (URLUtil.FILE_PROTOCOL.equals(myURL.getProtocol())) { - String s = FileUtil.unquote(myURL.getFile()); - if (!new File(s).exists()) { - throw new FileNotFoundException(s); - } - else { - return new ZipFile(s); - } - } - - return null; + return new ZipFile(FileUtil.unquote(myURL.getFile())); } @Override