--- a/jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Mon May 20 19:49:20 2013 +0400
+++ b/jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Fri May 31 21:25:42 2013 +0400
@@ -30,6 +30,9 @@
import java.util.*;
import sun.awt.datatransfer.DataTransferer;
+import sun.reflect.misc.ReflectUtil;
+
+import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
/**
* A {@code DataFlavor} provides meta information about data. {@code DataFlavor}
@@ -116,26 +119,36 @@
ClassLoader fallback)
throws ClassNotFoundException
{
- ClassLoader systemClassLoader = (ClassLoader)
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
- ClassLoader cl = Thread.currentThread().
- getContextClassLoader();
- return (cl != null)
- ? cl
- : ClassLoader.getSystemClassLoader();
+ ReflectUtil.checkPackageAccess(className);
+ try {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(GET_CLASSLOADER_PERMISSION);
+ }
+ ClassLoader loader = ClassLoader.getSystemClassLoader();
+ try {
+ // bootstrap class loader and system class loader if present
+ return Class.forName(className, true, loader);
+ }
+ catch (ClassNotFoundException exception) {
+ // thread context class loader if and only if present
+ loader = Thread.currentThread().getContextClassLoader();
+ if (loader != null) {
+ try {
+ return Class.forName(className, true, loader);
}
- });
-
- try {
- return Class.forName(className, true, systemClassLoader);
- } catch (ClassNotFoundException e2) {
- if (fallback != null) {
- return Class.forName(className, true, fallback);
- } else {
- throw new ClassNotFoundException(className);
+ catch (ClassNotFoundException e) {
+ // fallback to user's class loader
+ }
+ }
}
+ } catch (SecurityException exception) {
+ // ignore secured class loaders
+ }
+ if (fallback != null) {
+ return Class.forName(className, true, fallback);
+ } else {
+ throw new ClassNotFoundException(className);
}
}