changeset 10063:496893f26d3d

8057936: java.net.URLClassLoader.findClass uses exceptions in control flow Reviewed-by: alanb, chegar, dholmes, mr Contributed-by: claes.redestad@oracle.com
author michaelm
date Thu, 11 Sep 2014 15:51:46 +0100
parents 0091ae45d136
children e2029f9c1103
files src/share/classes/java/net/URLClassLoader.java
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/net/URLClassLoader.java	Tue Sep 30 13:38:58 2014 +0800
+++ b/src/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;
     }
 
     /*