From 5b12a87dcb47b5783f179534e2de43d5a920a489 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Wed, 20 Nov 2024 09:11:12 +0000 Subject: [PATCH] 8344060: Remove doPrivileged calls from shared implementation code in the java.desktop module : part 1 Reviewed-by: aivanov, prr --- .../share/classes/sun/awt/SunToolkit.java | 47 +++------ .../classes/sun/awt/image/ImageDecoder.java | 9 +- .../classes/sun/awt/image/ImageFetcher.java | 30 +++--- .../classes/sun/awt/image/ImageWatched.java | 36 +------ .../classes/sun/awt/image/ImagingLib.java | 24 ++--- .../sun/awt/image/JPEGImageDecoder.java | 10 +- .../sun/awt/image/NativeLibLoader.java | 10 +- .../sun/awt/image/VSyncedBSManager.java | 5 +- .../sun/awt/util/PerformanceLogger.java | 33 +++---- .../share/classes/sun/java2d/Disposer.java | 32 ++---- .../sun/java2d/SunGraphicsEnvironment.java | 10 +- .../classes/sun/java2d/SurfaceDataProxy.java | 11 +-- .../classes/sun/java2d/cmm/CMSManager.java | 11 +-- .../classes/sun/java2d/cmm/lcms/LCMS.java | 18 ++-- .../sun/java2d/loops/GraphicsPrimitive.java | 40 +++----- .../java2d/marlin/DMarlinRenderingEngine.java | 8 +- .../sun/java2d/marlin/MarlinProperties.java | 18 +--- .../sun/java2d/marlin/RendererStats.java | 30 +++--- .../sun/java2d/opengl/OGLRenderQueue.java | 5 +- .../sun/java2d/opengl/OGLSurfaceData.java | 20 +--- .../sun/java2d/pipe/RenderingEngine.java | 16 +-- .../share/classes/sun/print/PSPrinterJob.java | 97 ++++++------------- .../classes/sun/print/RasterPrinterJob.java | 61 ++---------- .../classes/sun/print/ServiceDialog.java | 39 ++------ .../classes/sun/swing/JLightweightFrame.java | 15 +-- .../classes/sun/swing/SwingUtilities2.java | 8 +- 26 files changed, 166 insertions(+), 477 deletions(-) diff --git a/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/src/java.desktop/share/classes/sun/awt/SunToolkit.java index 5c4ebda8715..1dc6c2f3920 100644 --- a/src/java.desktop/share/classes/sun/awt/SunToolkit.java +++ b/src/java.desktop/share/classes/sun/awt/SunToolkit.java @@ -79,7 +79,6 @@ import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.net.URL; -import java.security.AccessController; import java.util.ArrayList; import java.util.Collections; import java.util.Locale; @@ -100,8 +99,6 @@ import sun.awt.image.ToolkitImage; import sun.awt.image.URLImageSource; import sun.font.FontDesignMetrics; import sun.net.util.URLUtil; -import sun.security.action.GetBooleanAction; -import sun.security.action.GetPropertyAction; import sun.util.logging.PlatformLogger; import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING; @@ -122,14 +119,12 @@ public abstract class SunToolkit extends Toolkit initStatic(); } - @SuppressWarnings("removal") private static void initStatic() { - if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.nativedebug"))) { + if (Boolean.getBoolean("sun.awt.nativedebug")) { DebugSettings.init(); } touchKeyboardAutoShowIsEnabled = Boolean.parseBoolean( - GetPropertyAction.privilegedGetProperty( - "awt.touchKeyboardAutoShowIsEnabled", "true")); + System.getProperty("awt.touchKeyboardAutoShowIsEnabled", "true")); } /** @@ -231,9 +226,8 @@ public abstract class SunToolkit extends Toolkit * } */ - @SuppressWarnings("removal") private static final ReentrantLock AWT_LOCK = new ReentrantLock( - AccessController.doPrivileged(new GetBooleanAction("awt.lock.fair"))); + Boolean.getBoolean("awt.lock.fair")); private static final Condition AWT_LOCK_COND = AWT_LOCK.newCondition(); public static final void awtLock() { @@ -672,18 +666,16 @@ public abstract class SunToolkit extends Toolkit * Returns the value of "sun.awt.noerasebackground" property. Default * value is {@code false}. */ - @SuppressWarnings("removal") public static boolean getSunAwtNoerasebackground() { - return AccessController.doPrivileged(new GetBooleanAction("sun.awt.noerasebackground")); + return Boolean.getBoolean("sun.awt.noerasebackground"); } /** * Returns the value of "sun.awt.erasebackgroundonresize" property. Default * value is {@code false}. */ - @SuppressWarnings("removal") public static boolean getSunAwtErasebackgroundonresize() { - return AccessController.doPrivileged(new GetBooleanAction("sun.awt.erasebackgroundonresize")); + return Boolean.getBoolean("sun.awt.erasebackgroundonresize"); } @@ -1157,15 +1149,12 @@ public abstract class SunToolkit extends Toolkit /** * Returns the locale in which the runtime was started. */ - @SuppressWarnings("removal") public static Locale getStartupLocale() { if (startupLocale == null) { String language, region, country, variant; - language = AccessController.doPrivileged( - new GetPropertyAction("user.language", "en")); + language = System.getProperty("user.language", "en"); // for compatibility, check for old user.region property - region = AccessController.doPrivileged( - new GetPropertyAction("user.region")); + region = System.getProperty("user.region"); if (region != null) { // region can be of form country, country_variant, or _variant int i = region.indexOf('_'); @@ -1177,10 +1166,8 @@ public abstract class SunToolkit extends Toolkit variant = ""; } } else { - country = AccessController.doPrivileged( - new GetPropertyAction("user.country", "")); - variant = AccessController.doPrivileged( - new GetPropertyAction("user.variant", "")); + country = System.getProperty("user.country", ""); + variant = System.getProperty("user.variant", ""); } startupLocale = Locale.of(language, country, variant); } @@ -1201,9 +1188,7 @@ public abstract class SunToolkit extends Toolkit * @return {@code true}, if XEmbed is needed, {@code false} otherwise */ public static boolean needsXEmbed() { - @SuppressWarnings("removal") - String noxembed = AccessController. - doPrivileged(new GetPropertyAction("sun.awt.noxembed", "false")); + String noxembed = System.getProperty("sun.awt.noxembed", "false"); if ("true".equals(noxembed)) { return false; } @@ -1235,9 +1220,8 @@ public abstract class SunToolkit extends Toolkit * developer. If true, Toolkit should return an * XEmbed-server-enabled CanvasPeer instead of the ordinary CanvasPeer. */ - @SuppressWarnings("removal") protected final boolean isXEmbedServerRequested() { - return AccessController.doPrivileged(new GetBooleanAction("sun.awt.xembedserver")); + return Boolean.getBoolean("sun.awt.xembedserver"); } /** @@ -1756,16 +1740,13 @@ public abstract class SunToolkit extends Toolkit * to be inapplicable in that case. In that headless case although * this method will return "true" the toolkit will return a null map. */ - @SuppressWarnings("removal") private static boolean useSystemAAFontSettings() { if (!checkedSystemAAFontSettings) { useSystemAAFontSettings = true; /* initially set this true */ String systemAAFonts = null; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { - systemAAFonts = - AccessController.doPrivileged( - new GetPropertyAction("awt.useSystemAAFontSettings")); + systemAAFonts = System.getProperty("awt.useSystemAAFontSettings"); } if (systemAAFonts != null) { useSystemAAFontSettings = Boolean.parseBoolean(systemAAFonts); @@ -1859,11 +1840,9 @@ public abstract class SunToolkit extends Toolkit * Returns the value of "sun.awt.disableMixing" property. Default * value is {@code false}. */ - @SuppressWarnings("removal") public static synchronized boolean getSunAwtDisableMixing() { if (sunAwtDisableMixing == null) { - sunAwtDisableMixing = AccessController.doPrivileged( - new GetBooleanAction("sun.awt.disableMixing")); + sunAwtDisableMixing = Boolean.getBoolean("sun.awt.disableMixing"); } return sunAwtDisableMixing.booleanValue(); } diff --git a/src/java.desktop/share/classes/sun/awt/image/ImageDecoder.java b/src/java.desktop/share/classes/sun/awt/image/ImageDecoder.java index d09cfd9b2d8..c3691773f6e 100644 --- a/src/java.desktop/share/classes/sun/awt/image/ImageDecoder.java +++ b/src/java.desktop/share/classes/sun/awt/image/ImageDecoder.java @@ -159,18 +159,11 @@ public abstract class ImageDecoder { public abstract void produceImage() throws IOException, ImageFormatException; - @SuppressWarnings("removal") public void abort() { aborted = true; source.doneDecoding(this); close(); - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - feeder.interrupt(); - return null; - } - }); + feeder.interrupt(); } public synchronized void close() { diff --git a/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java b/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java index e527dbfcb3f..88e830a2bf5 100644 --- a/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java +++ b/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java @@ -276,7 +276,6 @@ class ImageFetcher extends Thread { /** * Create and start ImageFetcher threads in the appropriate ThreadGroup. */ - @SuppressWarnings("removal") private static void createFetchers(final FetcherInfo info) { // We need to instantiate a new ImageFetcher thread. // First, figure out which ThreadGroup we'll put the @@ -310,25 +309,18 @@ class ImageFetcher extends Thread { } final ThreadGroup fetcherGroup = fetcherThreadGroup; - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - for (int i = 0; i < info.fetchers.length; i++) { - if (info.fetchers[i] == null) { - ImageFetcher f = new ImageFetcher(fetcherGroup, i); - try { - f.start(); - info.fetchers[i] = f; - info.numFetchers++; - break; - } catch (Error e) { - } - } - } - return null; + for (int i = 0; i < info.fetchers.length; i++) { + if (info.fetchers[i] == null) { + ImageFetcher f = new ImageFetcher(fetcherGroup, i); + try { + f.start(); + info.fetchers[i] = f; + info.numFetchers++; + break; + } catch (Error e) { } - }); - return; + } + } } } diff --git a/src/java.desktop/share/classes/sun/awt/image/ImageWatched.java b/src/java.desktop/share/classes/sun/awt/image/ImageWatched.java index 0a1dd47fb55..c3198ac704b 100644 --- a/src/java.desktop/share/classes/sun/awt/image/ImageWatched.java +++ b/src/java.desktop/share/classes/sun/awt/image/ImageWatched.java @@ -29,10 +29,6 @@ import java.lang.ref.WeakReference; import java.awt.Image; import java.awt.image.ImageObserver; -import java.security.AccessControlContext; -import java.security.AccessController; -import java.security.PrivilegedAction; - public abstract class ImageWatched { public static Link endlink = new Link(); @@ -89,28 +85,16 @@ public abstract class ImageWatched { } } - static class AccWeakReference extends WeakReference { - - @SuppressWarnings("removal") - private final AccessControlContext acc; - - @SuppressWarnings("removal") - AccWeakReference(T ref) { - super(ref); - acc = AccessController.getContext(); - } - } - /* * Standard Link implementation to manage a Weak Reference * to an ImageObserver. */ public static class WeakLink extends Link { - private final AccWeakReference myref; + private final WeakReference myref; private Link next; public WeakLink(ImageObserver obs, Link next) { - myref = new AccWeakReference(obs); + myref = new WeakReference(obs); this.next = next; } @@ -136,20 +120,6 @@ public abstract class ImageWatched { return this; } - @SuppressWarnings("removal") - private static boolean update(ImageObserver iw, AccessControlContext acc, - Image img, int info, - int x, int y, int w, int h) { - - if (acc != null || System.getSecurityManager() != null) { - return AccessController.doPrivileged( - (PrivilegedAction) () -> { - return iw.imageUpdate(img, info, x, y, w, h); - }, acc); - } - return false; - } - public boolean newInfo(Image img, int info, int x, int y, int w, int h) { @@ -159,7 +129,7 @@ public abstract class ImageWatched { if (myiw == null) { // My referent is null so we must prune in a second pass. ret = true; - } else if (update(myiw, myref.acc, img, info, x, y, w, h) == false) { + } else if (myiw.imageUpdate(img, info, x, y, w, h) == false) { // My referent has lost interest so clear it and ask // for a pruning pass to remove it later. myref.clear(); diff --git a/src/java.desktop/share/classes/sun/awt/image/ImagingLib.java b/src/java.desktop/share/classes/sun/awt/image/ImagingLib.java index a98e6fc81fb..d37afcb7a8b 100644 --- a/src/java.desktop/share/classes/sun/awt/image/ImagingLib.java +++ b/src/java.desktop/share/classes/sun/awt/image/ImagingLib.java @@ -37,8 +37,6 @@ import java.awt.image.LookupTable; import java.awt.image.RasterOp; import java.awt.image.Raster; import java.awt.image.WritableRaster; -import java.security.AccessController; -import java.security.PrivilegedAction; /** * This class provides a hook to access platform-specific @@ -51,7 +49,7 @@ import java.security.PrivilegedAction; * (in which case our java code will be executed) or may throw * an exception. */ -@SuppressWarnings({"removal", "restricted"}) +@SuppressWarnings("restricted") public class ImagingLib { static boolean useLib = true; @@ -90,20 +88,14 @@ public class ImagingLib { static { - PrivilegedAction doMlibInitialization = - new PrivilegedAction() { - public Boolean run() { - try { - System.loadLibrary("mlib_image"); - } catch (UnsatisfiedLinkError e) { - return Boolean.FALSE; - } - boolean success = init(); - return Boolean.valueOf(success); - } - }; + boolean success = false; + try { + System.loadLibrary("mlib_image"); + success = init(); + } catch (UnsatisfiedLinkError e) { + } - useLib = AccessController.doPrivileged(doMlibInitialization); + useLib = success; // // Cache the class references of the operations we know about diff --git a/src/java.desktop/share/classes/sun/awt/image/JPEGImageDecoder.java b/src/java.desktop/share/classes/sun/awt/image/JPEGImageDecoder.java index b976a716ded..eb1023bd694 100644 --- a/src/java.desktop/share/classes/sun/awt/image/JPEGImageDecoder.java +++ b/src/java.desktop/share/classes/sun/awt/image/JPEGImageDecoder.java @@ -42,7 +42,7 @@ import java.awt.image.*; * * @author Jim Graham */ -@SuppressWarnings({"removal", "restricted"}) +@SuppressWarnings("restricted") public class JPEGImageDecoder extends ImageDecoder { private static ColorModel RGBcolormodel; private static ColorModel ARGBcolormodel; @@ -54,13 +54,7 @@ public class JPEGImageDecoder extends ImageDecoder { private ColorModel colormodel; static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("javajpeg"); - return null; - } - }); + System.loadLibrary("javajpeg"); initIDs(InputStreamClass); RGBcolormodel = new DirectColorModel(24, 0xff0000, 0xff00, 0xff); ARGBcolormodel = ColorModel.getRGBdefault(); diff --git a/src/java.desktop/share/classes/sun/awt/image/NativeLibLoader.java b/src/java.desktop/share/classes/sun/awt/image/NativeLibLoader.java index e1fe5658e63..d971bf6e40d 100644 --- a/src/java.desktop/share/classes/sun/awt/image/NativeLibLoader.java +++ b/src/java.desktop/share/classes/sun/awt/image/NativeLibLoader.java @@ -52,14 +52,8 @@ class NativeLibLoader { * For now, we know it's done by the implementation, and we assume * that the name of the library is "awt". -br. */ - @SuppressWarnings({"removal", "restricted"}) + @SuppressWarnings("restricted") static void loadLibraries() { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + System.loadLibrary("awt"); } } diff --git a/src/java.desktop/share/classes/sun/awt/image/VSyncedBSManager.java b/src/java.desktop/share/classes/sun/awt/image/VSyncedBSManager.java index 8bb34dd6279..88403ca06a3 100644 --- a/src/java.desktop/share/classes/sun/awt/image/VSyncedBSManager.java +++ b/src/java.desktop/share/classes/sun/awt/image/VSyncedBSManager.java @@ -35,11 +35,8 @@ public abstract class VSyncedBSManager { private static VSyncedBSManager theInstance; - @SuppressWarnings("removal") private static final boolean vSyncLimit = - Boolean.parseBoolean(java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction( - "sun.java2d.vsynclimit", "true"))); + Boolean.parseBoolean(System.getProperty("sun.java2d.vsynclimit", "true")); private static VSyncedBSManager getInstance(boolean create) { if (theInstance == null && create) { diff --git a/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java b/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java index fa4a1450bb4..303b57626d6 100644 --- a/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java +++ b/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java @@ -72,7 +72,6 @@ import java.io.Writer; * exist once those APIs are in place. * @author Chet Haase */ -@SuppressWarnings("removal") public class PerformanceLogger { // Timing values of global interest @@ -87,16 +86,12 @@ public class PerformanceLogger { private static long baseTime; static { - String perfLoggingProp = - java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("sun.perflog")); + String perfLoggingProp = System.getProperty("sun.perflog"); if (perfLoggingProp != null) { perfLoggingOn = true; // Check if we should use nanoTime - String perfNanoProp = - java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("sun.perflog.nano")); + String perfNanoProp = System.getProperty("sun.perflog.nano"); if (perfNanoProp != null) { useNanoTime = true; } @@ -107,21 +102,15 @@ public class PerformanceLogger { } if (logFileName != null) { if (logWriter == null) { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - try { - File logFile = new File(logFileName); - logFile.createNewFile(); - logWriter = new FileWriter(logFile); - } catch (Exception e) { - System.out.println(e + ": Creating logfile " + - logFileName + - ". Log to console"); - } - return null; - } - }); + try { + File logFile = new File(logFileName); + logFile.createNewFile(); + logWriter = new FileWriter(logFile); + } catch (Exception e) { + System.out.println(e + ": Creating logfile " + + logFileName + + ". Log to console"); + } } } if (logWriter == null) { diff --git a/src/java.desktop/share/classes/sun/java2d/Disposer.java b/src/java.desktop/share/classes/sun/java2d/Disposer.java index 5692b490278..9929238c099 100644 --- a/src/java.desktop/share/classes/sun/java2d/Disposer.java +++ b/src/java.desktop/share/classes/sun/java2d/Disposer.java @@ -31,8 +31,6 @@ import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.PhantomReference; import java.lang.ref.WeakReference; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Hashtable; import java.util.concurrent.ConcurrentLinkedDeque; @@ -50,7 +48,7 @@ import java.util.concurrent.ConcurrentLinkedDeque; * * @see DisposerRecord */ -@SuppressWarnings({"removal", "restricted"}) +@SuppressWarnings("restricted") public class Disposer implements Runnable { private static final ReferenceQueue queue = new ReferenceQueue<>(); private static final Hashtable, DisposerRecord> records = @@ -62,16 +60,9 @@ public class Disposer implements Runnable { public static int refType = PHANTOM; static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + System.loadLibrary("awt"); initIDs(); - String type = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("sun.java2d.reftype")); + String type = System.getProperty("sun.java2d.reftype"); if (type != null) { if (type.equals("weak")) { refType = WEAK; @@ -82,16 +73,13 @@ public class Disposer implements Runnable { } } disposerInstance = new Disposer(); - AccessController.doPrivileged((PrivilegedAction) () -> { - String name = "Java2D Disposer"; - ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup(); - Thread t = new Thread(rootTG, disposerInstance, name, 0, false); - t.setContextClassLoader(null); - t.setDaemon(true); - t.setPriority(Thread.MAX_PRIORITY); - t.start(); - return null; - }); + String name = "Java2D Disposer"; + ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup(); + Thread t = new Thread(rootTG, disposerInstance, name, 0, false); + t.setContextClassLoader(null); + t.setDaemon(true); + t.setPriority(Thread.MAX_PRIORITY); + t.start(); } /** diff --git a/src/java.desktop/share/classes/sun/java2d/SunGraphicsEnvironment.java b/src/java.desktop/share/classes/sun/java2d/SunGraphicsEnvironment.java index 4335b1c9fbf..5cd8f11ecdb 100644 --- a/src/java.desktop/share/classes/sun/java2d/SunGraphicsEnvironment.java +++ b/src/java.desktop/share/classes/sun/java2d/SunGraphicsEnvironment.java @@ -40,7 +40,6 @@ import java.awt.Toolkit; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.awt.peer.ComponentPeer; -import java.security.AccessController; import java.util.Locale; import java.util.TreeMap; @@ -50,7 +49,6 @@ import sun.font.FontManager; import sun.font.FontManagerFactory; import sun.font.FontManagerForSGE; import sun.java2d.pipe.Region; -import sun.security.action.GetPropertyAction; /** * This is an implementation of a GraphicsEnvironment object for the @@ -65,10 +63,8 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment /** Establish the default font to be used by SG2D. */ private final Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12); - @SuppressWarnings("removal") private static final boolean uiScaleEnabled - = "true".equals(AccessController.doPrivileged( - new GetPropertyAction("sun.java2d.uiScale.enabled", "true"))); + = "true".equals(System.getProperty("sun.java2d.uiScale.enabled", "true")); private static final double debugScale = uiScaleEnabled ? getScaleFactor("sun.java2d.uiScale") : -1; @@ -293,9 +289,7 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment public static double getScaleFactor(String propertyName) { - @SuppressWarnings("removal") - String scaleFactor = AccessController.doPrivileged( - new GetPropertyAction(propertyName, "-1")); + String scaleFactor = System.getProperty(propertyName, "-1"); if (scaleFactor == null || scaleFactor.equals("-1")) { return -1; diff --git a/src/java.desktop/share/classes/sun/java2d/SurfaceDataProxy.java b/src/java.desktop/share/classes/sun/java2d/SurfaceDataProxy.java index 4c1e8256552..ba4d6caf44c 100644 --- a/src/java.desktop/share/classes/sun/java2d/SurfaceDataProxy.java +++ b/src/java.desktop/share/classes/sun/java2d/SurfaceDataProxy.java @@ -38,9 +38,6 @@ import sun.java2d.loops.Blit; import sun.java2d.loops.BlitBg; import sun.awt.image.SurfaceManager; -import java.security.AccessController; -import sun.security.action.GetPropertyAction; - /** * The proxy class encapsulates the logic for managing alternate * SurfaceData representations of a primary SurfaceData. @@ -70,18 +67,14 @@ public abstract class SurfaceDataProxy static { cachingAllowed = true; - @SuppressWarnings("removal") - String manimg = AccessController.doPrivileged( - new GetPropertyAction("sun.java2d.managedimages")); + String manimg = System.getProperty("sun.java2d.managedimages"); if ("false".equals(manimg)) { cachingAllowed = false; System.out.println("Disabling managed images"); } defaultThreshold = 1; - @SuppressWarnings("removal") - String num = AccessController.doPrivileged( - new GetPropertyAction("sun.java2d.accthreshold")); + String num = System.getProperty("sun.java2d.accthreshold"); if (num != null) { try { int parsed = Integer.parseInt(num); diff --git a/src/java.desktop/share/classes/sun/java2d/cmm/CMSManager.java b/src/java.desktop/share/classes/sun/java2d/cmm/CMSManager.java index 99e167ba672..8aba1056616 100644 --- a/src/java.desktop/share/classes/sun/java2d/cmm/CMSManager.java +++ b/src/java.desktop/share/classes/sun/java2d/cmm/CMSManager.java @@ -27,9 +27,6 @@ package sun.java2d.cmm; import java.awt.color.CMMException; import java.awt.color.ICC_Profile; -import java.security.AccessController; - -import sun.security.action.GetPropertyAction; public final class CMSManager { @@ -45,9 +42,7 @@ public final class CMSManager { return cmmImpl; } - GetPropertyAction gpa = new GetPropertyAction("sun.java2d.cmm"); - @SuppressWarnings("removal") - String cmmProviderClass = AccessController.doPrivileged(gpa); + String cmmProviderClass = System.getProperty("sun.java2d.cmm"); CMMServiceProvider provider = null; if (cmmProviderClass != null) { try { @@ -67,9 +62,7 @@ public final class CMSManager { "No CM module found"); } - gpa = new GetPropertyAction("sun.java2d.cmm.trace"); - @SuppressWarnings("removal") - String cmmTrace = AccessController.doPrivileged(gpa); + String cmmTrace = System.getProperty("sun.java2d.cmm.trace"); if (cmmTrace != null) { cmmImpl = new CMMTracer(cmmImpl); } diff --git a/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java b/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java index 2fe86b3500c..3a7db37329e 100644 --- a/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java +++ b/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java @@ -143,23 +143,17 @@ final class LCMS implements PCMM { private static LCMS theLcms = null; - @SuppressWarnings({"removal", "restricted"}) + @SuppressWarnings("restricted") static synchronized PCMM getModule() { if (theLcms != null) { return theLcms; } - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - /* We need to load awt here because of usage trace and - * disposer frameworks - */ - System.loadLibrary("awt"); - System.loadLibrary("lcms"); - return null; - } - }); + /* We need to load awt here because of usage trace and + * disposer frameworks + */ + System.loadLibrary("awt"); + System.loadLibrary("lcms"); theLcms = new LCMS(); diff --git a/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitive.java b/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitive.java index ade97ee007f..8fd97626f04 100644 --- a/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitive.java +++ b/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitive.java @@ -36,8 +36,6 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; import java.lang.reflect.Field; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; @@ -46,7 +44,6 @@ import sun.awt.image.BufImgSurfaceData; import sun.awt.util.ThreadGroupUtils; import sun.java2d.SurfaceData; import sun.java2d.pipe.Region; -import sun.security.action.GetPropertyAction; /** * defines interface for primitives which can be placed into @@ -336,9 +333,7 @@ public abstract class GraphicsPrimitive { public static final int TRACECOUNTS = 4; static { - GetPropertyAction gpa = new GetPropertyAction("sun.java2d.trace"); - @SuppressWarnings("removal") - String trace = AccessController.doPrivileged(gpa); + String trace = System.getProperty("sun.java2d.trace"); if (trace != null) { boolean verbose = false; int traceflags = 0; @@ -401,17 +396,12 @@ public abstract class GraphicsPrimitive { private static PrintStream getTraceOutputFile() { if (traceout == null) { if (tracefile != null) { - @SuppressWarnings("removal") - FileOutputStream o = AccessController.doPrivileged( - new PrivilegedAction() { - public FileOutputStream run() { - try { - return new FileOutputStream(tracefile); - } catch (FileNotFoundException e) { - return null; - } - } - }); + FileOutputStream o; + try { + o = new FileOutputStream(tracefile); + } catch (FileNotFoundException e) { + o = null; + } if (o != null) { traceout = new PrintStream(o); } else { @@ -425,17 +415,13 @@ public abstract class GraphicsPrimitive { } public static class TraceReporter implements Runnable { - @SuppressWarnings("removal") public static void setShutdownHook() { - AccessController.doPrivileged((PrivilegedAction) () -> { - TraceReporter t = new TraceReporter(); - Thread thread = new Thread( - ThreadGroupUtils.getRootThreadGroup(), t, - "TraceReporter", 0, false); - thread.setContextClassLoader(null); - Runtime.getRuntime().addShutdownHook(thread); - return null; - }); + TraceReporter t = new TraceReporter(); + Thread thread = new Thread( + ThreadGroupUtils.getRootThreadGroup(), t, + "TraceReporter", 0, false); + thread.setContextClassLoader(null); + Runtime.getRuntime().addShutdownHook(thread); } public void run() { diff --git a/src/java.desktop/share/classes/sun/java2d/marlin/DMarlinRenderingEngine.java b/src/java.desktop/share/classes/sun/java2d/marlin/DMarlinRenderingEngine.java index b29cc84c127..66eb9334e86 100644 --- a/src/java.desktop/share/classes/sun/java2d/marlin/DMarlinRenderingEngine.java +++ b/src/java.desktop/share/classes/sun/java2d/marlin/DMarlinRenderingEngine.java @@ -30,7 +30,6 @@ import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.Path2D; import java.awt.geom.PathIterator; -import java.security.AccessController; import java.util.Arrays; import sun.awt.geom.PathConsumer2D; import static sun.java2d.marlin.MarlinUtils.logInfo; @@ -40,7 +39,6 @@ import sun.java2d.ReentrantContextProviderTL; import sun.java2d.pipe.AATileGenerator; import sun.java2d.pipe.Region; import sun.java2d.pipe.RenderingEngine; -import sun.security.action.GetPropertyAction; /** * Marlin RendererEngine implementation (derived from Pisces) @@ -1119,10 +1117,8 @@ public final class DMarlinRenderingEngine extends RenderingEngine USE_THREAD_LOCAL = MarlinProperties.isUseThreadLocal(); // Soft reference by default: - @SuppressWarnings("removal") - final String refType = AccessController.doPrivileged( - new GetPropertyAction("sun.java2d.renderer.useRef", - "soft")); + final String refType = System.getProperty("sun.java2d.renderer.useRef", + "soft"); switch (refType) { default: case "soft": diff --git a/src/java.desktop/share/classes/sun/java2d/marlin/MarlinProperties.java b/src/java.desktop/share/classes/sun/java2d/marlin/MarlinProperties.java index ef919eba400..65122cae2a3 100644 --- a/src/java.desktop/share/classes/sun/java2d/marlin/MarlinProperties.java +++ b/src/java.desktop/share/classes/sun/java2d/marlin/MarlinProperties.java @@ -25,9 +25,7 @@ package sun.java2d.marlin; -import java.security.AccessController; import static sun.java2d.marlin.MarlinUtils.logInfo; -import sun.security.action.GetPropertyAction; public final class MarlinProperties { @@ -288,24 +286,18 @@ public final class MarlinProperties { } // system property utilities - @SuppressWarnings("removal") static String getString(final String key, final String def) { - return AccessController.doPrivileged( - new GetPropertyAction(key, def)); + return System.getProperty(key, def); } - @SuppressWarnings("removal") static boolean getBoolean(final String key, final String def) { - return Boolean.parseBoolean(AccessController.doPrivileged( - new GetPropertyAction(key, def))); + return Boolean.parseBoolean(System.getProperty(key, def)); } static int getInteger(final String key, final int def, final int min, final int max) { - @SuppressWarnings("removal") - final String property = AccessController.doPrivileged( - new GetPropertyAction(key)); + final String property = System.getProperty(key); int value = def; if (property != null) { @@ -334,9 +326,7 @@ public final class MarlinProperties { final double min, final double max) { double value = def; - @SuppressWarnings("removal") - final String property = AccessController.doPrivileged( - new GetPropertyAction(key)); + final String property = System.getProperty(key); if (property != null) { try { diff --git a/src/java.desktop/share/classes/sun/java2d/marlin/RendererStats.java b/src/java.desktop/share/classes/sun/java2d/marlin/RendererStats.java index 5517ce93f99..131f63afa65 100644 --- a/src/java.desktop/share/classes/sun/java2d/marlin/RendererStats.java +++ b/src/java.desktop/share/classes/sun/java2d/marlin/RendererStats.java @@ -25,8 +25,6 @@ package sun.java2d.marlin; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ConcurrentLinkedQueue; @@ -357,11 +355,8 @@ public final class RendererStats implements MarlinConst { private final ConcurrentLinkedQueue allStats = new ConcurrentLinkedQueue<>(); - @SuppressWarnings("removal") private RendererStatsHolder() { - AccessController.doPrivileged( - (PrivilegedAction) () -> { - final Thread hook = new Thread( + final Thread hook = new Thread( MarlinUtils.getRootThreadGroup(), new Runnable() { @Override @@ -371,21 +366,18 @@ public final class RendererStats implements MarlinConst { }, "MarlinStatsHook" ); - hook.setContextClassLoader(null); - Runtime.getRuntime().addShutdownHook(hook); + hook.setContextClassLoader(null); + Runtime.getRuntime().addShutdownHook(hook); - if (USE_DUMP_THREAD) { - final Timer statTimer = new Timer("RendererStats"); - statTimer.scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { - dump(); - } - }, DUMP_INTERVAL, DUMP_INTERVAL); + if (USE_DUMP_THREAD) { + final Timer statTimer = new Timer("RendererStats"); + statTimer.scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + dump(); } - return null; - } - ); + }, DUMP_INTERVAL, DUMP_INTERVAL); + } } void add(final Object parent, final RendererStats stats) { diff --git a/src/java.desktop/share/classes/sun/java2d/opengl/OGLRenderQueue.java b/src/java.desktop/share/classes/sun/java2d/opengl/OGLRenderQueue.java index 4b89aca5c85..8427bcd1a4f 100644 --- a/src/java.desktop/share/classes/sun/java2d/opengl/OGLRenderQueue.java +++ b/src/java.desktop/share/classes/sun/java2d/opengl/OGLRenderQueue.java @@ -30,8 +30,6 @@ import sun.java2d.pipe.RenderBuffer; import sun.java2d.pipe.RenderQueue; import static sun.java2d.pipe.BufferedOpCodes.*; -import java.security.AccessController; -import java.security.PrivilegedAction; /** * OGL-specific implementation of RenderQueue. This class provides a @@ -44,13 +42,12 @@ public class OGLRenderQueue extends RenderQueue { private static OGLRenderQueue theInstance; private final QueueFlusher flusher; - @SuppressWarnings("removal") private OGLRenderQueue() { /* * The thread must be a member of a thread group * which will not get GCed before VM exit. */ - flusher = AccessController.doPrivileged((PrivilegedAction) QueueFlusher::new); + flusher = new QueueFlusher(); } /** diff --git a/src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java b/src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java index 2f27515c204..501399c35a9 100644 --- a/src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java +++ b/src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java @@ -178,31 +178,19 @@ public abstract class OGLSurfaceData extends SurfaceData static { if (!GraphicsEnvironment.isHeadless()) { // fbobject currently enabled by default; use "false" to disable - @SuppressWarnings("removal") - String fbo = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction( - "sun.java2d.opengl.fbobject")); + String fbo = System.getProperty("sun.java2d.opengl.fbobject"); isFBObjectEnabled = !"false".equals(fbo); // lcdshader currently enabled by default; use "false" to disable - @SuppressWarnings("removal") - String lcd = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction( - "sun.java2d.opengl.lcdshader")); + String lcd = System.getProperty("sun.java2d.opengl.lcdshader"); isLCDShaderEnabled = !"false".equals(lcd); // biopshader currently enabled by default; use "false" to disable - @SuppressWarnings("removal") - String biop = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction( - "sun.java2d.opengl.biopshader")); + String biop = System.getProperty("sun.java2d.opengl.biopshader"); isBIOpShaderEnabled = !"false".equals(biop); // gradshader currently enabled by default; use "false" to disable - @SuppressWarnings("removal") - String grad = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction( - "sun.java2d.opengl.gradshader")); + String grad = System.getProperty("sun.java2d.opengl.gradshader"); isGradShaderEnabled = !"false".equals(grad); OGLRenderQueue rq = OGLRenderQueue.getInstance(); diff --git a/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java b/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java index e33eabd06b3..e6a5be7ca3b 100644 --- a/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java +++ b/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java @@ -30,9 +30,6 @@ import java.awt.BasicStroke; import java.awt.geom.PathIterator; import java.awt.geom.AffineTransform; -import java.security.AccessController; -import sun.security.action.GetPropertyAction; - import sun.awt.geom.PathConsumer2D; /** @@ -120,10 +117,7 @@ public abstract class RenderingEngine { /* Look first for an app-override renderer, * if not specified or present, then look for marlin. */ - GetPropertyAction gpa = - new GetPropertyAction("sun.java2d.renderer"); - @SuppressWarnings("removal") - String reClass = AccessController.doPrivileged(gpa); + String reClass = System.getProperty("sun.java2d.renderer"); if (reClass != null) { try { Class cls = Class.forName(reClass); @@ -144,16 +138,12 @@ public abstract class RenderingEngine { throw new InternalError("No RenderingEngine module found"); } - gpa = new GetPropertyAction("sun.java2d.renderer.verbose"); - @SuppressWarnings("removal") - String verbose = AccessController.doPrivileged(gpa); + String verbose = System.getProperty("sun.java2d.renderer.verbose"); if (verbose != null && verbose.startsWith("t")) { System.out.println("RenderingEngine = "+reImpl); } - gpa = new GetPropertyAction("sun.java2d.renderer.trace"); - @SuppressWarnings("removal") - String reTrace = AccessController.doPrivileged(gpa); + String reTrace = System.getProperty("sun.java2d.renderer.trace"); if (reTrace != null) { reImpl = new Tracer(reImpl); } diff --git a/src/java.desktop/share/classes/sun/print/PSPrinterJob.java b/src/java.desktop/share/classes/sun/print/PSPrinterJob.java index e64fb2cb0d5..a0f68a713aa 100644 --- a/src/java.desktop/share/classes/sun/print/PSPrinterJob.java +++ b/src/java.desktop/share/classes/sun/print/PSPrinterJob.java @@ -338,18 +338,9 @@ public class PSPrinterJob extends RasterPrinterJob { initStatic(); } - @SuppressWarnings("removal") private static void initStatic() { - //enable privileges so initProps can access system properties, - // open the property file, etc. - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - mFontProps = initProps(); - isMac = OSInfo.getOSType() == OSInfo.OSType.MACOSX; - return null; - } - }); + mFontProps = initProps(); + isMac = OSInfo.getOSType() == OSInfo.OSType.MACOSX; } /* @@ -512,7 +503,6 @@ public class PSPrinterJob extends RasterPrinterJob { * this method is called to mark the start of a * document. */ - @SuppressWarnings("removal") protected void startDoc() throws PrinterException { // A security check has been performed in the @@ -551,7 +541,7 @@ public class PSPrinterJob extends RasterPrinterJob { } } else { PrinterOpener po = new PrinterOpener(); - java.security.AccessController.doPrivileged(po); + po.run(); if (po.pex != null) { throw po.pex; } @@ -641,22 +631,16 @@ public class PSPrinterJob extends RasterPrinterJob { paperWidth + " "+ paperHeight+"]"); final PrintService pservice = getPrintService(); - Boolean isPS = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Boolean run() { - try { - Class psClass = Class.forName("sun.print.IPPPrintService"); - if (psClass.isInstance(pservice)) { - Method isPSMethod = psClass.getMethod("isPostscript", - (Class[])null); - return (Boolean)isPSMethod.invoke(pservice, (Object[])null); - } - } catch (Throwable t) { - } - return Boolean.TRUE; - } + Boolean isPS = Boolean.TRUE; + try { + Class psClass = Class.forName("sun.print.IPPPrintService"); + if (psClass.isInstance(pservice)) { + Method isPSMethod = psClass.getMethod("isPostscript", + (Class[])null); + isPS = (Boolean)isPSMethod.invoke(pservice, (Object[])null); } - ); + } catch (Throwable t) { + } if (isPS) { mPSStream.print(" /DeferredMediaSelection true"); } @@ -677,9 +661,9 @@ public class PSPrinterJob extends RasterPrinterJob { mPSStream.println("%%EndSetup"); } - // Inner class to run "privileged" to open the printer output stream. + // Inner class to open the printer output stream. - private class PrinterOpener implements java.security.PrivilegedAction { + private class PrinterOpener { PrinterException pex; OutputStream result; @@ -704,9 +688,9 @@ public class PSPrinterJob extends RasterPrinterJob { } } - // Inner class to run "privileged" to invoke the system print command + // Inner class to invoke the system print command - private class PrinterSpooler implements java.security.PrivilegedAction { + private class PrinterSpooler { PrinterException pex; private void handleProcessFailure(final Process failedProcess, @@ -767,21 +751,13 @@ public class PSPrinterJob extends RasterPrinterJob { /** * Invoked if the application cancelled the printjob. */ - @SuppressWarnings("removal") protected void abortDoc() { if (mPSStream != null && mDestType != RasterPrinterJob.STREAM) { mPSStream.close(); } - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - - public Object run() { - if (spoolFile != null && spoolFile.exists()) { - spoolFile.delete(); - } - return null; - } - }); + if (spoolFile != null && spoolFile.exists()) { + spoolFile.delete(); + } } /** @@ -789,7 +765,6 @@ public class PSPrinterJob extends RasterPrinterJob { * this method is called after that last page * has been imaged. */ - @SuppressWarnings("removal") protected void endDoc() throws PrinterException { if (mPSStream != null) { mPSStream.println(EOF_COMMENT); @@ -814,7 +789,7 @@ public class PSPrinterJob extends RasterPrinterJob { } } PrinterSpooler spooler = new PrinterSpooler(); - java.security.AccessController.doPrivileged(spooler); + spooler.run(); if (spooler.pex != null) { throw spooler.pex; } @@ -859,28 +834,18 @@ public class PSPrinterJob extends RasterPrinterJob { paperWidth + " " + paperHeight + "]"); final PrintService pservice = getPrintService(); - @SuppressWarnings("removal") - Boolean isPS = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Boolean run() { - try { - Class psClass = - Class.forName("sun.print.IPPPrintService"); - if (psClass.isInstance(pservice)) { - Method isPSMethod = - psClass.getMethod("isPostscript", - (Class[])null); - return (Boolean) - isPSMethod.invoke(pservice, + Boolean isPS = Boolean.TRUE; + try { + Class psClass = Class.forName("sun.print.IPPPrintService"); + if (psClass.isInstance(pservice)) { + Method isPSMethod = + psClass.getMethod("isPostscript", + (Class[])null); + isPS = (Boolean) isPSMethod.invoke(pservice, (Object[])null); - } - } catch (Throwable t) { - } - return Boolean.TRUE; - } - } - ); - + } + } catch (Throwable t) { + } if (isPS) { mPSStream.print(" /DeferredMediaSelection true"); } diff --git a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java index 82f47824bfa..bf380873d2b 100644 --- a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java +++ b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java @@ -174,9 +174,7 @@ public abstract class RasterPrinterJob extends PrinterJob { * use a particular pipeline. Either the raster * pipeline or the pdl pipeline can be forced. */ - @SuppressWarnings("removal") - String forceStr = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction(FORCE_PIPE_PROP)); + String forceStr = System.getProperty(FORCE_PIPE_PROP); if (forceStr != null) { if (forceStr.equalsIgnoreCase(FORCE_PDL)) { @@ -186,9 +184,7 @@ public abstract class RasterPrinterJob extends PrinterJob { } } - @SuppressWarnings("removal") - String shapeTextStr =java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction(SHAPE_TEXT_PROP)); + String shapeTextStr = System.getProperty(SHAPE_TEXT_PROP); if (shapeTextStr != null) { shapeTextProp = true; @@ -731,20 +727,9 @@ public abstract class RasterPrinterJob extends PrinterJob { GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().getDefaultConfiguration(); - @SuppressWarnings("removal") - PrintService service = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public PrintService run() { - PrintService service = getPrintService(); - if (service == null) { - ServiceDialog.showNoPrintService(gc); - return null; - } - return service; - } - }); - + PrintService service = getPrintService(); if (service == null) { + ServiceDialog.showNoPrintService(gc); return page; } updatePageAttributes(service, page); @@ -812,20 +797,9 @@ public abstract class RasterPrinterJob extends PrinterJob { } final GraphicsConfiguration gc = grCfg; - @SuppressWarnings("removal") - PrintService service = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public PrintService run() { - PrintService service = getPrintService(); - if (service == null) { - ServiceDialog.showNoPrintService(gc); - return null; - } - return service; - } - }); - + PrintService service = getPrintService(); if (service == null) { + ServiceDialog.showNoPrintService(gc); return null; } @@ -953,7 +927,6 @@ public abstract class RasterPrinterJob extends PrinterJob { * returns true. * @see java.awt.GraphicsEnvironment#isHeadless */ - @SuppressWarnings("removal") public boolean printDialog(final PrintRequestAttributeSet attributes) throws HeadlessException { if (GraphicsEnvironment.isHeadless()) { @@ -1008,19 +981,9 @@ public abstract class RasterPrinterJob extends PrinterJob { } final GraphicsConfiguration gc = grCfg; - PrintService service = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public PrintService run() { - PrintService service = getPrintService(); - if (service == null) { - ServiceDialog.showNoPrintService(gc); - return null; - } - return service; - } - }); - + PrintService service = getPrintService(); if (service == null) { + ServiceDialog.showNoPrintService(gc); return false; } @@ -1033,13 +996,7 @@ public abstract class RasterPrinterJob extends PrinterJob { services[i] = spsFactories[i].getPrintService(null); } } else { - services = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public PrintService[] run() { - PrintService[] services = PrinterJob.lookupPrintServices(); - return services; - } - }); + services = PrinterJob.lookupPrintServices(); if ((services == null) || (services.length == 0)) { /* diff --git a/src/java.desktop/share/classes/sun/print/ServiceDialog.java b/src/java.desktop/share/classes/sun/print/ServiceDialog.java index 983be70bdbb..ae2c787ce36 100644 --- a/src/java.desktop/share/classes/sun/print/ServiceDialog.java +++ b/src/java.desktop/share/classes/sun/print/ServiceDialog.java @@ -448,21 +448,13 @@ public class ServiceDialog extends JDialog implements ActionListener { /** * Initialize ResourceBundle */ - @SuppressWarnings("removal") public static void initResource() { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - try { - messageRB = ResourceBundle.getBundle(strBundle); - return null; - } catch (java.util.MissingResourceException e) { - throw new Error("Fatal: Resource for ServiceUI " + - "is missing"); - } - } - } - ); + try { + messageRB = ResourceBundle.getBundle(strBundle); + } catch (java.util.MissingResourceException e) { + throw new Error("Fatal: Resource for ServiceUI " + + "is missing"); + } } /** @@ -542,15 +534,7 @@ public class ServiceDialog extends JDialog implements ActionListener { * Returns URL for image resource */ private static URL getImageResource(final String key) { - @SuppressWarnings("removal") - URL url = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public URL run() { - URL url = ServiceDialog.class.getResource( - "resources/" + key); - return url; - } - }); + URL url = ServiceDialog.class.getResource("resources/" + key); if (url == null) { throw new Error("Fatal: Resource for ServiceUI is broken; " + @@ -2943,14 +2927,7 @@ public class ServiceDialog extends JDialog implements ActionListener { { super(new FlowLayout(FlowLayout.LEADING)); final URL imgURL = getImageResource(img); - @SuppressWarnings("removal") - Icon icon = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Icon run() { - Icon icon = new ImageIcon(imgURL); - return icon; - } - }); + Icon icon = new ImageIcon(imgURL); lbl = new JLabel(icon); add(lbl); diff --git a/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java b/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java index d83b940a0bd..8e4b0ff3f7c 100644 --- a/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java +++ b/src/java.desktop/share/classes/sun/swing/JLightweightFrame.java @@ -40,7 +40,6 @@ import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.security.AccessController; import javax.swing.JComponent; import javax.swing.JLayeredPane; @@ -55,7 +54,6 @@ import sun.awt.AWTAccessor; import sun.awt.DisplayChangedListener; import sun.awt.LightweightFrame; import sun.awt.OverrideNativeWindowHandle; -import sun.security.action.GetPropertyAction; import sun.swing.SwingUtilities2.RepaintListener; /** @@ -105,24 +103,21 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan * by the lock (managed with the {@link LightweightContent#paintLock()}, * {@link LightweightContent#paintUnlock()} methods). */ - @SuppressWarnings("removal") - private static boolean copyBufferEnabled = "true".equals(AccessController. - doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true"))); + private static boolean copyBufferEnabled = "true".equals( + System.getProperty("swing.jlf.copyBufferEnabled", "true")); private int[] copyBuffer; /** * Constructs a new, initially invisible {@code JLightweightFrame} * instance. */ - @SuppressWarnings("removal") public JLightweightFrame() { super(); AffineTransform defaultTransform = getGraphicsConfiguration().getDefaultTransform(); scaleFactorX = defaultTransform.getScaleX(); scaleFactorY = defaultTransform.getScaleY(); - copyBufferEnabled = "true".equals(AccessController. - doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true"))); + copyBufferEnabled = "true".equals(System.getProperty("swing.jlf.copyBufferEnabled", "true")); add(rootPane, BorderLayout.CENTER); setFocusTraversalPolicy(new LayoutFocusTraversalPolicy()); @@ -331,7 +326,6 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan content.imageUpdated(x, y, width, height); } - @SuppressWarnings("removal") private void initInterior() { contentPane = new JPanel() { @Override @@ -392,8 +386,7 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan contentPane.add(component); contentPane.revalidate(); contentPane.repaint(); - if ("true".equals(AccessController. - doPrivileged(new GetPropertyAction("swing.jlf.contentPaneTransparent", "false")))) + if ("true".equals(System.getProperty("swing.jlf.contentPaneTransparent", "false"))) { contentPane.setOpaque(false); } diff --git a/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java b/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java index d763a72d528..2613ca326ea 100644 --- a/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java +++ b/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java @@ -61,8 +61,6 @@ import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Modifier; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.text.AttributedCharacterIterator; import java.text.AttributedString; import java.text.BreakIterator; @@ -1706,10 +1704,8 @@ public class SwingUtilities2 { final String imageFile, final boolean enablePrivileges) { return (UIDefaults.LazyValue) (table) -> { - @SuppressWarnings("removal") - byte[] buffer = enablePrivileges ? AccessController.doPrivileged( - (PrivilegedAction) () - -> getIconBytes(baseClass, rootClass, imageFile)) + byte[] buffer = enablePrivileges ? + getIconBytes(baseClass, rootClass, imageFile) : getIconBytes(baseClass, rootClass, imageFile); if (buffer == null) {