# HG changeset patch # User michaelm # Date 1410447106 -3600 # Node ID 605e2ffaec1402d9483a5e18e8c70c48d8b21664 # Parent 718b4d0243ab2a07634956ce5c34e60fb9ebb5ec 8057936: java.net.URLClassLoader.findClass uses exceptions in control flow Reviewed-by: alanb, chegar, dholmes, mr Contributed-by: claes.redestad@oracle.com diff -r 718b4d0243ab -r 605e2ffaec14 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>() { 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; } /*