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