提交 da3cf22c 编写于 作者: M michaelm

8057936: java.net.URLClassLoader.findClass uses exceptions in control flow

Reviewed-by: alanb, chegar, dholmes, mr
Contributed-by: claes.redestad@oracle.com
上级 5178643e
...@@ -356,8 +356,9 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { ...@@ -356,8 +356,9 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
protected Class<?> findClass(final String name) protected Class<?> findClass(final String name)
throws ClassNotFoundException throws ClassNotFoundException
{ {
final Class<?> result;
try { try {
return AccessController.doPrivileged( result = AccessController.doPrivileged(
new PrivilegedExceptionAction<Class<?>>() { new PrivilegedExceptionAction<Class<?>>() {
public Class<?> run() throws ClassNotFoundException { public Class<?> run() throws ClassNotFoundException {
String path = name.replace('.', '/').concat(".class"); String path = name.replace('.', '/').concat(".class");
...@@ -369,13 +370,17 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { ...@@ -369,13 +370,17 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
throw new ClassNotFoundException(name, e); throw new ClassNotFoundException(name, e);
} }
} else { } else {
throw new ClassNotFoundException(name); return null;
} }
} }
}, acc); }, acc);
} catch (java.security.PrivilegedActionException pae) { } catch (java.security.PrivilegedActionException pae) {
throw (ClassNotFoundException) pae.getException(); throw (ClassNotFoundException) pae.getException();
} }
if (result == null) {
throw new ClassNotFoundException(name);
}
return result;
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册