8057936: java.net.URLClassLoader.findClass uses exceptions in control flow
authormichaelm
Thu, 11 Sep 2014 15:51:46 +0100
changeset 26487 605e2ffaec14
parent 26486 718b4d0243ab
child 26488 5b5fccd9d016
8057936: java.net.URLClassLoader.findClass uses exceptions in control flow Reviewed-by: alanb, chegar, dholmes, mr Contributed-by: claes.redestad@oracle.com
jdk/src/java.base/share/classes/java/net/URLClassLoader.java
--- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java	Thu Sep 11 06:21:10 2014 -0700
+++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java	Thu Sep 11 15:51:46 2014 +0100
@@ -354,10 +354,11 @@
      * @exception NullPointerException if {@code name} is {@code null}.
      */
     protected Class<?> findClass(final String name)
-         throws ClassNotFoundException
+        throws ClassNotFoundException
     {
+        final Class<?> result;
         try {
-            return AccessController.doPrivileged(
+            result = AccessController.doPrivileged(
                 new PrivilegedExceptionAction<Class<?>>() {
                     public Class<?> run() throws ClassNotFoundException {
                         String path = name.replace('.', '/').concat(".class");
@@ -369,13 +370,17 @@
                                 throw new ClassNotFoundException(name, e);
                             }
                         } else {
-                            throw new ClassNotFoundException(name);
+                            return null;
                         }
                     }
                 }, acc);
         } catch (java.security.PrivilegedActionException pae) {
             throw (ClassNotFoundException) pae.getException();
         }
+        if (result == null) {
+            throw new ClassNotFoundException(name);
+        }
+        return result;
     }
 
     /*