mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-20 15:25:27 +00:00
8012277: Improve AWT DataFlavor
Reviewed-by: art, skoivu
This commit is contained in:
parent
5c6c0246cc
commit
d86660d21b
@ -30,6 +30,9 @@ import java.nio.*;
|
||||
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 @@ public class DataFlavor implements Externalizable, Cloneable {
|
||||
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 {
|
||||
return Class.forName(className, true, systemClassLoader);
|
||||
} catch (ClassNotFoundException e2) {
|
||||
if (fallback != null) {
|
||||
return Class.forName(className, true, fallback);
|
||||
} else {
|
||||
throw new ClassNotFoundException(className);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user