From 027607968b3d55b498e9f2d7a4023b8ae2d47b5b Mon Sep 17 00:00:00 2001 From: Phil Race Date: Mon, 25 Nov 2024 22:16:07 +0000 Subject: [PATCH] 8344667: Remove most uses of AWT Permissions from the desktop module Reviewed-by: azvegint, kizune --- .../classes/sun/awt/CGraphicsDevice.java | 20 ------- .../share/classes/java/applet/Applet.java | 7 --- .../share/classes/java/awt/Dialog.java | 20 ------- .../java/awt/KeyboardFocusManager.java | 54 ------------------- .../share/classes/java/awt/MouseInfo.java | 7 --- .../share/classes/java/awt/Robot.java | 22 -------- .../share/classes/java/awt/SystemTray.java | 10 ---- .../share/classes/java/awt/Toolkit.java | 26 --------- .../share/classes/java/awt/TrayIcon.java | 3 +- .../share/classes/java/awt/Window.java | 14 ----- .../classes/javax/swing/JInternalFrame.java | 6 +-- .../classes/javax/swing/SwingUtilities.java | 8 --- .../basic/BasicInternalFrameTitlePane.java | 7 +-- .../share/classes/sun/awt/AWTPermissions.java | 24 --------- .../share/classes/sun/awt/SunToolkit.java | 15 +----- .../sun/awt/image/BufImgSurfaceData.java | 5 -- .../classes/sun/java2d/NullSurfaceData.java | 9 ---- .../classes/sun/java2d/SunGraphics2D.java | 1 - .../share/classes/sun/java2d/SurfaceData.java | 19 ------- .../classes/sun/awt/X11GraphicsDevice.java | 20 +------ .../classes/sun/awt/Win32GraphicsDevice.java | 21 +------- test/jdk/lib/client/ExtendedRobot.java | 6 --- 22 files changed, 6 insertions(+), 318 deletions(-) diff --git a/src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java b/src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java index 5a865f92cb6..bdb36a90899 100644 --- a/src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java +++ b/src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java @@ -25,7 +25,6 @@ package sun.awt; -import java.awt.AWTPermission; import java.awt.DisplayMode; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; @@ -62,8 +61,6 @@ public final class CGraphicsDevice extends GraphicsDevice private static boolean oglPipelineEnabled = false; - private static AWTPermission fullScreenExclusivePermission; - // Save/restore DisplayMode for the Full Screen mode private DisplayMode originalMode; private DisplayMode initialMode; @@ -260,23 +257,6 @@ public final class CGraphicsDevice extends GraphicsDevice */ @Override public boolean isFullScreenSupported() { - return isFSExclusiveModeAllowed(); - } - - private static boolean isFSExclusiveModeAllowed() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - if (fullScreenExclusivePermission == null) { - fullScreenExclusivePermission = - new AWTPermission("fullScreenExclusive"); - } - try { - security.checkPermission(fullScreenExclusivePermission); - } catch (SecurityException e) { - return false; - } - } return true; } diff --git a/src/java.desktop/share/classes/java/applet/Applet.java b/src/java.desktop/share/classes/java/applet/Applet.java index c68605a9b64..2228ea419d4 100644 --- a/src/java.desktop/share/classes/java/applet/Applet.java +++ b/src/java.desktop/share/classes/java/applet/Applet.java @@ -25,7 +25,6 @@ package java.applet; -import java.awt.AWTPermission; import java.awt.Dimension; import java.awt.GraphicsEnvironment; import java.awt.HeadlessException; @@ -127,12 +126,6 @@ public class Applet extends Panel { * @param stub the new stub */ public final void setStub(AppletStub stub) { - if (this.stub != null) { - SecurityManager s = System.getSecurityManager(); - if (s != null) { - s.checkPermission(new AWTPermission("setAppletStub")); - } - } this.stub = stub; } diff --git a/src/java.desktop/share/classes/java/awt/Dialog.java b/src/java.desktop/share/classes/java/awt/Dialog.java index 03449200478..95d32161b36 100644 --- a/src/java.desktop/share/classes/java/awt/Dialog.java +++ b/src/java.desktop/share/classes/java/awt/Dialog.java @@ -33,7 +33,6 @@ import java.awt.peer.DialogPeer; import java.io.IOException; import java.io.ObjectInputStream; import java.io.Serial; -import java.security.AccessControlException; import java.util.Iterator; import java.util.concurrent.atomic.AtomicLong; @@ -42,7 +41,6 @@ import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleState; import javax.accessibility.AccessibleStateSet; -import sun.awt.AWTPermissions; import sun.awt.AppContext; import sun.awt.SunToolkit; import sun.awt.util.IdentityArrayList; @@ -844,8 +842,6 @@ public class Dialog extends Window { return; } - checkModalityPermission(type); - modalityType = type; modal = (modalityType != ModalityType.MODELESS); } @@ -1561,16 +1557,6 @@ public class Dialog extends Window { } } - private void checkModalityPermission(ModalityType mt) { - if (mt == ModalityType.TOOLKIT_MODAL) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(AWTPermissions.TOOLKIT_MODALITY_PERMISSION); - } - } - } - /** * Reads serializable fields from stream. * @@ -1592,12 +1578,6 @@ public class Dialog extends Window { ModalityType localModalityType = (ModalityType)fields.get("modalityType", null); - try { - checkModalityPermission(localModalityType); - } catch (@SuppressWarnings("removal") AccessControlException ace) { - localModalityType = DEFAULT_MODALITY_TYPE; - } - // in 1.5 or earlier modalityType was absent, so use "modal" instead if (localModalityType == null) { this.modal = fields.get("modal", false); diff --git a/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java b/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java index eb623213a77..ede4d385a80 100644 --- a/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java +++ b/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java @@ -226,7 +226,6 @@ public abstract class KeyboardFocusManager * @see DefaultKeyboardFocusManager */ public static void setCurrentKeyboardFocusManager(KeyboardFocusManager newManager) { - checkReplaceKFMPermission(); KeyboardFocusManager oldManager = null; @@ -354,12 +353,6 @@ public abstract class KeyboardFocusManager */ private static java.util.Map> mostRecentFocusOwners = new WeakHashMap<>(); - /** - * We cache the permission used to verify that the calling thread is - * permitted to access the global focus state. - */ - private static AWTPermission replaceKeyboardFocusManagerPermission; - /* * SequencedEvent which is currently dispatched in AppContext. */ @@ -473,7 +466,6 @@ public abstract class KeyboardFocusManager */ protected Component getGlobalFocusOwner() { synchronized (KeyboardFocusManager.class) { - checkKFMSecurity(); return focusOwner; } } @@ -506,7 +498,6 @@ public abstract class KeyboardFocusManager if (focusOwner == null || focusOwner.isFocusable()) { synchronized (KeyboardFocusManager.class) { - checkKFMSecurity(); oldFocusOwner = getFocusOwner(); @@ -584,7 +575,6 @@ public abstract class KeyboardFocusManager * @see java.awt.event.FocusEvent#FOCUS_LOST */ public void clearGlobalFocusOwner() { - checkReplaceKFMPermission(); if (!GraphicsEnvironment.isHeadless()) { // Toolkit must be fully initialized, otherwise // _clearGlobalFocusOwner will crash or throw an exception @@ -660,7 +650,6 @@ public abstract class KeyboardFocusManager */ protected Component getGlobalPermanentFocusOwner() { synchronized (KeyboardFocusManager.class) { - checkKFMSecurity(); return permanentFocusOwner; } } @@ -694,7 +683,6 @@ public abstract class KeyboardFocusManager if (permanentFocusOwner == null || permanentFocusOwner.isFocusable()) { synchronized (KeyboardFocusManager.class) { - checkKFMSecurity(); oldPermanentFocusOwner = getPermanentFocusOwner(); @@ -755,7 +743,6 @@ public abstract class KeyboardFocusManager */ protected Window getGlobalFocusedWindow() { synchronized (KeyboardFocusManager.class) { - checkKFMSecurity(); return focusedWindow; } } @@ -785,7 +772,6 @@ public abstract class KeyboardFocusManager if (focusedWindow == null || focusedWindow.isFocusableWindow()) { synchronized (KeyboardFocusManager.class) { - checkKFMSecurity(); oldFocusedWindow = getFocusedWindow(); @@ -847,7 +833,6 @@ public abstract class KeyboardFocusManager */ protected Window getGlobalActiveWindow() { synchronized (KeyboardFocusManager.class) { - checkKFMSecurity(); return activeWindow; } } @@ -875,7 +860,6 @@ public abstract class KeyboardFocusManager protected void setGlobalActiveWindow(Window activeWindow) { Window oldActiveWindow; synchronized (KeyboardFocusManager.class) { - checkKFMSecurity(); oldActiveWindow = getActiveWindow(); if (focusLog.isLoggable(PlatformLogger.Level.FINER)) { @@ -1152,7 +1136,6 @@ public abstract class KeyboardFocusManager */ protected Container getGlobalCurrentFocusCycleRoot() { synchronized (KeyboardFocusManager.class) { - checkKFMSecurity(); return currentFocusCycleRoot; } } @@ -1172,7 +1155,6 @@ public abstract class KeyboardFocusManager * @see #getGlobalCurrentFocusCycleRoot */ public void setGlobalCurrentFocusCycleRoot(Container newFocusCycleRoot) { - checkReplaceKFMPermission(); Container oldFocusCycleRoot; @@ -2976,40 +2958,4 @@ public abstract class KeyboardFocusManager : null; } } - - private static void checkReplaceKFMPermission() - throws SecurityException - { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - if (replaceKeyboardFocusManagerPermission == null) { - replaceKeyboardFocusManagerPermission = - new AWTPermission("replaceKeyboardFocusManager"); - } - security. - checkPermission(replaceKeyboardFocusManagerPermission); - } - } - - // Checks if this KeyboardFocusManager instance is the current KFM, - // or otherwise checks if the calling thread has "replaceKeyboardFocusManager" - // permission. Here's the reasoning to do so: - // - // A system KFM instance (which is the current KFM by default) may have no - // "replaceKFM" permission when a client code is on the call stack beneath, - // but still it should be able to execute the methods protected by this check - // due to the system KFM is trusted (and so it does like "privileged"). - // - // If this KFM instance is not the current KFM but the client code has all - // permissions we can't throw SecurityException because it would contradict - // the security concepts. In this case the trusted client code is responsible - // for calling the secured methods from KFM instance which is not current. - private void checkKFMSecurity() - throws SecurityException - { - if (this != getCurrentKeyboardFocusManager()) { - checkReplaceKFMPermission(); - } - } } diff --git a/src/java.desktop/share/classes/java/awt/MouseInfo.java b/src/java.desktop/share/classes/java/awt/MouseInfo.java index 3081e376cdc..6b913adf06e 100644 --- a/src/java.desktop/share/classes/java/awt/MouseInfo.java +++ b/src/java.desktop/share/classes/java/awt/MouseInfo.java @@ -25,7 +25,6 @@ package java.awt; -import sun.awt.AWTPermissions; import sun.awt.ComponentFactory; /** @@ -66,12 +65,6 @@ public class MouseInfo { throw new HeadlessException(); } - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(AWTPermissions.WATCH_MOUSE_PERMISSION); - } - Toolkit toolkit = Toolkit.getDefaultToolkit(); Point point = new Point(0, 0); int deviceNum = 0; diff --git a/src/java.desktop/share/classes/java/awt/Robot.java b/src/java.desktop/share/classes/java/awt/Robot.java index 95ea477beb3..8b7506f5f2d 100644 --- a/src/java.desktop/share/classes/java/awt/Robot.java +++ b/src/java.desktop/share/classes/java/awt/Robot.java @@ -37,7 +37,6 @@ import java.awt.image.Raster; import java.awt.image.WritableRaster; import java.awt.peer.RobotPeer; -import sun.awt.AWTPermissions; import sun.awt.ComponentFactory; import sun.awt.SunToolkit; import sun.awt.image.SunWritableRaster; @@ -163,7 +162,6 @@ public class Robot { } private void init(GraphicsDevice screen) throws AWTException { - checkRobotAllowed(); Toolkit toolkit = Toolkit.getDefaultToolkit(); if (toolkit instanceof ComponentFactory) { peer = ((ComponentFactory)toolkit).createRobot(screen); @@ -193,15 +191,6 @@ public class Robot { LEGAL_BUTTON_MASK = tmpMask; } - /* determine if the security policy allows Robot's to be created */ - private static void checkRobotAllowed() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(AWTPermissions.CREATE_ROBOT_PERMISSION); - } - } - /** * Check for headless state and throw {@code AWTException} if headless. */ @@ -437,7 +426,6 @@ public class Robot { * @return Color of the pixel */ public synchronized Color getPixelColor(int x, int y) { - checkScreenCaptureAllowed(); Point point = peer.useAbsoluteCoordinates() ? toDeviceSpaceAbs(x, y) : toDeviceSpace(x, y); return new Color(peer.getRGBPixel(point.x, point.y)); @@ -518,8 +506,6 @@ public class Robot { private synchronized BufferedImage[] createCompatibleImage(Rectangle screenRect, boolean isHiDPI) { - checkScreenCaptureAllowed(); - checkValidRect(screenRect); BufferedImage lowResolutionImage; @@ -635,14 +621,6 @@ public class Robot { } } - private static void checkScreenCaptureAllowed() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(AWTPermissions.READ_DISPLAY_PIXELS_PERMISSION); - } - } - /* * Called after an event is generated */ diff --git a/src/java.desktop/share/classes/java/awt/SystemTray.java b/src/java.desktop/share/classes/java/awt/SystemTray.java index 990985e7b44..abf8c97abda 100644 --- a/src/java.desktop/share/classes/java/awt/SystemTray.java +++ b/src/java.desktop/share/classes/java/awt/SystemTray.java @@ -32,7 +32,6 @@ import java.beans.PropertyChangeSupport; import java.util.Vector; import sun.awt.AWTAccessor; -import sun.awt.AWTPermissions; import sun.awt.AppContext; import sun.awt.HeadlessToolkit; import sun.awt.SunToolkit; @@ -160,7 +159,6 @@ public class SystemTray { * @see #isSupported */ public static SystemTray getSystemTray() { - checkSystemTrayAllowed(); if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } @@ -494,14 +492,6 @@ public class SystemTray { } } - static void checkSystemTrayAllowed() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(AWTPermissions.ACCESS_SYSTEM_TRAY_PERMISSION); - } - } - private static void initializeSystemTrayIfNeeded() { synchronized (SystemTray.class) { if (systemTray == null) { diff --git a/src/java.desktop/share/classes/java/awt/Toolkit.java b/src/java.desktop/share/classes/java/awt/Toolkit.java index d181fb6f536..3d9d781de33 100644 --- a/src/java.desktop/share/classes/java/awt/Toolkit.java +++ b/src/java.desktop/share/classes/java/awt/Toolkit.java @@ -72,7 +72,6 @@ import java.util.stream.Collectors; import javax.accessibility.AccessibilityProvider; import sun.awt.AWTAccessor; -import sun.awt.AWTPermissions; import sun.awt.AppContext; import sun.awt.HeadlessToolkit; import sun.awt.PeerEvent; @@ -1360,11 +1359,6 @@ public abstract class Toolkit { * @return the {@code EventQueue} object */ public final EventQueue getSystemEventQueue() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(AWTPermissions.CHECK_AWT_EVENTQUEUE_PERMISSION); - } return getSystemEventQueueImpl(); } @@ -1690,11 +1684,6 @@ public abstract class Toolkit { if (localL == null) { return; } - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION); - } synchronized (this) { SelectiveAWTEventListener selectiveListener = listener2SelectiveListener.get(localL); @@ -1750,11 +1739,6 @@ public abstract class Toolkit { if (listener == null) { return; } - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION); - } synchronized (this) { SelectiveAWTEventListener selectiveListener = @@ -1807,11 +1791,6 @@ public abstract class Toolkit { * @since 1.4 */ public AWTEventListener[] getAWTEventListeners() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION); - } synchronized (this) { EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class); @@ -1851,11 +1830,6 @@ public abstract class Toolkit { * @since 1.4 */ public AWTEventListener[] getAWTEventListeners(long eventMask) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(AWTPermissions.ALL_AWT_EVENTS_PERMISSION); - } synchronized (this) { EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class); diff --git a/src/java.desktop/share/classes/java/awt/TrayIcon.java b/src/java.desktop/share/classes/java/awt/TrayIcon.java index 3323818eeb1..b53174ef05e 100644 --- a/src/java.desktop/share/classes/java/awt/TrayIcon.java +++ b/src/java.desktop/share/classes/java/awt/TrayIcon.java @@ -118,9 +118,8 @@ public class TrayIcon { } private TrayIcon() - throws UnsupportedOperationException, HeadlessException, SecurityException + throws UnsupportedOperationException, HeadlessException { - SystemTray.checkSystemTrayAllowed(); if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } diff --git a/src/java.desktop/share/classes/java/awt/Window.java b/src/java.desktop/share/classes/java/awt/Window.java index ac1a2e41dc1..9d12b0cd3c0 100644 --- a/src/java.desktop/share/classes/java/awt/Window.java +++ b/src/java.desktop/share/classes/java/awt/Window.java @@ -64,7 +64,6 @@ import javax.accessibility.AccessibleState; import javax.accessibility.AccessibleStateSet; import sun.awt.AWTAccessor; -import sun.awt.AWTPermissions; import sun.awt.AppContext; import sun.awt.DebugSettings; import sun.awt.SunToolkit; @@ -1627,13 +1626,6 @@ public class Window extends Container implements Accessible { if (modalExclusionType == exclusionType) { return; } - if (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(AWTPermissions.TOOLKIT_MODALITY_PERMISSION); - } - } modalExclusionType = exclusionType; // if we want on-fly changes, we need to uncomment the lines below @@ -2169,12 +2161,6 @@ public class Window extends Container implements Accessible { * @since 1.5 */ public final void setAlwaysOnTop(boolean alwaysOnTop) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPermission(AWTPermissions.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION); - } - boolean oldAlwaysOnTop; synchronized(this) { oldAlwaysOnTop = this.alwaysOnTop; diff --git a/src/java.desktop/share/classes/javax/swing/JInternalFrame.java b/src/java.desktop/share/classes/javax/swing/JInternalFrame.java index d6b6958e084..e7d0eec76fb 100644 --- a/src/java.desktop/share/classes/javax/swing/JInternalFrame.java +++ b/src/java.desktop/share/classes/javax/swing/JInternalFrame.java @@ -1096,12 +1096,8 @@ public class JInternalFrame extends JComponent implements fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ACTIVATED); else { fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED); - try { - java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent( + java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent( new sun.awt.UngrabEvent(this)); - } catch (SecurityException e) { - this.dispatchEvent(new sun.awt.UngrabEvent(this)); - } } repaint(); } diff --git a/src/java.desktop/share/classes/javax/swing/SwingUtilities.java b/src/java.desktop/share/classes/javax/swing/SwingUtilities.java index 8d944187418..f2cecb3d761 100644 --- a/src/java.desktop/share/classes/javax/swing/SwingUtilities.java +++ b/src/java.desktop/share/classes/javax/swing/SwingUtilities.java @@ -1970,14 +1970,6 @@ public class SwingUtilities implements SwingConstants public void show() { // This frame can never be shown } - public void dispose() { - try { - getToolkit().getSystemEventQueue(); - super.dispose(); - } catch (Exception e) { - // untrusted code not allowed to dispose - } - } } /** diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java index cea618a20e3..c11172d7f4e 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java @@ -528,12 +528,7 @@ public class BasicInternalFrameTitlePane extends JComponent protected void postClosingEvent(JInternalFrame frame) { InternalFrameEvent e = new InternalFrameEvent( frame, InternalFrameEvent.INTERNAL_FRAME_CLOSING); - // Try posting event, unless there's a SecurityManager. - try { - Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e); - } catch (SecurityException se) { - frame.dispatchEvent(e); - } + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e); } /** diff --git a/src/java.desktop/share/classes/sun/awt/AWTPermissions.java b/src/java.desktop/share/classes/sun/awt/AWTPermissions.java index da0dcd1c3af..9fc8ab85aab 100644 --- a/src/java.desktop/share/classes/sun/awt/AWTPermissions.java +++ b/src/java.desktop/share/classes/sun/awt/AWTPermissions.java @@ -35,28 +35,4 @@ public final class AWTPermissions { public static final AWTPermission ACCESS_CLIPBOARD_PERMISSION = new AWTPermission("accessClipboard"); - - public static final AWTPermission CHECK_AWT_EVENTQUEUE_PERMISSION = - new AWTPermission("accessEventQueue"); - - public static final AWTPermission TOOLKIT_MODALITY_PERMISSION = - new AWTPermission("toolkitModality"); - - public static final AWTPermission READ_DISPLAY_PIXELS_PERMISSION = - new AWTPermission("readDisplayPixels"); - - public static final AWTPermission CREATE_ROBOT_PERMISSION = - new AWTPermission("createRobot"); - - public static final AWTPermission WATCH_MOUSE_PERMISSION = - new AWTPermission("watchMousePointer"); - - public static final AWTPermission SET_WINDOW_ALWAYS_ON_TOP_PERMISSION = - new AWTPermission("setWindowAlwaysOnTop"); - - public static final AWTPermission ALL_AWT_EVENTS_PERMISSION = - new AWTPermission("listenToAllAWTEvents"); - - public static final AWTPermission ACCESS_SYSTEM_TRAY_PERMISSION = - new AWTPermission("accessSystemTray"); } diff --git a/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/src/java.desktop/share/classes/sun/awt/SunToolkit.java index 439167d6642..b630148f809 100644 --- a/src/java.desktop/share/classes/sun/awt/SunToolkit.java +++ b/src/java.desktop/share/classes/sun/awt/SunToolkit.java @@ -1082,22 +1082,9 @@ public abstract class SunToolkit extends Toolkit /** * Returns whether popup is allowed to be shown above the task bar. - * This is a default implementation of this method, which checks - * corresponding security permission. */ public boolean canPopupOverlapTaskBar() { - boolean result = true; - try { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(AWTPermissions.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION); - } - } catch (SecurityException se) { - // There is no permission to show popups over the task bar - result = false; - } - return result; + return true; } /** diff --git a/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java b/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java index 09d5adcb776..1a76c47692e 100644 --- a/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java +++ b/src/java.desktop/share/classes/sun/awt/image/BufImgSurfaceData.java @@ -437,11 +437,6 @@ public class BufImgSurfaceData extends SurfaceData { return new Rectangle(bufImg.getWidth(), bufImg.getHeight()); } - protected void checkCustomComposite() { - // BufferedImages always allow Custom Composite objects since - // their pixels are immediately retrievable anyway. - } - /** * Returns destination Image associated with this SurfaceData. */ diff --git a/src/java.desktop/share/classes/sun/java2d/NullSurfaceData.java b/src/java.desktop/share/classes/sun/java2d/NullSurfaceData.java index 6b93d81afb6..827170e488d 100644 --- a/src/java.desktop/share/classes/sun/java2d/NullSurfaceData.java +++ b/src/java.desktop/share/classes/sun/java2d/NullSurfaceData.java @@ -130,15 +130,6 @@ public class NullSurfaceData extends SurfaceData { return new Rectangle(); } - /** - * Performs Security Permissions checks to see if a Custom - * Composite object should be allowed access to the pixels - * of this surface. - */ - protected void checkCustomComposite() { - return; - } - /** * Performs a copyarea within this surface. Returns * false if there is no algorithm to perform the copyarea diff --git a/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java b/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java index c27e4c6ebe0..1bebf379997 100644 --- a/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java +++ b/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java @@ -974,7 +974,6 @@ public final class SunGraphics2D } else if (comp == null) { throw new IllegalArgumentException("null Composite"); } else { - surfaceData.checkCustomComposite(); newCompState = COMP_CUSTOM; newCompType = CompositeType.General; } diff --git a/src/java.desktop/share/classes/sun/java2d/SurfaceData.java b/src/java.desktop/share/classes/sun/java2d/SurfaceData.java index 3e20631f682..cd39e48d90e 100644 --- a/src/java.desktop/share/classes/sun/java2d/SurfaceData.java +++ b/src/java.desktop/share/classes/sun/java2d/SurfaceData.java @@ -1002,25 +1002,6 @@ public abstract class SurfaceData */ public abstract Rectangle getBounds(); - static java.security.Permission compPermission; - - /** - * Performs Security Permissions checks to see if a Custom - * Composite object should be allowed access to the pixels - * of this surface. - */ - protected void checkCustomComposite() { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - if (compPermission == null) { - compPermission = - new java.awt.AWTPermission("readDisplayPixels"); - } - sm.checkPermission(compPermission); - } - } - /** * Fetches private field IndexColorModel.allgrayopaque * which is true when all palette entries in the color diff --git a/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java b/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java index ca43142a098..eed50962f0d 100644 --- a/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java +++ b/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java @@ -25,7 +25,6 @@ package sun.awt; -import java.awt.AWTPermission; import java.awt.DisplayMode; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; @@ -65,7 +64,6 @@ public final class X11GraphicsDevice extends GraphicsDevice private volatile int screen; Map x11ProxyCacheMap = Collections.synchronizedMap(new HashMap<>()); - private static AWTPermission fullScreenExclusivePermission; private static Boolean xrandrExtSupported; private SunDisplayChanger topLevels = new SunDisplayChanger(); private DisplayMode origDisplayMode; @@ -335,23 +333,7 @@ public final class X11GraphicsDevice extends GraphicsDevice @Override public boolean isFullScreenSupported() { - boolean fsAvailable = isXrandrExtensionSupported(); - if (fsAvailable) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - if (fullScreenExclusivePermission == null) { - fullScreenExclusivePermission = - new AWTPermission("fullScreenExclusive"); - } - try { - security.checkPermission(fullScreenExclusivePermission); - } catch (SecurityException e) { - return false; - } - } - } - return fsAvailable; + return isXrandrExtensionSupported(); } @Override diff --git a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java index f32b25626bb..95aa5b302f0 100644 --- a/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java +++ b/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java @@ -25,7 +25,6 @@ package sun.awt; -import java.awt.AWTPermission; import java.awt.DisplayMode; import java.awt.EventQueue; import java.awt.Frame; @@ -81,7 +80,6 @@ public class Win32GraphicsDevice extends GraphicsDevice implements // pipelines which are mutually exclusive with opengl, for which // pixel formats were added in the first place protected static boolean pfDisabled; - private static AWTPermission fullScreenExclusivePermission; // the original display mode we had before entering the fullscreen // mode private DisplayMode defaultDisplayMode; @@ -349,29 +347,12 @@ public class Win32GraphicsDevice extends GraphicsDevice implements getLocalGraphicsEnvironment().getDefaultScreenDevice()); } - private static boolean isFSExclusiveModeAllowed() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - if (fullScreenExclusivePermission == null) { - fullScreenExclusivePermission = - new AWTPermission("fullScreenExclusive"); - } - try { - security.checkPermission(fullScreenExclusivePermission); - } catch (SecurityException e) { - return false; - } - } - return true; - } - /** * returns true unless we're not allowed to use fullscreen mode. */ @Override public boolean isFullScreenSupported() { - return isFSExclusiveModeAllowed(); + return true; } @Override diff --git a/test/jdk/lib/client/ExtendedRobot.java b/test/jdk/lib/client/ExtendedRobot.java index 2a39017231c..3f77da88750 100644 --- a/test/jdk/lib/client/ExtendedRobot.java +++ b/test/jdk/lib/client/ExtendedRobot.java @@ -68,11 +68,8 @@ public class ExtendedRobot extends Robot { * @throws AWTException if the platform configuration does not allow low-level input * control. This exception is always thrown when * GraphicsEnvironment.isHeadless() returns true - * @throws SecurityException if {@code createRobot} permission is not granted * * @see java.awt.GraphicsEnvironment#isHeadless - * @see SecurityManager#checkPermission - * @see java.awt.AWTPermission */ public ExtendedRobot() throws AWTException { super(); @@ -99,12 +96,9 @@ public class ExtendedRobot extends Robot { * GraphicsEnvironment.isHeadless() returns true. * @throws IllegalArgumentException if {@code screen} is not a screen * GraphicsDevice. - * @throws SecurityException if {@code createRobot} permission is not granted * * @see java.awt.GraphicsEnvironment#isHeadless * @see GraphicsDevice - * @see SecurityManager#checkPermission - * @see java.awt.AWTPermission */ public ExtendedRobot(GraphicsDevice screen) throws AWTException { super(screen);