8344065: Remove SecurityManager uses from the java.datatransfer module
Reviewed-by: serb
This commit is contained in:
parent
db56266ad1
commit
99070658fd
@ -313,7 +313,6 @@ module java.base {
|
||||
java.desktop;
|
||||
exports sun.reflect.misc to
|
||||
java.desktop,
|
||||
java.datatransfer,
|
||||
java.management,
|
||||
java.management.rmi,
|
||||
java.rmi,
|
||||
|
@ -45,7 +45,6 @@ import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
import sun.datatransfer.DataFlavorUtil;
|
||||
import sun.reflect.misc.ReflectUtil;
|
||||
|
||||
/**
|
||||
* A {@code DataFlavor} provides meta information about data. {@code DataFlavor}
|
||||
@ -131,32 +130,22 @@ public class DataFlavor implements Externalizable, Cloneable {
|
||||
ClassLoader fallback)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
ReflectUtil.checkPackageAccess(className);
|
||||
ClassLoader loader = ClassLoader.getSystemClassLoader();
|
||||
try {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(new RuntimePermission("getClassLoader"));
|
||||
}
|
||||
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
|
||||
}
|
||||
// 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
|
||||
}
|
||||
return Class.forName(className, true, fallback);
|
||||
}
|
||||
|
@ -30,8 +30,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -202,12 +200,8 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
|
||||
}
|
||||
isMapInitialized = true;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
InputStream is = AccessController.doPrivileged(
|
||||
(PrivilegedAction<InputStream>) () -> {
|
||||
return SystemFlavorMap.class.getResourceAsStream(
|
||||
InputStream is = SystemFlavorMap.class.getResourceAsStream(
|
||||
"/sun/datatransfer/resources/flavormap.properties");
|
||||
});
|
||||
if (is == null) {
|
||||
throw new InternalError("Default flavor mapping not found");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user