--- old/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java 2018-02-20 21:46:40.621004678 -0800 +++ new/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java 2018-02-20 21:46:40.381002555 -0800 @@ -43,6 +43,7 @@ import java.security.AccessController; import java.security.CodeSigner; import java.security.Permission; +import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.security.cert.Certificate; import java.util.ArrayList; @@ -99,27 +100,30 @@ DISABLE_ACC_CHECKING = p != null ? p.equals("true") || p.equals("") : false; } - /* The original search path of URLs. */ + /** The original search path of URLs. */ private final List path; - /* The stack of unopened URLs */ + /** The stack of unopened URLs. */ private final Stack urls = new Stack<>(); - /* The resulting search path of Loaders */ + /** The resulting search path of Loaders. */ private final ArrayList loaders = new ArrayList<>(); - /* Map of each URL opened to its corresponding Loader */ + /** Map of each URL opened to its corresponding Loader. */ private final HashMap lmap = new HashMap<>(); - /* The jar protocol handler to use when creating new URLs */ + /** The jar protocol handler to use when creating new URLs. */ private final URLStreamHandler jarHandler; - /* Whether this URLClassLoader has been closed yet */ + /** Whether this URLClassLoader has been closed yet. */ private boolean closed = false; - /* The context to be used when loading classes and resources. If non-null - * this is the context that was captured during the creation of the - * URLClassLoader. null implies no additional security restrictions. */ + /** + * The context to be used when loading classes and resources. If + * non-null this is the context that was captured during the creation + * of the URLClassLoader. null implies no additional security + * restrictions. + */ private final AccessControlContext acc; /** @@ -209,7 +213,7 @@ try { loader.close(); } catch (IOException e) { - result.add (e); + result.add(e); } } closed = true; @@ -272,7 +276,7 @@ * * @param name the name of the resource * @param check whether to perform a security check - * @return a URL for the resource, or null + * @return a {@code URL} for the resource, or {@code null} * if the resource could not be found. */ public URL findResource(String name, boolean check) { @@ -403,7 +407,7 @@ return getResources(name, true); } - /* + /** * Returns the Loader at the specified position in the URL search * path. The URLs are opened and expanded as needed. Returns null * if the specified index is out of range. @@ -460,13 +464,13 @@ return loaders.get(index); } - /* + /** * Returns the Loader for the specified base URL. */ private Loader getLoader(final URL url) throws IOException { try { - return java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction<>() { + return AccessController.doPrivileged( + new PrivilegedExceptionAction<>() { public Loader run() throws IOException { String protocol = url.getProtocol(); // lower cased in URL String file = url.getFile(); @@ -487,7 +491,7 @@ } } }, acc); - } catch (java.security.PrivilegedActionException pae) { + } catch (PrivilegedActionException pae) { throw (IOException)pae.getException(); } } @@ -500,7 +504,7 @@ return h instanceof sun.net.www.protocol.jar.Handler; } - /* + /** * Pushes the specified URLs onto the list of unopened URLs. */ private void push(URL[] us) { @@ -511,9 +515,9 @@ } } - /* - * Check whether the resource URL should be returned. - * Return null on security check failure. + /** + * Checks whether the resource URL should be returned. + * Returns null on security check failure. * Called by java.net.URLClassLoader. */ public static URL checkURL(URL url) { @@ -527,9 +531,9 @@ return url; } - /* - * Check whether the resource URL should be returned. - * Throw exception on failure. + /** + * Checks whether the resource URL should be returned. + * Throws exception on failure. * Called internally within this file. */ public static void check(URL url) throws IOException { @@ -571,14 +575,14 @@ private final URL base; private JarFile jarfile; // if this points to a jar file - /* + /** * Creates a new Loader for the specified URL. */ Loader(URL url) { base = url; } - /* + /** * Returns the base URL for this Loader. */ URL getBaseURL() { @@ -658,7 +662,7 @@ }; } - /* + /** * Returns the Resource for the specified name, or null if not * found or the caller does not have the permission to get the * resource. @@ -667,9 +671,9 @@ return getResource(name, true); } - /* - * close this loader and release all resources - * method overridden in sub-classes + /** + * Closes this loader and release all resources. + * Method overridden in sub-classes. */ @Override public void close() throws IOException { @@ -678,7 +682,7 @@ } } - /* + /** * Returns the local class path for this loader, or null if none. */ URL[] getClassPath() throws IOException { @@ -686,7 +690,7 @@ } } - /* + /** * Nested class used to represent a Loader of resources from a JAR URL. */ static class JarLoader extends Loader { @@ -700,7 +704,7 @@ private static final JavaUtilZipFileAccess zipAccess = SharedSecrets.getJavaUtilZipFileAccess(); - /* + /** * Creates a new JarLoader for the specified URL referring to * a JAR file. */ @@ -740,8 +744,8 @@ private void ensureOpen() throws IOException { if (jar == null) { try { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction<>() { + AccessController.doPrivileged( + new PrivilegedExceptionAction<>() { public Void run() throws IOException { if (DEBUG) { System.err.println("Opening " + csu); @@ -757,7 +761,7 @@ // if the same URL occurs later on the main class path. We set // Loader to null here to avoid creating a Loader for each // URL until we actually need to try to load something from them. - for(int i = 0; i < jarfiles.length; i++) { + for (int i = 0; i < jarfiles.length; i++) { try { URL jarURL = new URL(csu, jarfiles[i]); // If a non-null loader already exists, leave it alone. @@ -773,13 +777,13 @@ return null; } }, acc); - } catch (java.security.PrivilegedActionException pae) { + } catch (PrivilegedActionException pae) { throw (IOException)pae.getException(); } } } - /* Throws if the given jar file is does not start with the correct LOC */ + /** Throws if the given jar file is does not start with the correct LOC */ static JarFile checkJar(JarFile jar) throws IOException { if (System.getSecurityManager() != null && !DISABLE_JAR_CHECKING && !zipAccess.startsWithLocHeader(jar)) { @@ -811,7 +815,7 @@ return checkJar(jarFile); } - /* + /** * Returns the index of this JarLoader if it exists. */ JarIndex getIndex() { @@ -823,7 +827,7 @@ return index; } - /* + /** * Creates the resource and if the check flag is set to true, checks if * is its okay to return the resource. */ @@ -869,14 +873,14 @@ } - /* + /** * Returns true iff at least one resource in the jar file has the same * package name as that of the specified resource name. */ boolean validIndex(final String name) { String packageName = name; int pos; - if((pos = name.lastIndexOf('/')) != -1) { + if ((pos = name.lastIndexOf('/')) != -1) { packageName = name.substring(0, pos); } @@ -886,7 +890,7 @@ while (enum_.hasMoreElements()) { entry = enum_.nextElement(); entryName = entry.getName(); - if((pos = entryName.lastIndexOf('/')) != -1) + if ((pos = entryName.lastIndexOf('/')) != -1) entryName = entryName.substring(0, pos); if (entryName.equals(packageName)) { return true; @@ -895,7 +899,7 @@ return false; } - /* + /** * Returns the URL for a resource with the specified name */ @Override @@ -907,7 +911,7 @@ return null; } - /* + /** * Returns the JAR Resource for the specified name. */ @Override @@ -928,12 +932,12 @@ return getResource(name, check, visited); } - /* + /** * Version of getResource() that tracks the jar files that have been * visited by linking through the index files. This helper method uses * a HashSet to store the URLs of jar files that have been searched and * uses it to avoid going into an infinite loop, looking for a - * non-existent resource + * non-existent resource. */ Resource getResource(final String name, boolean check, Set visited) { @@ -945,14 +949,14 @@ /* If there no jar files in the index that can potential contain * this resource then return immediately. */ - if((jarFilesList = index.get(name)) == null) + if ((jarFilesList = index.get(name)) == null) return null; do { int size = jarFilesList.size(); jarFiles = jarFilesList.toArray(new String[size]); /* loop through the mapped jar file list */ - while(count < size) { + while (count < size) { String jarName = jarFiles[count++]; JarLoader newLoader; final URL url; @@ -977,7 +981,7 @@ * account the relative path. */ JarIndex newIndex = newLoader.getIndex(); - if(newIndex != null) { + if (newIndex != null) { int pos = jarName.lastIndexOf('/'); newIndex.merge(this.index, (pos == -1 ? null : jarName.substring(0, pos + 1))); @@ -986,7 +990,7 @@ /* put it in the global hashtable */ lmap.put(urlNoFragString, newLoader); } - } catch (java.security.PrivilegedActionException pae) { + } catch (PrivilegedActionException pae) { continue; } catch (MalformedURLException e) { continue; @@ -1029,7 +1033,7 @@ /* Process the index of the new loader */ - if((res = newLoader.getResource(name, check, visited)) + if ((res = newLoader.getResource(name, check, visited)) != null) { return res; } @@ -1039,12 +1043,12 @@ jarFilesList = index.get(name); // If the count is unchanged, we are done. - } while(count < jarFilesList.size()); + } while (count < jarFilesList.size()); return null; } - /* + /** * Returns the JAR file local class path, or null if none. */ @Override @@ -1071,7 +1075,7 @@ return null; } - /* + /** * Parses value of the Class-Path manifest attribute and returns * an array of URLs relative to the specified base URL. */ @@ -1090,12 +1094,12 @@ } } - /* + /** * Nested class used to represent a loader of classes and resources * from a file URL that refers to a directory. */ private static class FileLoader extends Loader { - /* Canonicalized File */ + /** Canonicalized File */ private File dir; FileLoader(URL url) throws IOException { @@ -1108,7 +1112,7 @@ dir = (new File(path)).getCanonicalFile(); } - /* + /** * Returns the URL for a resource with the specified name */ @Override