8057936: java.net.URLClassLoader.findClass uses exceptions in control flow
Reviewed-by: alanb, chegar, dholmes, mr
Contributed-by: claes.redestad@oracle.com
--- 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;
}
/*