提交 c28d73ad 编写于 作者: D dfuchs

8001043: Clarify definition restrictions

Reviewed-by: alanb, skoivu, smarks
上级 7565cf52
...@@ -55,6 +55,7 @@ import java.util.IdentityHashMap; ...@@ -55,6 +55,7 @@ import java.util.IdentityHashMap;
import java.util.Map; import java.util.Map;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import sun.reflect.misc.ReflectUtil;
import sun.rmi.runtime.Log; import sun.rmi.runtime.Log;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
...@@ -170,7 +171,7 @@ public final class LoaderHandler { ...@@ -170,7 +171,7 @@ public final class LoaderHandler {
if (defaultLoader != null) { if (defaultLoader != null) {
try { try {
Class<?> c = Class.forName(name, false, defaultLoader); Class<?> c = loadClassForName(name, false, defaultLoader);
if (loaderLog.isLoggable(Log.VERBOSE)) { if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE, loaderLog.log(Log.VERBOSE,
"class \"" + name + "\" found via defaultLoader, " + "class \"" + name + "\" found via defaultLoader, " +
...@@ -422,7 +423,7 @@ public final class LoaderHandler { ...@@ -422,7 +423,7 @@ public final class LoaderHandler {
* resolved without the security-offending codebase anyway; * resolved without the security-offending codebase anyway;
* if so, return successfully (see bugids 4191926 & 4349670). * if so, return successfully (see bugids 4191926 & 4349670).
*/ */
Class<?> c = Class.forName(name, false, parent); Class<?> c = loadClassForName(name, false, parent);
if (loaderLog.isLoggable(Log.VERBOSE)) { if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE, loaderLog.log(Log.VERBOSE,
"class \"" + name + "\" found via " + "class \"" + name + "\" found via " +
...@@ -448,7 +449,7 @@ public final class LoaderHandler { ...@@ -448,7 +449,7 @@ public final class LoaderHandler {
} }
try { try {
Class<?> c = Class.forName(name, false, loader); Class<?> c = loadClassForName(name, false, loader);
if (loaderLog.isLoggable(Log.VERBOSE)) { if (loaderLog.isLoggable(Log.VERBOSE)) {
loaderLog.log(Log.VERBOSE, loaderLog.log(Log.VERBOSE,
"class \"" + name + "\" " + "found via codebase, " + "class \"" + name + "\" " + "found via codebase, " +
...@@ -726,7 +727,7 @@ public final class LoaderHandler { ...@@ -726,7 +727,7 @@ public final class LoaderHandler {
for (int i = 0; i < interfaces.length; i++) { for (int i = 0; i < interfaces.length; i++) {
Class<?> cl = Class<?> cl =
(classObjs[i] = Class.forName(interfaces[i], false, loader)); (classObjs[i] = loadClassForName(interfaces[i], false, loader));
if (!Modifier.isPublic(cl.getModifiers())) { if (!Modifier.isPublic(cl.getModifiers())) {
ClassLoader current = cl.getClassLoader(); ClassLoader current = cl.getClassLoader();
...@@ -1195,5 +1196,28 @@ public final class LoaderHandler { ...@@ -1195,5 +1196,28 @@ public final class LoaderHandler {
public String toString() { public String toString() {
return super.toString() + "[\"" + annotation + "\"]"; return super.toString() + "[\"" + annotation + "\"]";
} }
@Override
protected Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException {
if (parent == null) {
ReflectUtil.checkPackageAccess(name);
}
return super.loadClass(name, resolve);
}
} }
private static Class<?> loadClassForName(String name,
boolean initialize,
ClassLoader loader)
throws ClassNotFoundException
{
if (loader == null) {
ReflectUtil.checkPackageAccess(name);
}
return Class.forName(name, initialize, loader);
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册