8344795: Remove uses of AccessControlContext in java.desktop module
Reviewed-by: azvegint
This commit is contained in:
parent
5154b71637
commit
4b1653056d
@ -38,9 +38,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
@ -62,8 +59,6 @@ import jdk.internal.access.SharedSecrets;
|
||||
* @see ElementHandler
|
||||
*/
|
||||
public final class DocumentHandler extends DefaultHandler {
|
||||
@SuppressWarnings("removal")
|
||||
private final AccessControlContext acc = AccessController.getContext();
|
||||
private final Map<String, Class<? extends ElementHandler>> handlers = new HashMap<>();
|
||||
private final Map<String, Object> environment = new HashMap<>();
|
||||
private final List<Object> objects = new ArrayList<>();
|
||||
@ -367,14 +362,7 @@ public final class DocumentHandler extends DefaultHandler {
|
||||
*
|
||||
* @param input the input source to parse
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public void parse(final InputSource input) {
|
||||
if ((this.acc == null) && (null != System.getSecurityManager())) {
|
||||
throw new SecurityException("AccessControlContext is not set");
|
||||
}
|
||||
AccessControlContext stack = AccessController.getContext();
|
||||
SharedSecrets.getJavaSecurityAccess().doIntersectionPrivilege(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
try {
|
||||
SAXParserFactory.newInstance().newSAXParser().parse(input, DocumentHandler.this);
|
||||
}
|
||||
@ -388,9 +376,6 @@ public final class DocumentHandler extends DefaultHandler {
|
||||
}
|
||||
handleException(exception);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, stack, this.acc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,8 +39,6 @@ import java.awt.event.WindowEvent;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.LightweightPeer;
|
||||
import java.io.Serial;
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.AccessController;
|
||||
import java.util.EventObject;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
@ -112,24 +110,6 @@ public abstract class AWTEvent extends EventObject {
|
||||
*/
|
||||
protected boolean consumed = false;
|
||||
|
||||
/*
|
||||
* The event's AccessControlContext.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private transient volatile AccessControlContext acc =
|
||||
AccessController.getContext();
|
||||
|
||||
/*
|
||||
* Returns the acc this event was constructed with.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
final AccessControlContext getAccessControlContext() {
|
||||
if (acc == null) {
|
||||
throw new SecurityException("AWTEvent is missing AccessControlContext");
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
transient boolean focusManagerIsDispatching = false;
|
||||
transient boolean isPosted;
|
||||
|
||||
@ -281,11 +261,6 @@ public abstract class AWTEvent extends EventObject {
|
||||
return ev.isSystemGenerated;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public AccessControlContext getAccessControlContext(AWTEvent ev) {
|
||||
return ev.getAccessControlContext();
|
||||
}
|
||||
|
||||
public byte[] getBData(AWTEvent ev) {
|
||||
return ev.bdata;
|
||||
}
|
||||
|
@ -69,8 +69,6 @@ import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.AccessController;
|
||||
import java.util.Collections;
|
||||
import java.util.EventListener;
|
||||
import java.util.HashSet;
|
||||
@ -501,13 +499,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
static final Object LOCK = new AWTTreeLock();
|
||||
static class AWTTreeLock {}
|
||||
|
||||
/*
|
||||
* The component's AccessControlContext.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private transient volatile AccessControlContext acc =
|
||||
AccessController.getContext();
|
||||
|
||||
/**
|
||||
* Minimum size.
|
||||
* (This field perhaps should have been transient).
|
||||
@ -706,17 +697,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
return objectLock;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the acc this component was constructed with.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
final AccessControlContext getAccessControlContext() {
|
||||
if (acc == null) {
|
||||
throw new SecurityException("Component is missing AccessControlContext");
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the component is packed or not;
|
||||
*/
|
||||
@ -972,11 +952,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
comp.processEvent(e);
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public AccessControlContext getAccessControlContext(Component comp) {
|
||||
return comp.getAccessControlContext();
|
||||
}
|
||||
|
||||
public void revalidateSynchronously(Component comp) {
|
||||
comp.revalidateSynchronously();
|
||||
}
|
||||
@ -8967,15 +8942,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
* @throws IOException if an I/O error occurs
|
||||
* @see #writeObject(ObjectOutputStream)
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
@Serial
|
||||
private void readObject(ObjectInputStream s)
|
||||
throws ClassNotFoundException, IOException
|
||||
{
|
||||
objectLock = new Object();
|
||||
|
||||
acc = AccessController.getContext();
|
||||
|
||||
s.defaultReadObject();
|
||||
|
||||
appContext = AppContext.getAppContext();
|
||||
|
@ -30,8 +30,6 @@ import java.awt.peer.MenuComponentPeer;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serial;
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.AccessController;
|
||||
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.accessibility.AccessibleComponent;
|
||||
@ -103,25 +101,6 @@ public abstract class MenuComponent implements java.io.Serializable {
|
||||
*/
|
||||
volatile boolean newEventsOnly;
|
||||
|
||||
/*
|
||||
* The menu's AccessControlContext.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private transient volatile AccessControlContext acc =
|
||||
AccessController.getContext();
|
||||
|
||||
/*
|
||||
* Returns the acc this menu component was constructed with.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
final AccessControlContext getAccessControlContext() {
|
||||
if (acc == null) {
|
||||
throw new SecurityException(
|
||||
"MenuComponent is missing AccessControlContext");
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal constants for serialization.
|
||||
*/
|
||||
@ -442,15 +421,12 @@ public abstract class MenuComponent implements java.io.Serializable {
|
||||
*
|
||||
* @see java.awt.GraphicsEnvironment#isHeadless
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
@Serial
|
||||
private void readObject(ObjectInputStream s)
|
||||
throws ClassNotFoundException, IOException, HeadlessException
|
||||
{
|
||||
GraphicsEnvironment.checkHeadless();
|
||||
|
||||
acc = AccessController.getContext();
|
||||
|
||||
s.defaultReadObject();
|
||||
|
||||
appContext = AppContext.getAppContext();
|
||||
|
@ -32,8 +32,6 @@ import sun.awt.SunToolkit;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.HeadlessToolkit;
|
||||
import java.util.EventObject;
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.AccessController;
|
||||
|
||||
/**
|
||||
* A {@code TrayIcon} object represents a tray icon that can be
|
||||
@ -102,26 +100,6 @@ public class TrayIcon {
|
||||
transient MouseMotionListener mouseMotionListener;
|
||||
transient ActionListener actionListener;
|
||||
|
||||
/*
|
||||
* The tray icon's AccessControlContext.
|
||||
*
|
||||
* Unlike the acc in Component, this field is made final
|
||||
* because TrayIcon is not serializable.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private final AccessControlContext acc = AccessController.getContext();
|
||||
|
||||
/*
|
||||
* Returns the acc this tray icon was constructed with.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
final AccessControlContext getAccessControlContext() {
|
||||
if (acc == null) {
|
||||
throw new SecurityException("TrayIcon is missing AccessControlContext");
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
static {
|
||||
Toolkit.loadLibraries();
|
||||
if (!GraphicsEnvironment.isHeadless()) {
|
||||
|
@ -42,16 +42,6 @@ import sun.awt.AppContext;
|
||||
import sun.swing.*;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import java.security.AccessControlContext;
|
||||
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import jdk.internal.access.JavaSecurityAccess;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
/**
|
||||
* This class is used to handle the transfer of a <code>Transferable</code>
|
||||
* to and from Swing components. The <code>Transferable</code> is used to
|
||||
@ -1701,40 +1691,7 @@ public class TransferHandler implements Serializable {
|
||||
&& ((JComponent)sender).getTransferHandler() == null);
|
||||
}
|
||||
|
||||
private static final JavaSecurityAccess javaSecurityAccess =
|
||||
SharedSecrets.getJavaSecurityAccess();
|
||||
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
final Object src = e.getSource();
|
||||
|
||||
final PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
actionPerformedImpl(e);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
final AccessControlContext stack = AccessController.getContext();
|
||||
@SuppressWarnings("removal")
|
||||
final AccessControlContext srcAcc = AWTAccessor.getComponentAccessor().getAccessControlContext((Component)src);
|
||||
@SuppressWarnings("removal")
|
||||
final AccessControlContext eventAcc = AWTAccessor.getAWTEventAccessor().getAccessControlContext(e);
|
||||
|
||||
if (srcAcc == null) {
|
||||
javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc);
|
||||
} else {
|
||||
javaSecurityAccess.doIntersectionPrivilege(
|
||||
new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
javaSecurityAccess.doIntersectionPrivilege(action, eventAcc);
|
||||
return null;
|
||||
}
|
||||
}, stack, srcAcc);
|
||||
}
|
||||
}
|
||||
|
||||
private void actionPerformedImpl(ActionEvent e) {
|
||||
Object src = e.getSource();
|
||||
if (src instanceof JComponent) {
|
||||
JComponent c = (JComponent) src;
|
||||
|
@ -49,8 +49,6 @@ import java.awt.Color;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Dimension;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.security.AccessController;
|
||||
import java.security.AccessControlContext;
|
||||
|
||||
import sun.reflect.misc.MethodUtil;
|
||||
import sun.reflect.misc.ReflectUtil;
|
||||
@ -1062,8 +1060,6 @@ public class UIDefaults extends Hashtable<Object,Object>
|
||||
* @since 1.3
|
||||
*/
|
||||
public static class ProxyLazyValue implements LazyValue {
|
||||
@SuppressWarnings("removal")
|
||||
private AccessControlContext acc;
|
||||
private String className;
|
||||
private String methodName;
|
||||
private Object[] args;
|
||||
@ -1117,9 +1113,7 @@ public class UIDefaults extends Hashtable<Object,Object>
|
||||
* @param o an array of <code>Objects</code> to be passed as
|
||||
* parameters to the static method in class c
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public ProxyLazyValue(String c, String m, Object[] o) {
|
||||
acc = AccessController.getContext();
|
||||
className = c;
|
||||
methodName = m;
|
||||
if (o != null) {
|
||||
|
@ -44,7 +44,6 @@ import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.MenuComponentPeer;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.AccessControlContext;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ResourceBundle;
|
||||
@ -244,13 +243,6 @@ public final class AWTAccessor {
|
||||
*/
|
||||
void processEvent(Component comp, AWTEvent e);
|
||||
|
||||
|
||||
/*
|
||||
* Returns the acc this component was constructed with.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
AccessControlContext getAccessControlContext(Component comp);
|
||||
|
||||
/**
|
||||
* Revalidates the component synchronously.
|
||||
*/
|
||||
@ -353,12 +345,6 @@ public final class AWTAccessor {
|
||||
*/
|
||||
boolean isSystemGenerated(AWTEvent ev);
|
||||
|
||||
/**
|
||||
* Returns the acc this event was constructed with.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
AccessControlContext getAccessControlContext(AWTEvent ev);
|
||||
|
||||
/**
|
||||
* Returns binary data associated with this event;
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user