diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/AnimationController.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/AnimationController.java index b50a5ad583e..a8fdbaf7a50 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/AnimationController.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/AnimationController.java @@ -25,9 +25,6 @@ package com.sun.java.swing.plaf.windows; -import java.security.AccessController; -import sun.security.action.GetBooleanAction; - import java.util.*; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; @@ -67,9 +64,8 @@ import sun.awt.AppContext; */ class AnimationController implements ActionListener, PropertyChangeListener { - @SuppressWarnings("removal") private static final boolean VISTA_ANIMATION_DISABLED = - AccessController.doPrivileged(new GetBooleanAction("swing.disablevistaanimation")); + Boolean.getBoolean("swing.disablevistaanimation"); private static final Object ANIMATION_CONTROLLER_KEY = diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java index aa97b0d0741..72ad51535ff 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java @@ -58,7 +58,6 @@ import java.awt.image.FilteredImageSource; import java.awt.image.ImageFilter; import java.awt.image.ImageProducer; import java.awt.image.RGBImageFilter; -import java.security.AccessController; import javax.swing.AbstractAction; import javax.swing.Action; @@ -90,7 +89,6 @@ import sun.awt.OSInfo; import sun.awt.SunToolkit; import sun.awt.shell.ShellFolder; import sun.font.FontUtilities; -import sun.security.action.GetPropertyAction; import sun.swing.DefaultLayoutStyle; import sun.swing.ImageIconUIResource; import sun.swing.MnemonicHandler; @@ -184,9 +182,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel // performance and compatibility issues, so allow this feature // to be switched off either at runtime or programmatically // - @SuppressWarnings("removal") - String systemFonts = java.security.AccessController.doPrivileged( - new GetPropertyAction("swing.useSystemFontSettings")); + String systemFonts = System.getProperty("swing.useSystemFontSettings"); useSystemFontSettings = systemFonts == null || Boolean.parseBoolean(systemFonts); if (useSystemFontSettings) { @@ -596,8 +592,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel if (!(this instanceof WindowsClassicLookAndFeel) && (OSInfo.getOSType() == OSInfo.OSType.WINDOWS && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) >= 0)) { - @SuppressWarnings("removal") - String prop = AccessController.doPrivileged(new GetPropertyAction("swing.noxp")); + String prop = System.getProperty("swing.noxp"); if (prop == null) { // These desktop properties are not used directly, but are needed to diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java index 5723d4274af..bba5f8dc31e 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java @@ -55,7 +55,6 @@ import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.awt.image.WritableRaster; -import java.security.AccessController; import java.util.HashMap; import javax.swing.AbstractButton; @@ -79,7 +78,6 @@ import javax.swing.text.JTextComponent; import sun.awt.image.SunWritableRaster; import sun.awt.windows.ThemeReader; -import sun.security.action.GetPropertyAction; import sun.swing.CachedPainter; import static com.sun.java.swing.plaf.windows.TMSchema.Part; @@ -124,7 +122,6 @@ class XPStyle { * @return the singleton instance of this class or null if XP styles * are not active or if this is not Windows XP */ - @SuppressWarnings("removal") static synchronized XPStyle getXP() { if (themeActive == null) { Toolkit toolkit = Toolkit.getDefaultToolkit(); @@ -134,9 +131,8 @@ class XPStyle { themeActive = Boolean.FALSE; } if (themeActive.booleanValue()) { - GetPropertyAction propertyAction = - new GetPropertyAction("swing.noxp"); - if (AccessController.doPrivileged(propertyAction) == null && + String propertyAction = System.getProperty("swing.noxp"); + if (propertyAction == null && ThemeReader.isThemed() && !(UIManager.getLookAndFeel() instanceof WindowsClassicLookAndFeel)) { diff --git a/src/java.desktop/windows/classes/sun/awt/PlatformGraphicsInfo.java b/src/java.desktop/windows/classes/sun/awt/PlatformGraphicsInfo.java index 6d14a72400c..642f98b0df2 100644 --- a/src/java.desktop/windows/classes/sun/awt/PlatformGraphicsInfo.java +++ b/src/java.desktop/windows/classes/sun/awt/PlatformGraphicsInfo.java @@ -39,15 +39,9 @@ public class PlatformGraphicsInfo { hasDisplays = hasDisplays0(); } - @SuppressWarnings({"removal", "restricted"}) + @SuppressWarnings("restricted") private static void loadAWTLibrary() { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + System.loadLibrary("awt"); } private static native boolean hasDisplays0(); diff --git a/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java b/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java index 1d5f76f9960..52042a600f9 100644 --- a/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java +++ b/src/java.desktop/windows/classes/sun/awt/Win32FontManager.java @@ -29,13 +29,12 @@ package sun.awt; import java.awt.FontFormatException; import java.awt.GraphicsEnvironment; import java.io.File; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.HashMap; import java.util.Locale; import java.util.NoSuchElementException; import java.util.StringTokenizer; +import java.util.function.Supplier; import sun.awt.windows.WFontConfiguration; import sun.font.FontManager; @@ -47,24 +46,21 @@ import sun.font.TrueTypeFont; */ public final class Win32FontManager extends SunFontManager { - @SuppressWarnings("removal") private static final TrueTypeFont eudcFont = - AccessController.doPrivileged(new PrivilegedAction() { - public TrueTypeFont run() { - String eudcFile = getEUDCFontFile(); - if (eudcFile != null) { - try { - /* Must use Java rasteriser since GDI doesn't - * enumerate (allow direct use) of EUDC fonts. - */ - return new TrueTypeFont(eudcFile, null, 0, - true, false); - } catch (FontFormatException e) { - } + ((Supplier) () -> { + String eudcFile = getEUDCFontFile(); + if (eudcFile != null) { + try { + /* Must use Java rasteriser since GDI doesn't + * enumerate (allow direct use) of EUDC fonts. + */ + return new TrueTypeFont(eudcFile, null, 0, + true, false); + } catch (FontFormatException e) { } - return null; } - }); + return null; + }).get(); /* Used on Windows to obtain from the windows registry the name * of a file containing the system EUFC font. If running in one of @@ -78,20 +74,14 @@ public final class Win32FontManager extends SunFontManager { return eudcFont; } - @SuppressWarnings("removal") public Win32FontManager() { super(); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - /* Register the JRE fonts so that the native platform can - * access them. This is used only on Windows so that when - * printing the printer driver can access the fonts. - */ - registerJREFontsWithPlatform(jreFontDirName); - return null; - } - }); + /* Register the JRE fonts so that the native platform can + * access them. This is used only on Windows so that when + * printing the printer driver can access the fonts. + */ + registerJREFontsWithPlatform(jreFontDirName); } /** @@ -213,21 +203,15 @@ public final class Win32FontManager extends SunFontManager { info[1] = "c:\\windows\\fonts"; final String[] dirs = getPlatformFontDirs(true); if (dirs.length > 1) { - @SuppressWarnings("removal") - String dir = (String) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - for (int i=0; i() { - public Object run() { - File f1 = new File(pathName); - String[] ls = f1.list(SunFontManager.getInstance(). - getTrueTypeFilter()); - if (ls == null) { - return null; - } - for (int i=0; i () { - public String run() { - return dir.getAbsolutePath(); - } - }); + String path = dir.getAbsolutePath(); return (path.startsWith("\\\\") && path.indexOf("\\", 2) < 0); //Network path } @@ -572,25 +565,17 @@ final class Win32ShellFolderManager2 extends ShellFolderManager { private static class ComInvoker extends ThreadPoolExecutor implements ThreadFactory, ShellFolder.Invoker { private static Thread comThread; - @SuppressWarnings("removal") private ComInvoker() { super(1, 1, 0, TimeUnit.DAYS, new LinkedBlockingQueue<>()); allowCoreThreadTimeOut(false); setThreadFactory(this); - final Runnable shutdownHook = () -> AccessController.doPrivileged((PrivilegedAction) () -> { - shutdownNow(); - return null; - }); - AccessController.doPrivileged((PrivilegedAction) () -> { - Thread t = new Thread( - ThreadGroupUtils.getRootThreadGroup(), shutdownHook, - "ShellFolder", 0, false); - Runtime.getRuntime().addShutdownHook(t); - return null; - }); + final Runnable shutdownHook = () -> shutdownNow(); + Thread t = new Thread( + ThreadGroupUtils.getRootThreadGroup(), shutdownHook, + "ShellFolder", 0, false); + Runtime.getRuntime().addShutdownHook(t); } - @SuppressWarnings("removal") public synchronized Thread newThread(final Runnable task) { final Runnable comRun = new Runnable() { public void run() { @@ -602,27 +587,22 @@ final class Win32ShellFolderManager2 extends ShellFolderManager { } } }; - comThread = AccessController.doPrivileged((PrivilegedAction) () -> { - String name = "Swing-Shell"; - /* The thread must be a member of a thread group - * which will not get GCed before VM exit. - * Make its parent the top-level thread group. - */ - Thread thread = new Thread( - ThreadGroupUtils.getRootThreadGroup(), comRun, name, - 0, false); - thread.setDaemon(true); - /* This is important, since this thread running at lower priority - leads to memory consumption when listDrives() function is called - repeatedly. - */ - thread.setPriority(Thread.MAX_PRIORITY); - return thread; - }); + /* The thread must be a member of a thread group + * which will not get GCed before VM exit. + * Make its parent the top-level thread group. + */ + comThread = new Thread( + ThreadGroupUtils.getRootThreadGroup(), comRun, "Swing-Shell", + 0, false); + comThread.setDaemon(true); + /* This is important, since this thread running at lower priority + leads to memory consumption when listDrives() function is called + repeatedly. + */ + comThread.setPriority(Thread.MAX_PRIORITY); return comThread; } - @SuppressWarnings("removal") public T invoke(Callable task) throws Exception { if (Thread.currentThread() == comThread) { // if it's already called from the COM @@ -640,13 +620,8 @@ final class Win32ShellFolderManager2 extends ShellFolderManager { try { return future.get(); } catch (InterruptedException e) { - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - future.cancel(true); + future.cancel(true); - return null; - } - }); throw e; } catch (ExecutionException e) { diff --git a/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java b/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java index 56cea268d28..b31685294ba 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java @@ -35,7 +35,6 @@ import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.awt.image.VolatileImage; -import java.security.AccessController; import sun.awt.image.BufImgSurfaceData; import sun.java2d.DestSurfaceProvider; import sun.java2d.InvalidPipeException; @@ -45,7 +44,6 @@ import sun.java2d.pipe.RenderQueue; import sun.java2d.pipe.BufferedContext; import sun.java2d.pipe.hw.AccelGraphicsConfig; import sun.java2d.pipe.hw.AccelSurface; -import sun.security.action.GetPropertyAction; import static java.awt.image.VolatileImage.*; import static sun.java2d.pipe.hw.AccelSurface.*; @@ -66,14 +64,10 @@ abstract class TranslucentWindowPainter { protected WWindowPeer peer; // REMIND: we probably would want to remove this later - @SuppressWarnings("removal") - private static final boolean forceOpt = - Boolean.parseBoolean(AccessController.doPrivileged( - new GetPropertyAction("sun.java2d.twp.forceopt", "false"))); - @SuppressWarnings("removal") - private static final boolean forceSW = - Boolean.parseBoolean(AccessController.doPrivileged( - new GetPropertyAction("sun.java2d.twp.forcesw", "false"))); + private static final boolean forceOpt = + Boolean.getBoolean("sun.java2d.twp.forceopt"); + private static final boolean forceSW = + Boolean.getBoolean("sun.java2d.twp.forcesw"); /** * Creates an instance of the painter for particular peer. diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java b/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java index 0ffc973408a..a6294e05ba9 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WEmbeddedFrame.java @@ -32,11 +32,8 @@ import java.awt.peer.ComponentPeer; import java.awt.image.*; import sun.awt.image.ByteInterleavedRaster; -import sun.security.action.GetPropertyAction; import java.awt.peer.FramePeer; -import java.security.PrivilegedAction; -import java.security.AccessController; @SuppressWarnings("serial") // JDK-implementation class public class WEmbeddedFrame extends EmbeddedFrame { @@ -60,9 +57,7 @@ public class WEmbeddedFrame extends EmbeddedFrame { */ private boolean isEmbeddedInIE = false; - @SuppressWarnings("removal") - private static String printScale = AccessController.doPrivileged( - new GetPropertyAction("sun.java2d.print.pluginscalefactor")); + private static String printScale = System.getProperty("sun.java2d.print.pluginscalefactor"); public WEmbeddedFrame() { this((long)0); @@ -181,7 +176,6 @@ public class WEmbeddedFrame extends EmbeddedFrame { } } - @SuppressWarnings("removal") protected static int getPrintScaleFactor() { // check if value is already cached if (pScale != 0) @@ -189,13 +183,7 @@ public class WEmbeddedFrame extends EmbeddedFrame { if (printScale == null) { // if no system property is specified, // check for environment setting - printScale = AccessController.doPrivileged( - new PrivilegedAction() { - public String run() { - return System.getenv("JAVA2D_PLUGIN_PRINT_SCALE"); - } - } - ); + printScale = System.getenv("JAVA2D_PLUGIN_PRINT_SCALE"); } int default_printDC_scale = 4; int scale = default_printDC_scale; diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java index 7502b667250..60f3726249e 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java @@ -30,8 +30,6 @@ import java.awt.dnd.DropTarget; import java.awt.peer.*; import java.io.File; import java.io.FilenameFilter; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ResourceBundle; import java.util.MissingResourceException; import java.util.Vector; @@ -197,19 +195,13 @@ final class WFileDialogPeer extends WWindowPeer implements FileDialogPeer { //This whole static block is a part of 4152317 fix static { - @SuppressWarnings("removal") - String filterString = AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public String run() { - try { - ResourceBundle rb = ResourceBundle.getBundle("sun.awt.windows.awtLocalization"); - return rb.getString("allFiles"); - } catch (MissingResourceException e) { - return "All Files"; - } - } - }); + String filterString; + try { + ResourceBundle rb = ResourceBundle.getBundle("sun.awt.windows.awtLocalization"); + filterString = rb.getString("allFiles"); + } catch (MissingResourceException e) { + filterString = "All Files"; + } setFilterString(filterString); } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WFramePeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WFramePeer.java index a5612b08dc4..9b74f7359fb 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WFramePeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WFramePeer.java @@ -32,11 +32,9 @@ import java.awt.GraphicsConfiguration; import java.awt.MenuBar; import java.awt.Rectangle; import java.awt.peer.FramePeer; -import java.security.AccessController; import sun.awt.AWTAccessor; import sun.awt.im.InputMethodManager; -import sun.security.action.GetPropertyAction; import static sun.java2d.SunGraphicsEnvironment.getGCDeviceBounds; import static sun.java2d.SunGraphicsEnvironment.toDeviceSpaceAbs; @@ -80,11 +78,8 @@ class WFramePeer extends WWindowPeer implements FramePeer { private native void setMaximizedBounds(int x, int y, int w, int h); private native void clearMaximizedBounds(); - @SuppressWarnings("removal") private static final boolean keepOnMinimize = "true".equals( - AccessController.doPrivileged( - new GetPropertyAction( - "sun.awt.keepWorkingSetOnMinimize"))); + System.getProperty("sun.awt.keepWorkingSetOnMinimize")); @Override public final void setMaximizedBounds(Rectangle b) { diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java b/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java index 344a8e7dbc8..3a736e5c519 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WMenuItemPeer.java @@ -29,11 +29,8 @@ import java.util.MissingResourceException; import java.awt.*; import java.awt.peer.*; import java.awt.event.ActionEvent; -import java.security.AccessController; -import java.security.PrivilegedAction; import sun.util.logging.PlatformLogger; -@SuppressWarnings("removal") class WMenuItemPeer extends WObjectPeer implements MenuItemPeer { private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.WMenuItemPeer"); @@ -146,20 +143,15 @@ class WMenuItemPeer extends WObjectPeer implements MenuItemPeer { private static Font defaultMenuFont; static { - defaultMenuFont = AccessController.doPrivileged( - new PrivilegedAction () { - public Font run() { - try { - ResourceBundle rb = ResourceBundle.getBundle("sun.awt.windows.awtLocalization"); - return Font.decode(rb.getString("menuFont")); - } catch (MissingResourceException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("WMenuItemPeer: " + e.getMessage()+". Using default MenuItem font.", e); - } - return new Font("SanSerif", Font.PLAIN, 11); - } - } - }); + try { + ResourceBundle rb = ResourceBundle.getBundle("sun.awt.windows.awtLocalization"); + defaultMenuFont = Font.decode(rb.getString("menuFont")); + } catch (MissingResourceException e) { + if (log.isLoggable(PlatformLogger.Level.FINE)) { + log.fine("WMenuItemPeer: " + e.getMessage()+". Using default MenuItem font.", e); + } + defaultMenuFont = new Font("SanSerif", Font.PLAIN, 11); + } } static Font getDefaultFont() { diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WPathGraphics.java b/src/java.desktop/windows/classes/sun/awt/windows/WPathGraphics.java index 84ae7e8f418..aef078b950f 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WPathGraphics.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WPathGraphics.java @@ -95,11 +95,8 @@ final class WPathGraphics extends PathGraphics { private static boolean useGDITextLayout = true; private static boolean preferGDITextLayout = false; static { - @SuppressWarnings("removal") - String textLayoutStr = - java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction( - "sun.java2d.print.enableGDITextLayout")); + String textLayoutStr = System.getProperty( + "sun.java2d.print.enableGDITextLayout"); if (textLayoutStr != null) { useGDITextLayout = Boolean.getBoolean(textLayoutStr); diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java b/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java index ad643ccbd3d..f2fbfa9b77d 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java @@ -112,8 +112,6 @@ import java.awt.peer.TrayIconPeer; import java.awt.peer.WindowPeer; import java.beans.PropertyChangeListener; import java.lang.ref.WeakReference; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Hashtable; import java.util.Locale; import java.util.Map; @@ -168,17 +166,11 @@ public final class WToolkit extends SunToolkit implements Runnable { */ private static native void initIDs(); private static boolean loaded = false; - @SuppressWarnings({"removal", "restricted"}) + + @SuppressWarnings("restricted") public static void loadLibraries() { if (!loaded) { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - @Override - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + System.loadLibrary("awt"); loaded = true; } } @@ -208,7 +200,6 @@ public final class WToolkit extends SunToolkit implements Runnable { private static native boolean startToolkitThread(Runnable thread, ThreadGroup rootThreadGroup); - @SuppressWarnings("removal") public WToolkit() { // Startup toolkit threads if (PerformanceLogger.loggingEnabled()) { @@ -225,16 +216,12 @@ public final class WToolkit extends SunToolkit implements Runnable { AWTAutoShutdown.notifyToolkitThreadBusy(); // Find a root TG and attach toolkit thread to it - ThreadGroup rootTG = AccessController.doPrivileged( - (PrivilegedAction) ThreadGroupUtils::getRootThreadGroup); + ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup(); if (!startToolkitThread(this, rootTG)) { final String name = "AWT-Windows"; - AccessController.doPrivileged((PrivilegedAction) () -> { - Thread toolkitThread = new Thread(rootTG, this, name, 0, false); - toolkitThread.setDaemon(true); - toolkitThread.start(); - return null; - }); + Thread toolkitThread = new Thread(rootTG, this, name, 0, false); + toolkitThread.setDaemon(true); + toolkitThread.start(); } try { @@ -251,36 +238,25 @@ public final class WToolkit extends SunToolkit implements Runnable { // by the native system though. setDynamicLayout(true); final String extraButtons = "sun.awt.enableExtraMouseButtons"; - AccessController.doPrivileged((PrivilegedAction) () -> { - areExtraMouseButtonsEnabled = - Boolean.parseBoolean(System.getProperty(extraButtons, "true")); - //set system property if not yet assigned - System.setProperty(extraButtons, ""+areExtraMouseButtonsEnabled); - return null; - }); + areExtraMouseButtonsEnabled = + Boolean.parseBoolean(System.getProperty(extraButtons, "true")); + //set system property if not yet assigned + System.setProperty(extraButtons, ""+areExtraMouseButtonsEnabled); setExtraMouseButtonsEnabledNative(areExtraMouseButtonsEnabled); } - @SuppressWarnings("removal") private void registerShutdownHook() { - AccessController.doPrivileged((PrivilegedAction) () -> { - Thread shutdown = new Thread( - ThreadGroupUtils.getRootThreadGroup(), this::shutdown, - "ToolkitShutdown", 0, false); - shutdown.setContextClassLoader(null); - Runtime.getRuntime().addShutdownHook(shutdown); - return null; - }); - } + Thread shutdown = new Thread( + ThreadGroupUtils.getRootThreadGroup(), this::shutdown, + "ToolkitShutdown", 0, false); + shutdown.setContextClassLoader(null); + Runtime.getRuntime().addShutdownHook(shutdown); + } - @SuppressWarnings("removal") @Override public void run() { - AccessController.doPrivileged((PrivilegedAction) () -> { - Thread.currentThread().setContextClassLoader(null); - Thread.currentThread().setPriority(Thread.NORM_PRIORITY + 1); - return null; - }); + Thread.currentThread().setContextClassLoader(null); + Thread.currentThread().setPriority(Thread.NORM_PRIORITY + 1); boolean startPump = init(); diff --git a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java index 7ad09a5e750..fd9112e08f1 100644 --- a/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java +++ b/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java @@ -32,8 +32,6 @@ import java.awt.Font; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Window; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.HashMap; @@ -91,25 +89,21 @@ public class D3DScreenUpdateManager extends ScreenUpdateManager */ private HashMap gdiSurfaces; - @SuppressWarnings("removal") public D3DScreenUpdateManager() { done = false; - AccessController.doPrivileged((PrivilegedAction) () -> { - Runnable shutdownRunnable = () -> { - done = true; - wakeUpUpdateThread(); - }; - Thread shutdown = new Thread( - ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable, - "ScreenUpdater", 0, false); - shutdown.setContextClassLoader(null); - try { - Runtime.getRuntime().addShutdownHook(shutdown); - } catch (Exception e) { - done = true; - } - return null; - }); + Runnable shutdownRunnable = () -> { + done = true; + wakeUpUpdateThread(); + }; + Thread shutdown = new Thread( + ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable, + "ScreenUpdater", 0, false); + shutdown.setContextClassLoader(null); + try { + Runtime.getRuntime().addShutdownHook(shutdown); + } catch (Exception e) { + done = true; + } } /** @@ -345,19 +339,15 @@ public class D3DScreenUpdateManager extends ScreenUpdateManager * If the update thread hasn't yet been created, it will be; * otherwise it is awaken */ - @SuppressWarnings("removal") private synchronized void startUpdateThread() { if (screenUpdater == null) { - screenUpdater = AccessController.doPrivileged((PrivilegedAction) () -> { - String name = "D3D Screen Updater"; - Thread t = new Thread( + String name = "D3D Screen Updater"; + screenUpdater = new Thread( ThreadGroupUtils.getRootThreadGroup(), this, name, 0, false); - // REMIND: should it be higher? - t.setPriority(Thread.NORM_PRIORITY + 2); - t.setDaemon(true); - return t; - }); + // REMIND: should it be higher? + screenUpdater.setPriority(Thread.NORM_PRIORITY + 2); + screenUpdater.setDaemon(true); screenUpdater.start(); } else { wakeUpUpdateThread(); diff --git a/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java b/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java index 3c18de432bb..da13c6b49fc 100644 --- a/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java +++ b/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java @@ -176,65 +176,57 @@ public class WindowsFlags { return (propString != null) ? true : false; } - @SuppressWarnings("removal") private static void initJavaFlags() { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() - { - public Object run() { - magPresent = getBooleanProp( - "javax.accessibility.screen_magnifier_present", false); - boolean ddEnabled = - !getBooleanProp("sun.java2d.noddraw", magPresent); - boolean ddOffscreenEnabled = - getBooleanProp("sun.java2d.ddoffscreen", ddEnabled); - d3dEnabled = getBooleanProp("sun.java2d.d3d", - ddEnabled && ddOffscreenEnabled); - d3dOnScreenEnabled = - getBooleanProp("sun.java2d.d3d.onscreen", d3dEnabled); - oglEnabled = getBooleanProp("sun.java2d.opengl", false); - if (oglEnabled) { - oglVerbose = isBooleanPropTrueVerbose("sun.java2d.opengl"); - if (WGLGraphicsConfig.isWGLAvailable()) { - d3dEnabled = false; - } else { - if (oglVerbose) { - System.out.println( - "Could not enable OpenGL pipeline " + - "(WGL not available)"); - } - oglEnabled = false; - } - } - gdiBlitEnabled = getBooleanProp("sun.java2d.gdiBlit", true); - d3dSet = getPropertySet("sun.java2d.d3d"); - if (d3dSet) { - d3dVerbose = isBooleanPropTrueVerbose("sun.java2d.d3d"); - } - offscreenSharingEnabled = - getBooleanProp("sun.java2d.offscreenSharing", false); - String dpiOverride = System.getProperty("sun.java2d.dpiaware"); - if (dpiOverride != null) { - setHighDPIAware = dpiOverride.equalsIgnoreCase("true"); - } else { - String sunLauncherProperty = - System.getProperty("sun.java.launcher", "unknown"); - setHighDPIAware = - sunLauncherProperty.equalsIgnoreCase("SUN_STANDARD"); - } - /* - // Output info based on some non-default flags: - if (offscreenSharingEnabled) { + magPresent = getBooleanProp( + "javax.accessibility.screen_magnifier_present", false); + boolean ddEnabled = + !getBooleanProp("sun.java2d.noddraw", magPresent); + boolean ddOffscreenEnabled = + getBooleanProp("sun.java2d.ddoffscreen", ddEnabled); + d3dEnabled = getBooleanProp("sun.java2d.d3d", + ddEnabled && ddOffscreenEnabled); + d3dOnScreenEnabled = + getBooleanProp("sun.java2d.d3d.onscreen", d3dEnabled); + oglEnabled = getBooleanProp("sun.java2d.opengl", false); + if (oglEnabled) { + oglVerbose = isBooleanPropTrueVerbose("sun.java2d.opengl"); + if (WGLGraphicsConfig.isWGLAvailable()) { + d3dEnabled = false; + } else { + if (oglVerbose) { System.out.println( - "Warning: offscreenSharing has been enabled. " + - "The use of this capability will change in future " + - "releases and applications that depend on it " + - "may not work correctly"); + "Could not enable OpenGL pipeline " + + "(WGL not available)"); } - */ - return null; + oglEnabled = false; } - }); + } + gdiBlitEnabled = getBooleanProp("sun.java2d.gdiBlit", true); + d3dSet = getPropertySet("sun.java2d.d3d"); + if (d3dSet) { + d3dVerbose = isBooleanPropTrueVerbose("sun.java2d.d3d"); + } + offscreenSharingEnabled = + getBooleanProp("sun.java2d.offscreenSharing", false); + String dpiOverride = System.getProperty("sun.java2d.dpiaware"); + if (dpiOverride != null) { + setHighDPIAware = dpiOverride.equalsIgnoreCase("true"); + } else { + String sunLauncherProperty = + System.getProperty("sun.java.launcher", "unknown"); + setHighDPIAware = + sunLauncherProperty.equalsIgnoreCase("SUN_STANDARD"); + } + /* + // Output info based on some non-default flags: + if (offscreenSharingEnabled) { + System.out.println( + "Warning: offscreenSharing has been enabled. " + + "The use of this capability will change in future " + + "releases and applications that depend on it " + + "may not work correctly"); + } + */ /* System.out.println("WindowsFlags (Java):"); System.out.println(" ddEnabled: " + ddEnabled + "\n" + diff --git a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java index 9079e7c2bfe..44173fb2abf 100644 --- a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java +++ b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java @@ -25,8 +25,6 @@ package sun.print; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import javax.print.DocFlavor; @@ -54,15 +52,9 @@ public class PrintServiceLookupProvider extends PrintServiceLookup { loadAWTLibrary(); } - @SuppressWarnings({"removal", "restricted"}) + @SuppressWarnings("restricted") private static void loadAWTLibrary() { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + System.loadLibrary("awt"); } /* The singleton win32 print lookup service. @@ -85,31 +77,26 @@ public class PrintServiceLookupProvider extends PrintServiceLookup { return win32PrintLUS; } - @SuppressWarnings("removal") public PrintServiceLookupProvider() { if (win32PrintLUS == null) { win32PrintLUS = this; // start the local printer listener thread - AccessController.doPrivileged((PrivilegedAction) () -> { - Thread thr = new Thread(ThreadGroupUtils.getRootThreadGroup(), - new PrinterChangeListener(), - "PrinterListener", 0, false); - thr.setContextClassLoader(null); - thr.setDaemon(true); - return thr; - }).start(); + Thread thr = new Thread(ThreadGroupUtils.getRootThreadGroup(), + new PrinterChangeListener(), + "PrinterListener", 0, false); + thr.setContextClassLoader(null); + thr.setDaemon(true); + thr.start(); // start the remote printer listener thread - AccessController.doPrivileged((PrivilegedAction) () -> { - Thread thr = new Thread(ThreadGroupUtils.getRootThreadGroup(), - new RemotePrinterChangeListener(), - "RemotePrinterListener", 0, false); - thr.setContextClassLoader(null); - thr.setDaemon(true); - return thr; - }).start(); + Thread thr1 = new Thread(ThreadGroupUtils.getRootThreadGroup(), + new RemotePrinterChangeListener(), + "RemotePrinterListener", 0, false); + thr1.setContextClassLoader(null); + thr1.setDaemon(true); + thr1.start(); } /* else condition ought to never happen! */ }