8344062: Remove doPrivileged calls from awt and beans classes in the java.desktop module
Reviewed-by: serb
This commit is contained in:
parent
fc8fb34f3d
commit
1bb0d3baaa
@ -627,14 +627,10 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
initIDs();
|
initIDs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
String s = System.getProperty("awt.image.incrementaldraw");
|
||||||
String s = java.security.AccessController.doPrivileged(
|
|
||||||
new GetPropertyAction("awt.image.incrementaldraw"));
|
|
||||||
isInc = (s == null || s.equals("true"));
|
isInc = (s == null || s.equals("true"));
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
String s2 = System.getProperty("awt.image.redrawrate");
|
||||||
String s2 = java.security.AccessController.doPrivileged(
|
|
||||||
new GetPropertyAction("awt.image.redrawrate"));
|
|
||||||
incRate = (s2 != null) ? Integer.parseInt(s2) : 100;
|
incRate = (s2 != null) ? Integer.parseInt(s2) : 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1431,15 +1427,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
throw new HeadlessException();
|
throw new HeadlessException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
PointerInfo pi = MouseInfo.getPointerInfo();
|
||||||
PointerInfo pi = java.security.AccessController.doPrivileged(
|
|
||||||
new java.security.PrivilegedAction<PointerInfo>() {
|
|
||||||
public PointerInfo run() {
|
|
||||||
return MouseInfo.getPointerInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
synchronized (getTreeLock()) {
|
synchronized (getTreeLock()) {
|
||||||
Component inTheSameWindow = findUnderMouseInWindow(pi);
|
Component inTheSameWindow = findUnderMouseInWindow(pi);
|
||||||
if (!isSameOrAncestorOf(inTheSameWindow, true)) {
|
if (!isSameOrAncestorOf(inTheSameWindow, true)) {
|
||||||
@ -6253,14 +6241,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Need to check non-bootstraps.
|
// Need to check non-bootstraps.
|
||||||
@SuppressWarnings("removal")
|
Boolean enabled = isCoalesceEventsOverriden(clazz);
|
||||||
Boolean enabled = java.security.AccessController.doPrivileged(
|
|
||||||
new java.security.PrivilegedAction<Boolean>() {
|
|
||||||
public Boolean run() {
|
|
||||||
return isCoalesceEventsOverriden(clazz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
coalesceMap.put(clazz, enabled);
|
coalesceMap.put(clazz, enabled);
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
@ -1576,10 +1576,8 @@ public class Container extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't lazy-read because every app uses invalidate()
|
// Don't lazy-read because every app uses invalidate()
|
||||||
@SuppressWarnings("removal")
|
private static final boolean isJavaAwtSmartInvalidate =
|
||||||
private static final boolean isJavaAwtSmartInvalidate
|
Boolean.getBoolean("java.awt.smartInvalidate");
|
||||||
= AccessController.doPrivileged(
|
|
||||||
new GetBooleanAction("java.awt.smartInvalidate"));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidates the parent of the container unless the container
|
* Invalidates the parent of the container unless the container
|
||||||
@ -2632,14 +2630,7 @@ public class Container extends Component {
|
|||||||
if (GraphicsEnvironment.isHeadless()) {
|
if (GraphicsEnvironment.isHeadless()) {
|
||||||
throw new HeadlessException();
|
throw new HeadlessException();
|
||||||
}
|
}
|
||||||
@SuppressWarnings("removal")
|
PointerInfo pi = MouseInfo.getPointerInfo();
|
||||||
PointerInfo pi = java.security.AccessController.doPrivileged(
|
|
||||||
new java.security.PrivilegedAction<PointerInfo>() {
|
|
||||||
public PointerInfo run() {
|
|
||||||
return MouseInfo.getPointerInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
synchronized (getTreeLock()) {
|
synchronized (getTreeLock()) {
|
||||||
Component inTheSameWindow = findUnderMouseInWindow(pi);
|
Component inTheSameWindow = findUnderMouseInWindow(pi);
|
||||||
if (isSameOrAncestorOf(inTheSameWindow, allowChildren)) {
|
if (isSameOrAncestorOf(inTheSameWindow, allowChildren)) {
|
||||||
@ -4738,33 +4729,17 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
|
|||||||
* from other heavyweight containers will generate enter/exit
|
* from other heavyweight containers will generate enter/exit
|
||||||
* events in this container
|
* events in this container
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private void startListeningForOtherDrags() {
|
private void startListeningForOtherDrags() {
|
||||||
//System.out.println("Adding AWTEventListener");
|
//System.out.println("Adding AWTEventListener");
|
||||||
java.security.AccessController.doPrivileged(
|
nativeContainer.getToolkit().addAWTEventListener(
|
||||||
new java.security.PrivilegedAction<Object>() {
|
LightweightDispatcher.this,
|
||||||
public Object run() {
|
AWTEvent.MOUSE_EVENT_MASK |
|
||||||
nativeContainer.getToolkit().addAWTEventListener(
|
AWTEvent.MOUSE_MOTION_EVENT_MASK);
|
||||||
LightweightDispatcher.this,
|
|
||||||
AWTEvent.MOUSE_EVENT_MASK |
|
|
||||||
AWTEvent.MOUSE_MOTION_EVENT_MASK);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private void stopListeningForOtherDrags() {
|
private void stopListeningForOtherDrags() {
|
||||||
//System.out.println("Removing AWTEventListener");
|
//System.out.println("Removing AWTEventListener");
|
||||||
java.security.AccessController.doPrivileged(
|
nativeContainer.getToolkit().removeAWTEventListener(LightweightDispatcher.this);
|
||||||
new java.security.PrivilegedAction<Object>() {
|
|
||||||
public Object run() {
|
|
||||||
nativeContainer.getToolkit().removeAWTEventListener(LightweightDispatcher.this);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -29,8 +29,6 @@ import java.beans.ConstructorProperties;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.security.PrivilegedExceptionAction;
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
@ -332,11 +330,7 @@ public class Cursor implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
final Toolkit toolkit = Toolkit.getDefaultToolkit();
|
final Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||||
final String file = RESOURCE_PREFIX + fileName;
|
final String file = RESOURCE_PREFIX + fileName;
|
||||||
@SuppressWarnings("removal")
|
final InputStream in = Cursor.class.getResourceAsStream(file);
|
||||||
final InputStream in = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<InputStream>) () -> {
|
|
||||||
return Cursor.class.getResourceAsStream(file);
|
|
||||||
});
|
|
||||||
try (in) {
|
try (in) {
|
||||||
Image image = toolkit.createImage(in.readAllBytes());
|
Image image = toolkit.createImage(in.readAllBytes());
|
||||||
cursor = toolkit.createCustomCursor(image, hotPoint, localized);
|
cursor = toolkit.createCustomCursor(image, hotPoint, localized);
|
||||||
@ -428,7 +422,6 @@ public class Cursor implements java.io.Serializable {
|
|||||||
/*
|
/*
|
||||||
* load the cursor.properties file
|
* load the cursor.properties file
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static void loadSystemCustomCursorProperties() throws AWTException {
|
private static void loadSystemCustomCursorProperties() throws AWTException {
|
||||||
synchronized (systemCustomCursors) {
|
synchronized (systemCustomCursors) {
|
||||||
if (systemCustomCursorProperties != null) {
|
if (systemCustomCursorProperties != null) {
|
||||||
@ -437,14 +430,8 @@ public class Cursor implements java.io.Serializable {
|
|||||||
systemCustomCursorProperties = new Properties();
|
systemCustomCursorProperties = new Properties();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AccessController.doPrivileged(
|
InputStream is = Cursor.class.getResourceAsStream(PROPERTIES_FILE);
|
||||||
(PrivilegedExceptionAction<Object>) () -> {
|
systemCustomCursorProperties.load(is);
|
||||||
try (InputStream is = Cursor.class
|
|
||||||
.getResourceAsStream(PROPERTIES_FILE)) {
|
|
||||||
systemCustomCursorProperties.load(is);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
systemCustomCursorProperties = null;
|
systemCustomCursorProperties = null;
|
||||||
throw new AWTException("Exception: " + e.getClass() + " " +
|
throw new AWTException("Exception: " + e.getClass() + " " +
|
||||||
|
@ -32,8 +32,6 @@ import java.awt.peer.ComponentPeer;
|
|||||||
import java.awt.peer.LightweightPeer;
|
import java.awt.peer.LightweightPeer;
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
@ -86,21 +84,14 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
|
|||||||
initStatic();
|
initStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static void initStatic() {
|
private static void initStatic() {
|
||||||
AWTAccessor.setDefaultKeyboardFocusManagerAccessor(
|
AWTAccessor.setDefaultKeyboardFocusManagerAccessor(
|
||||||
new AWTAccessor.DefaultKeyboardFocusManagerAccessor() {
|
new AWTAccessor.DefaultKeyboardFocusManagerAccessor() {
|
||||||
public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e) {
|
public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e) {
|
||||||
dkfm.consumeNextKeyTyped(e);
|
dkfm.consumeNextKeyTyped(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
fxAppThreadIsDispatchThread = "true".equals(System.getProperty("javafx.embed.singleThread"));
|
||||||
public Object run() {
|
|
||||||
fxAppThreadIsDispatchThread =
|
|
||||||
"true".equals(System.getProperty("javafx.embed.singleThread"));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,8 +42,6 @@ import java.io.FilePermission;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.swing.JMenuBar;
|
import javax.swing.JMenuBar;
|
||||||
@ -936,11 +934,7 @@ public class Desktop {
|
|||||||
sm.checkDelete(file.getPath());
|
sm.checkDelete(file.getPath());
|
||||||
}
|
}
|
||||||
checkActionSupport(Action.MOVE_TO_TRASH);
|
checkActionSupport(Action.MOVE_TO_TRASH);
|
||||||
final File finalFile = file;
|
checkFileValidation(file);
|
||||||
AccessController.doPrivileged((PrivilegedAction<?>) () -> {
|
|
||||||
checkFileValidation(finalFile);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
return peer.moveToTrash(file);
|
return peer.moveToTrash(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,6 @@ import java.io.IOException;
|
|||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.security.AccessControlException;
|
import java.security.AccessControlException;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
@ -1052,9 +1050,7 @@ public class Dialog extends Window {
|
|||||||
|
|
||||||
modalityPushed();
|
modalityPushed();
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("removal")
|
EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
|
||||||
final EventQueue eventQueue = AccessController.doPrivileged(
|
|
||||||
(PrivilegedAction<EventQueue>) Toolkit.getDefaultToolkit()::getSystemEventQueue);
|
|
||||||
secondaryLoop = eventQueue.createSecondaryLoop(() -> true, modalFilter, 0);
|
secondaryLoop = eventQueue.createSecondaryLoop(() -> true, modalFilter, 0);
|
||||||
if (!secondaryLoop.enter()) {
|
if (!secondaryLoop.enter()) {
|
||||||
secondaryLoop = null;
|
secondaryLoop = null;
|
||||||
|
@ -32,9 +32,6 @@ import java.awt.peer.ComponentPeer;
|
|||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
|
|
||||||
import java.util.EmptyStackException;
|
import java.util.EmptyStackException;
|
||||||
|
|
||||||
import sun.awt.*;
|
import sun.awt.*;
|
||||||
@ -45,11 +42,6 @@ import java.util.concurrent.locks.Condition;
|
|||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import java.security.AccessControlContext;
|
|
||||||
|
|
||||||
import jdk.internal.access.SharedSecrets;
|
|
||||||
import jdk.internal.access.JavaSecurityAccess;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code EventQueue} is a platform-independent class
|
* {@code EventQueue} is a platform-independent class
|
||||||
* that queues events, both from the underlying peer classes
|
* that queues events, both from the underlying peer classes
|
||||||
@ -229,13 +221,8 @@ public class EventQueue {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static boolean fxAppThreadIsDispatchThread =
|
private static boolean fxAppThreadIsDispatchThread =
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
|
"true".equals(System.getProperty("javafx.embed.singleThread"));
|
||||||
public Boolean run() {
|
|
||||||
return "true".equals(System.getProperty("javafx.embed.singleThread"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new instance of {@code EventQueue}.
|
* Initializes a new instance of {@code EventQueue}.
|
||||||
@ -668,9 +655,6 @@ public class EventQueue {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final JavaSecurityAccess javaSecurityAccess =
|
|
||||||
SharedSecrets.getJavaSecurityAccess();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatches an event. The manner in which the event is
|
* Dispatches an event. The manner in which the event is
|
||||||
* dispatched depends upon the type of the event and the
|
* dispatched depends upon the type of the event and the
|
||||||
@ -711,59 +695,25 @@ public class EventQueue {
|
|||||||
*/
|
*/
|
||||||
protected void dispatchEvent(final AWTEvent event) {
|
protected void dispatchEvent(final AWTEvent event) {
|
||||||
final Object src = event.getSource();
|
final Object src = event.getSource();
|
||||||
final PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
|
// In case fwDispatcher is installed and we're already on the
|
||||||
public Void run() {
|
// dispatch thread (e.g. performing DefaultKeyboardFocusManager.sendMessage),
|
||||||
// In case fwDispatcher is installed and we're already on the
|
// dispatch the event straight away.
|
||||||
// dispatch thread (e.g. performing DefaultKeyboardFocusManager.sendMessage),
|
if (fwDispatcher == null || isDispatchThreadImpl()) {
|
||||||
// dispatch the event straight away.
|
dispatchEventImpl(event, src);
|
||||||
if (fwDispatcher == null || isDispatchThreadImpl()) {
|
|
||||||
dispatchEventImpl(event, src);
|
|
||||||
} else {
|
|
||||||
fwDispatcher.scheduleDispatch(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (dispatchThread.filterAndCheckEvent(event)) {
|
|
||||||
dispatchEventImpl(event, src);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
final AccessControlContext stack = AccessController.getContext();
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
final AccessControlContext srcAcc = getAccessControlContextFrom(src);
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
final AccessControlContext eventAcc = event.getAccessControlContext();
|
|
||||||
if (srcAcc == null) {
|
|
||||||
javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc);
|
|
||||||
} else {
|
} else {
|
||||||
javaSecurityAccess.doIntersectionPrivilege(
|
fwDispatcher.scheduleDispatch(new Runnable() {
|
||||||
new PrivilegedAction<Void>() {
|
@Override
|
||||||
public Void run() {
|
public void run() {
|
||||||
javaSecurityAccess.doIntersectionPrivilege(action, eventAcc);
|
if (dispatchThread.filterAndCheckEvent(event)) {
|
||||||
return null;
|
dispatchEventImpl(event, src);
|
||||||
}
|
}
|
||||||
}, stack, srcAcc);
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static AccessControlContext getAccessControlContextFrom(Object src) {
|
|
||||||
return src instanceof Component ?
|
|
||||||
((Component)src).getAccessControlContext() :
|
|
||||||
src instanceof MenuComponent ?
|
|
||||||
((MenuComponent)src).getAccessControlContext() :
|
|
||||||
src instanceof TrayIcon ?
|
|
||||||
((TrayIcon)src).getAccessControlContext() :
|
|
||||||
null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from dispatchEvent() under a correct AccessControlContext
|
* Called from dispatchEvent()
|
||||||
*/
|
*/
|
||||||
private void dispatchEventImpl(final AWTEvent event, final Object src) {
|
private void dispatchEventImpl(final AWTEvent event, final Object src) {
|
||||||
event.isPosted = true;
|
event.isPosted = true;
|
||||||
@ -1113,21 +1063,12 @@ public class EventQueue {
|
|||||||
pushPopLock.lock();
|
pushPopLock.lock();
|
||||||
try {
|
try {
|
||||||
if (dispatchThread == null && !threadGroup.isDestroyed() && !appContext.isDisposed()) {
|
if (dispatchThread == null && !threadGroup.isDestroyed() && !appContext.isDisposed()) {
|
||||||
dispatchThread = AccessController.doPrivileged(
|
EventDispatchThread t = new EventDispatchThread(threadGroup, name, EventQueue.this);
|
||||||
new PrivilegedAction<EventDispatchThread>() {
|
t.setContextClassLoader(classLoader);
|
||||||
public EventDispatchThread run() {
|
t.setPriority(Thread.NORM_PRIORITY + 1);
|
||||||
EventDispatchThread t =
|
t.setDaemon(false);
|
||||||
new EventDispatchThread(threadGroup,
|
AWTAutoShutdown.getInstance().notifyThreadBusy(t);
|
||||||
name,
|
dispatchThread = t;
|
||||||
EventQueue.this);
|
|
||||||
t.setContextClassLoader(classLoader);
|
|
||||||
t.setPriority(Thread.NORM_PRIORITY + 1);
|
|
||||||
t.setDaemon(false);
|
|
||||||
AWTAutoShutdown.getInstance().notifyThreadBusy(t);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
dispatchThread.start();
|
dispatchThread.start();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -44,8 +44,6 @@ import java.io.OutputStream;
|
|||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedExceptionAction;
|
|
||||||
import java.text.AttributedCharacterIterator.Attribute;
|
import java.text.AttributedCharacterIterator.Attribute;
|
||||||
import java.text.CharacterIterator;
|
import java.text.CharacterIterator;
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
@ -1095,7 +1093,6 @@ public class Font implements java.io.Serializable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static Font[] createFont0(int fontFormat, InputStream fontStream,
|
private static Font[] createFont0(int fontFormat, InputStream fontStream,
|
||||||
boolean allFonts,
|
boolean allFonts,
|
||||||
CreatedFontTracker tracker)
|
CreatedFontTracker tracker)
|
||||||
@ -1107,27 +1104,14 @@ public class Font implements java.io.Serializable
|
|||||||
}
|
}
|
||||||
boolean copiedFontData = false;
|
boolean copiedFontData = false;
|
||||||
try {
|
try {
|
||||||
final File tFile = AccessController.doPrivileged(
|
final File tFile = Files.createTempFile("+~JF", ".tmp").toFile();
|
||||||
new PrivilegedExceptionAction<File>() {
|
|
||||||
public File run() throws IOException {
|
|
||||||
return Files.createTempFile("+~JF", ".tmp").toFile();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if (tracker != null) {
|
if (tracker != null) {
|
||||||
tracker.add(tFile);
|
tracker.add(tFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalSize = 0;
|
int totalSize = 0;
|
||||||
try {
|
try {
|
||||||
final OutputStream outStream =
|
final OutputStream outStream = new FileOutputStream(tFile);
|
||||||
AccessController.doPrivileged(
|
|
||||||
new PrivilegedExceptionAction<OutputStream>() {
|
|
||||||
public OutputStream run() throws IOException {
|
|
||||||
return new FileOutputStream(tFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if (tracker != null) {
|
if (tracker != null) {
|
||||||
tracker.set(tFile, outStream);
|
tracker.set(tFile, outStream);
|
||||||
}
|
}
|
||||||
@ -1181,14 +1165,7 @@ public class Font implements java.io.Serializable
|
|||||||
if (tracker != null) {
|
if (tracker != null) {
|
||||||
tracker.subBytes(totalSize);
|
tracker.subBytes(totalSize);
|
||||||
}
|
}
|
||||||
AccessController.doPrivileged(
|
tFile.delete();
|
||||||
new PrivilegedExceptionAction<Void>() {
|
|
||||||
public Void run() {
|
|
||||||
tFile.delete();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
package java.awt;
|
package java.awt;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import sun.awt.PlatformGraphicsInfo;
|
import sun.awt.PlatformGraphicsInfo;
|
||||||
@ -137,20 +135,16 @@ public abstract class GraphicsEnvironment {
|
|||||||
* @return the value of the property "java.awt.headless"
|
* @return the value of the property "java.awt.headless"
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static boolean getHeadlessProperty() {
|
private static boolean getHeadlessProperty() {
|
||||||
if (headless == null) {
|
if (headless == null) {
|
||||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
String nm = System.getProperty("java.awt.headless");
|
||||||
String nm = System.getProperty("java.awt.headless");
|
|
||||||
|
|
||||||
if (nm == null) {
|
if (nm == null) {
|
||||||
headless = defaultHeadless =
|
headless = defaultHeadless =
|
||||||
PlatformGraphicsInfo.getDefaultHeadlessProperty();
|
PlatformGraphicsInfo.getDefaultHeadlessProperty();
|
||||||
} else {
|
} else {
|
||||||
headless = Boolean.valueOf(nm);
|
headless = Boolean.valueOf(nm);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return headless;
|
return headless;
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,6 @@ import java.beans.VetoableChangeSupport;
|
|||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -601,14 +598,8 @@ public abstract class KeyboardFocusManager
|
|||||||
peer.clearGlobalFocusOwner(activeWindow);
|
peer.clearGlobalFocusOwner(activeWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
void clearGlobalFocusOwnerPriv() {
|
void clearGlobalFocusOwnerPriv() {
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
clearGlobalFocusOwner();
|
||||||
public Void run() {
|
|
||||||
clearGlobalFocusOwner();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component getNativeFocusOwner() {
|
Component getNativeFocusOwner() {
|
||||||
@ -1194,14 +1185,8 @@ public abstract class KeyboardFocusManager
|
|||||||
newFocusCycleRoot);
|
newFocusCycleRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
void setGlobalCurrentFocusCycleRootPriv(final Container newFocusCycleRoot) {
|
void setGlobalCurrentFocusCycleRootPriv(final Container newFocusCycleRoot) {
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
setGlobalCurrentFocusCycleRoot(newFocusCycleRoot);
|
||||||
public Void run() {
|
|
||||||
setGlobalCurrentFocusCycleRoot(newFocusCycleRoot);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
package java.awt;
|
package java.awt;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import sun.awt.AWTAccessor;
|
import sun.awt.AWTAccessor;
|
||||||
@ -80,13 +78,7 @@ class SequencedEvent extends AWTEvent implements ActiveEvent {
|
|||||||
return new SequencedEvent(event);
|
return new SequencedEvent(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
fxAppThreadIsDispatchThread = "true".equals(System.getProperty("javafx.embed.singleThread"));
|
||||||
public Object run() {
|
|
||||||
fxAppThreadIsDispatchThread =
|
|
||||||
"true".equals(System.getProperty("javafx.embed.singleThread"));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class SequencedEventsFilter implements EventFilter {
|
private static final class SequencedEventsFilter implements EventFilter {
|
||||||
|
@ -129,13 +129,7 @@ public final class SplashScreen {
|
|||||||
}
|
}
|
||||||
// SplashScreen class is now a singleton
|
// SplashScreen class is now a singleton
|
||||||
if (!wasClosed && theInstance == null) {
|
if (!wasClosed && theInstance == null) {
|
||||||
java.security.AccessController.doPrivileged(
|
System.loadLibrary("splashscreen");
|
||||||
new java.security.PrivilegedAction<Void>() {
|
|
||||||
public Void run() {
|
|
||||||
System.loadLibrary("splashscreen");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
long ptr = _getInstance();
|
long ptr = _getInstance();
|
||||||
if (ptr != 0 && _isVisible(ptr)) {
|
if (ptr != 0 && _isVisible(ptr)) {
|
||||||
theInstance = new SplashScreen(ptr);
|
theInstance = new SplashScreen(ptr);
|
||||||
|
@ -56,8 +56,6 @@ import java.beans.PropertyChangeSupport;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
@ -396,18 +394,12 @@ public abstract class Toolkit {
|
|||||||
* properties are set up properly before any classes dependent upon them
|
* properties are set up properly before any classes dependent upon them
|
||||||
* are initialized.
|
* are initialized.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static void initAssistiveTechnologies() {
|
private static void initAssistiveTechnologies() {
|
||||||
|
|
||||||
// Get accessibility properties
|
// Get accessibility properties
|
||||||
final String sep = File.separator;
|
final String sep = File.separator;
|
||||||
final Properties properties = new Properties();
|
final Properties properties = new Properties();
|
||||||
|
|
||||||
|
|
||||||
atNames = java.security.AccessController.doPrivileged(
|
|
||||||
new java.security.PrivilegedAction<String>() {
|
|
||||||
public String run() {
|
|
||||||
|
|
||||||
// Try loading the per-user accessibility properties file.
|
// Try loading the per-user accessibility properties file.
|
||||||
try {
|
try {
|
||||||
File propsFile = new File(
|
File propsFile = new File(
|
||||||
@ -459,9 +451,7 @@ public abstract class Toolkit {
|
|||||||
System.setProperty("javax.accessibility.assistive_technologies", classNames);
|
System.setProperty("javax.accessibility.assistive_technologies", classNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return classNames;
|
atNames = classNames;
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -512,7 +502,6 @@ public abstract class Toolkit {
|
|||||||
* {@code null} it is ignored. All other errors are handled via an AWTError
|
* {@code null} it is ignored. All other errors are handled via an AWTError
|
||||||
* exception.
|
* exception.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static void loadAssistiveTechnologies() {
|
private static void loadAssistiveTechnologies() {
|
||||||
// Load any assistive technologies
|
// Load any assistive technologies
|
||||||
if (atNames != null && !atNames.isBlank()) {
|
if (atNames != null && !atNames.isBlank()) {
|
||||||
@ -521,20 +510,17 @@ public abstract class Toolkit {
|
|||||||
.map(String::trim)
|
.map(String::trim)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
final Map<String, AccessibilityProvider> providers = new HashMap<>();
|
final Map<String, AccessibilityProvider> providers = new HashMap<>();
|
||||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
try {
|
||||||
try {
|
for (AccessibilityProvider p : ServiceLoader.load(AccessibilityProvider.class, cl)) {
|
||||||
for (AccessibilityProvider p : ServiceLoader.load(AccessibilityProvider.class, cl)) {
|
String name = p.getName();
|
||||||
String name = p.getName();
|
if (names.contains(name) && !providers.containsKey(name)) {
|
||||||
if (names.contains(name) && !providers.containsKey(name)) {
|
p.activate();
|
||||||
p.activate();
|
providers.put(name, p);
|
||||||
providers.put(name, p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (java.util.ServiceConfigurationError | Exception e) {
|
|
||||||
newAWTError(e, "Could not load or activate service provider");
|
|
||||||
}
|
}
|
||||||
return null;
|
} catch (java.util.ServiceConfigurationError | Exception e) {
|
||||||
});
|
newAWTError(e, "Could not load or activate service provider");
|
||||||
|
}
|
||||||
names.stream()
|
names.stream()
|
||||||
.filter(n -> !providers.containsKey(n))
|
.filter(n -> !providers.containsKey(n))
|
||||||
.forEach(Toolkit::fallbackToLoadClassForAT);
|
.forEach(Toolkit::fallbackToLoadClassForAT);
|
||||||
@ -1302,16 +1288,10 @@ public abstract class Toolkit {
|
|||||||
* directly. -hung
|
* directly. -hung
|
||||||
*/
|
*/
|
||||||
private static boolean loaded = false;
|
private static boolean loaded = false;
|
||||||
@SuppressWarnings({"removal", "restricted"})
|
@SuppressWarnings("restricted")
|
||||||
static void loadLibraries() {
|
static void loadLibraries() {
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
java.security.AccessController.doPrivileged(
|
System.loadLibrary("awt");
|
||||||
new java.security.PrivilegedAction<Void>() {
|
|
||||||
public Void run() {
|
|
||||||
System.loadLibrary("awt");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1320,7 +1300,6 @@ public abstract class Toolkit {
|
|||||||
initStatic();
|
initStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static void initStatic() {
|
private static void initStatic() {
|
||||||
AWTAccessor.setToolkitAccessor(
|
AWTAccessor.setToolkitAccessor(
|
||||||
new AWTAccessor.ToolkitAccessor() {
|
new AWTAccessor.ToolkitAccessor() {
|
||||||
@ -1330,17 +1309,11 @@ public abstract class Toolkit {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
java.security.AccessController.doPrivileged(
|
try {
|
||||||
new java.security.PrivilegedAction<Void>() {
|
resources = ResourceBundle.getBundle("sun.awt.resources.awt");
|
||||||
public Void run() {
|
} catch (MissingResourceException e) {
|
||||||
try {
|
// No resource file; defaults will be used.
|
||||||
resources = ResourceBundle.getBundle("sun.awt.resources.awt");
|
}
|
||||||
} catch (MissingResourceException e) {
|
|
||||||
// No resource file; defaults will be used.
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// ensure that the proper libraries are loaded
|
// ensure that the proper libraries are loaded
|
||||||
loadLibraries();
|
loadLibraries();
|
||||||
|
@ -29,9 +29,6 @@ import java.util.Timer;
|
|||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.security.AccessController;
|
|
||||||
|
|
||||||
import sun.awt.PeerEvent;
|
import sun.awt.PeerEvent;
|
||||||
|
|
||||||
import sun.util.logging.PlatformLogger;
|
import sun.util.logging.PlatformLogger;
|
||||||
@ -230,13 +227,7 @@ class WaitDispatchSupport implements SecondaryLoop {
|
|||||||
// The event will be handled after the new event pump
|
// The event will be handled after the new event pump
|
||||||
// starts. Thus, the enter() method will not hang.
|
// starts. Thus, the enter() method will not hang.
|
||||||
//
|
//
|
||||||
// Event pump should be privileged. See 6300270.
|
run.run();
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
|
||||||
public Void run() {
|
|
||||||
run.run();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
|
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
|
||||||
log.finest("On non-dispatch thread: " + currentThread);
|
log.finest("On non-dispatch thread: " + currentThread);
|
||||||
|
@ -48,7 +48,6 @@ import java.io.Serial;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
@ -414,13 +413,9 @@ public class Window extends Container implements Accessible {
|
|||||||
initIDs();
|
initIDs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
String s = System.getProperty("java.awt.syncLWRequests");
|
||||||
String s = java.security.AccessController.doPrivileged(
|
|
||||||
new GetPropertyAction("java.awt.syncLWRequests"));
|
|
||||||
systemSyncLWRequests = "true".equals(s);
|
systemSyncLWRequests = "true".equals(s);
|
||||||
@SuppressWarnings("removal")
|
String s2 = System.getProperty("java.awt.Window.locationByPlatform");
|
||||||
String s2 = java.security.AccessController.doPrivileged(
|
|
||||||
new GetPropertyAction("java.awt.Window.locationByPlatform"));
|
|
||||||
locationByPlatformProp = "true".equals(s2);
|
locationByPlatformProp = "true".equals(s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +500,6 @@ public class Window extends Container implements Accessible {
|
|||||||
weakThis = new WeakReference<Window>(this);
|
weakThis = new WeakReference<Window>(this);
|
||||||
addToWindowList();
|
addToWindowList();
|
||||||
|
|
||||||
setWarningString();
|
|
||||||
this.cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
|
this.cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
|
|
||||||
@ -1376,24 +1370,6 @@ public class Window extends Container implements Accessible {
|
|||||||
return warningString;
|
return warningString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private void setWarningString() {
|
|
||||||
warningString = null;
|
|
||||||
SecurityManager sm = System.getSecurityManager();
|
|
||||||
if (sm != null) {
|
|
||||||
try {
|
|
||||||
sm.checkPermission(AWTPermissions.TOPLEVEL_WINDOW_PERMISSION);
|
|
||||||
} catch (SecurityException se) {
|
|
||||||
// make sure the privileged action is only
|
|
||||||
// for getting the property! We don't want the
|
|
||||||
// above checkPermission call to always succeed!
|
|
||||||
warningString = AccessController.doPrivileged(
|
|
||||||
new GetPropertyAction("awt.appletWarning",
|
|
||||||
"Java Applet Window"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@code Locale} object that is associated
|
* Gets the {@code Locale} object that is associated
|
||||||
* with this window, if the locale has been set.
|
* with this window, if the locale has been set.
|
||||||
@ -2978,7 +2954,6 @@ public class Window extends Container implements Accessible {
|
|||||||
// user's code.
|
// user's code.
|
||||||
//
|
//
|
||||||
private void initDeserializedWindow() {
|
private void initDeserializedWindow() {
|
||||||
setWarningString();
|
|
||||||
inputContextLock = new Object();
|
inputContextLock = new Object();
|
||||||
|
|
||||||
// Deserialized Windows are not yet visible.
|
// Deserialized Windows are not yet visible.
|
||||||
|
@ -48,8 +48,6 @@ import java.io.ObjectStreamException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
@ -1341,13 +1339,8 @@ public sealed class ICC_Profile implements Serializable
|
|||||||
* fileName. If there is no built-in profile with such name, then the method
|
* fileName. If there is no built-in profile with such name, then the method
|
||||||
* returns {@code null}.
|
* returns {@code null}.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static InputStream getStandardProfileInputStream(String fileName) {
|
private static InputStream getStandardProfileInputStream(String fileName) {
|
||||||
return AccessController.doPrivileged(
|
return PCMM.class.getResourceAsStream("profiles/" + fileName);
|
||||||
(PrivilegedAction<InputStream>) () -> {
|
|
||||||
return PCMM.class.getResourceAsStream("profiles/" + fileName);
|
|
||||||
}, null, new FilePermission("<<ALL FILES>>", "read"),
|
|
||||||
new RuntimePermission("accessSystemModules"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,13 +40,11 @@ import java.io.ObjectInputStream;
|
|||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
|
|
||||||
import sun.awt.AWTAccessor;
|
import sun.awt.AWTAccessor;
|
||||||
import sun.awt.AWTAccessor.DragSourceContextAccessor;
|
import sun.awt.AWTAccessor.DragSourceContextAccessor;
|
||||||
import sun.awt.dnd.SunDragSourceContextPeer;
|
import sun.awt.dnd.SunDragSourceContextPeer;
|
||||||
import sun.security.action.GetIntegerAction;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code DragSource} is the entity responsible
|
* The {@code DragSource} is the entity responsible
|
||||||
@ -908,8 +906,7 @@ public class DragSource implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public static int getDragThreshold() {
|
public static int getDragThreshold() {
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
int ts = AccessController.doPrivileged(
|
int ts = Integer.getInteger("awt.dnd.drag.threshold", 0);
|
||||||
new GetIntegerAction("awt.dnd.drag.threshold", 0)).intValue();
|
|
||||||
if (ts > 0) {
|
if (ts > 0) {
|
||||||
return ts;
|
return ts;
|
||||||
} else {
|
} else {
|
||||||
|
@ -52,14 +52,8 @@ class NativeLibLoader {
|
|||||||
* For now, we know it's done by the implementation, and we assume
|
* For now, we know it's done by the implementation, and we assume
|
||||||
* that the name of the library is "awt". -br.
|
* that the name of the library is "awt". -br.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"removal", "restricted"})
|
@SuppressWarnings("restricted")
|
||||||
static void loadLibraries() {
|
static void loadLibraries() {
|
||||||
java.security.AccessController.doPrivileged(
|
System.loadLibrary("awt");
|
||||||
new java.security.PrivilegedAction<Void>() {
|
|
||||||
public Void run() {
|
|
||||||
System.loadLibrary("awt");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,6 @@ import java.awt.Point;
|
|||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Transparency;
|
import java.awt.Transparency;
|
||||||
import java.awt.color.ColorSpace;
|
import java.awt.color.ColorSpace;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
@ -800,26 +798,16 @@ public class BufferedImage extends java.awt.Image
|
|||||||
} // else if ((raster instanceof ByteComponentRaster) &&
|
} // else if ((raster instanceof ByteComponentRaster) &&
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private static boolean isStandard(ColorModel cm, WritableRaster wr) {
|
private static boolean isStandard(ColorModel cm, WritableRaster wr) {
|
||||||
final Class<? extends ColorModel> cmClass = cm.getClass();
|
final Class<? extends ColorModel> cmClass = cm.getClass();
|
||||||
final Class<? extends WritableRaster> wrClass = wr.getClass();
|
final Class<? extends WritableRaster> wrClass = wr.getClass();
|
||||||
final Class<? extends SampleModel> smClass = wr.getSampleModel().getClass();
|
final Class<? extends SampleModel> smClass = wr.getSampleModel().getClass();
|
||||||
|
|
||||||
final PrivilegedAction<Boolean> checkClassLoadersAction =
|
final ClassLoader std = System.class.getClassLoader();
|
||||||
new PrivilegedAction<Boolean>()
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
return (cmClass.getClassLoader() == std) &&
|
||||||
public Boolean run() {
|
(smClass.getClassLoader() == std) &&
|
||||||
final ClassLoader std = System.class.getClassLoader();
|
(wrClass.getClassLoader() == std);
|
||||||
|
|
||||||
return (cmClass.getClassLoader() == std) &&
|
|
||||||
(smClass.getClassLoader() == std) &&
|
|
||||||
(wrClass.getClassLoader() == std);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return AccessController.doPrivileged(checkClassLoadersAction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,16 +202,10 @@ public abstract class ColorModel implements Transparency{
|
|||||||
* that the name of the library is "awt". -br.
|
* that the name of the library is "awt". -br.
|
||||||
*/
|
*/
|
||||||
private static boolean loaded = false;
|
private static boolean loaded = false;
|
||||||
@SuppressWarnings({"removal", "restricted"})
|
@SuppressWarnings("restricted")
|
||||||
static void loadLibraries() {
|
static void loadLibraries() {
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
java.security.AccessController.doPrivileged(
|
System.loadLibrary("awt");
|
||||||
new java.security.PrivilegedAction<Void>() {
|
|
||||||
public Void run() {
|
|
||||||
System.loadLibrary("awt");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,6 @@ import java.lang.reflect.InvocationHandler;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.security.AccessControlContext;
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
|
|
||||||
import sun.reflect.misc.MethodUtil;
|
import sun.reflect.misc.MethodUtil;
|
||||||
import sun.reflect.misc.ReflectUtil;
|
import sun.reflect.misc.ReflectUtil;
|
||||||
@ -281,8 +278,6 @@ public class EventHandler implements InvocationHandler {
|
|||||||
private String action;
|
private String action;
|
||||||
private final String eventPropertyName;
|
private final String eventPropertyName;
|
||||||
private final String listenerMethodName;
|
private final String listenerMethodName;
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private final AccessControlContext acc = AccessController.getContext();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@code EventHandler} object;
|
* Creates a new {@code EventHandler} object;
|
||||||
@ -421,20 +416,7 @@ public class EventHandler implements InvocationHandler {
|
|||||||
*
|
*
|
||||||
* @see EventHandler
|
* @see EventHandler
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public Object invoke(final Object proxy, final Method method, final Object[] arguments) {
|
public Object invoke(final Object proxy, final Method method, final Object[] arguments) {
|
||||||
AccessControlContext acc = this.acc;
|
|
||||||
if ((acc == null) && (System.getSecurityManager() != null)) {
|
|
||||||
throw new SecurityException("AccessControlContext is not set");
|
|
||||||
}
|
|
||||||
return AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
|
||||||
public Object run() {
|
|
||||||
return invokeInternal(proxy, method, arguments);
|
|
||||||
}
|
|
||||||
}, acc);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object invokeInternal(Object proxy, Method method, Object[] arguments) {
|
|
||||||
String methodName = method.getName();
|
String methodName = method.getName();
|
||||||
if (method.getDeclaringClass() == Object.class) {
|
if (method.getDeclaringClass() == Object.class) {
|
||||||
// Handle the Object public methods.
|
// Handle the Object public methods.
|
||||||
@ -689,7 +671,7 @@ public class EventHandler implements InvocationHandler {
|
|||||||
* @see EventHandler
|
* @see EventHandler
|
||||||
* @see Proxy#newProxyInstance
|
* @see Proxy#newProxyInstance
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T create(Class<T> listenerInterface,
|
public static <T> T create(Class<T> listenerInterface,
|
||||||
Object target, String action,
|
Object target, String action,
|
||||||
String eventPropertyName,
|
String eventPropertyName,
|
||||||
@ -705,12 +687,7 @@ public class EventHandler implements InvocationHandler {
|
|||||||
}
|
}
|
||||||
final ClassLoader loader = getClassLoader(listenerInterface);
|
final ClassLoader loader = getClassLoader(listenerInterface);
|
||||||
final Class<?>[] interfaces = {listenerInterface};
|
final Class<?>[] interfaces = {listenerInterface};
|
||||||
return AccessController.doPrivileged(new PrivilegedAction<T>() {
|
return (T) Proxy.newProxyInstance(loader, interfaces, handler);
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public T run() {
|
|
||||||
return (T) Proxy.newProxyInstance(loader, interfaces, handler);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ClassLoader getClassLoader(Class<?> type) {
|
private static ClassLoader getClassLoader(Class<?> type) {
|
||||||
|
@ -41,9 +41,6 @@ import java.lang.reflect.Method;
|
|||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
@ -1319,28 +1316,22 @@ static final class sun_swing_PrintColorUIResource_PersistenceDelegate extends Pe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
static Object getPrivateFieldValue(Object instance, String name) {
|
static Object getPrivateFieldValue(Object instance, String name) {
|
||||||
Field field = fields.get(name);
|
Field field = fields.get(name);
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
int index = name.lastIndexOf('.');
|
int index = name.lastIndexOf('.');
|
||||||
final String className = name.substring(0, index);
|
final String className = name.substring(0, index);
|
||||||
final String fieldName = name.substring(1 + index);
|
final String fieldName = name.substring(1 + index);
|
||||||
field = AccessController.doPrivileged(new PrivilegedAction<Field>() {
|
try {
|
||||||
public Field run() {
|
field = Class.forName(className).getDeclaredField(fieldName);
|
||||||
try {
|
field.setAccessible(true);
|
||||||
Field field = Class.forName(className).getDeclaredField(fieldName);
|
}
|
||||||
field.setAccessible(true);
|
catch (ClassNotFoundException exception) {
|
||||||
return field;
|
throw new IllegalStateException("Could not find class", exception);
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException exception) {
|
catch (NoSuchFieldException exception) {
|
||||||
throw new IllegalStateException("Could not find class", exception);
|
throw new IllegalStateException("Could not find field", exception);
|
||||||
}
|
}
|
||||||
catch (NoSuchFieldException exception) {
|
|
||||||
throw new IllegalStateException("Could not find field", exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fields.put(name, field);
|
fields.put(name, field);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -29,8 +29,6 @@ import java.awt.Image;
|
|||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.image.ImageProducer;
|
import java.awt.image.ImageProducer;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a support class to make it easier for people to provide
|
* This is a support class to make it easier for people to provide
|
||||||
@ -154,10 +152,8 @@ public class SimpleBeanInfo implements BeanInfo {
|
|||||||
* @return an image object. May be null if the load failed.
|
* @return an image object. May be null if the load failed.
|
||||||
* @see java.beans.SimpleBeanInfo#loadImage(String)
|
* @see java.beans.SimpleBeanInfo#loadImage(String)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private Image loadStandardImage(final String resourceName) {
|
private Image loadStandardImage(final String resourceName) {
|
||||||
return AccessController.doPrivileged(
|
return loadImage(resourceName);
|
||||||
(PrivilegedAction<Image>) () -> loadImage(resourceName));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,10 +29,6 @@ import java.lang.reflect.Array;
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.security.AccessControlContext;
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedActionException;
|
|
||||||
import java.security.PrivilegedExceptionAction;
|
|
||||||
|
|
||||||
import com.sun.beans.finder.ClassFinder;
|
import com.sun.beans.finder.ClassFinder;
|
||||||
import com.sun.beans.finder.ConstructorFinder;
|
import com.sun.beans.finder.ConstructorFinder;
|
||||||
@ -69,8 +65,6 @@ public class Statement {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private final AccessControlContext acc = AccessController.getContext();
|
|
||||||
private final Object target;
|
private final Object target;
|
||||||
private final String methodName;
|
private final String methodName;
|
||||||
private final Object[] arguments;
|
private final Object[] arguments;
|
||||||
@ -174,28 +168,7 @@ public class Statement {
|
|||||||
invoke();
|
invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
Object invoke() throws Exception {
|
Object invoke() throws Exception {
|
||||||
AccessControlContext acc = this.acc;
|
|
||||||
if ((acc == null) && (System.getSecurityManager() != null)) {
|
|
||||||
throw new SecurityException("AccessControlContext is not set");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return AccessController.doPrivileged(
|
|
||||||
new PrivilegedExceptionAction<Object>() {
|
|
||||||
public Object run() throws Exception {
|
|
||||||
return invokeInternal();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
acc
|
|
||||||
);
|
|
||||||
}
|
|
||||||
catch (PrivilegedActionException exception) {
|
|
||||||
throw exception.getException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object invokeInternal() throws Exception {
|
|
||||||
Object target = getTarget();
|
Object target = getTarget();
|
||||||
String methodName = getMethodName();
|
String methodName = getMethodName();
|
||||||
|
|
||||||
|
@ -29,9 +29,6 @@ import com.sun.beans.decoder.DocumentHandler;
|
|||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.AccessControlContext;
|
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
|
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.helpers.DefaultHandler;
|
import org.xml.sax.helpers.DefaultHandler;
|
||||||
@ -64,8 +61,6 @@ import org.xml.sax.helpers.DefaultHandler;
|
|||||||
* @author Philip Milne
|
* @author Philip Milne
|
||||||
*/
|
*/
|
||||||
public class XMLDecoder implements AutoCloseable {
|
public class XMLDecoder implements AutoCloseable {
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private final AccessControlContext acc = AccessController.getContext();
|
|
||||||
private final DocumentHandler handler = new DocumentHandler();
|
private final DocumentHandler handler = new DocumentHandler();
|
||||||
private final InputSource input;
|
private final InputSource input;
|
||||||
private Object owner;
|
private Object owner;
|
||||||
@ -189,21 +184,12 @@ public class XMLDecoder implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
private boolean parsingComplete() {
|
private boolean parsingComplete() {
|
||||||
if (this.input == null) {
|
if (this.input == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.array == null) {
|
if (this.array == null) {
|
||||||
if ((this.acc == null) && (null != System.getSecurityManager())) {
|
XMLDecoder.this.handler.parse(XMLDecoder.this.input);
|
||||||
throw new SecurityException("AccessControlContext is not set");
|
|
||||||
}
|
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
|
||||||
public Void run() {
|
|
||||||
XMLDecoder.this.handler.parse(XMLDecoder.this.input);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}, this.acc);
|
|
||||||
this.array = this.handler.getObjects();
|
this.array = this.handler.getObjects();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user