8344060: Remove doPrivileged calls from shared implementation code in the java.desktop module : part 1

Reviewed-by: aivanov, prr
This commit is contained in:
Prasanta Sadhukhan 2024-11-20 09:11:12 +00:00
parent 587f2b4b4d
commit 5b12a87dcb
26 changed files with 166 additions and 477 deletions

View File

@ -79,7 +79,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.URL; import java.net.URL;
import java.security.AccessController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Locale; import java.util.Locale;
@ -100,8 +99,6 @@ import sun.awt.image.ToolkitImage;
import sun.awt.image.URLImageSource; import sun.awt.image.URLImageSource;
import sun.font.FontDesignMetrics; import sun.font.FontDesignMetrics;
import sun.net.util.URLUtil; import sun.net.util.URLUtil;
import sun.security.action.GetBooleanAction;
import sun.security.action.GetPropertyAction;
import sun.util.logging.PlatformLogger; import sun.util.logging.PlatformLogger;
import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING; import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING;
@ -122,14 +119,12 @@ public abstract class SunToolkit extends Toolkit
initStatic(); initStatic();
} }
@SuppressWarnings("removal")
private static void initStatic() { private static void initStatic() {
if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.nativedebug"))) { if (Boolean.getBoolean("sun.awt.nativedebug")) {
DebugSettings.init(); DebugSettings.init();
} }
touchKeyboardAutoShowIsEnabled = Boolean.parseBoolean( touchKeyboardAutoShowIsEnabled = Boolean.parseBoolean(
GetPropertyAction.privilegedGetProperty( System.getProperty("awt.touchKeyboardAutoShowIsEnabled", "true"));
"awt.touchKeyboardAutoShowIsEnabled", "true"));
} }
/** /**
@ -231,9 +226,8 @@ public abstract class SunToolkit extends Toolkit
* } * }
*/ */
@SuppressWarnings("removal")
private static final ReentrantLock AWT_LOCK = new ReentrantLock( 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(); private static final Condition AWT_LOCK_COND = AWT_LOCK.newCondition();
public static final void awtLock() { public static final void awtLock() {
@ -672,18 +666,16 @@ public abstract class SunToolkit extends Toolkit
* Returns the value of "sun.awt.noerasebackground" property. Default * Returns the value of "sun.awt.noerasebackground" property. Default
* value is {@code false}. * value is {@code false}.
*/ */
@SuppressWarnings("removal")
public static boolean getSunAwtNoerasebackground() { 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 * Returns the value of "sun.awt.erasebackgroundonresize" property. Default
* value is {@code false}. * value is {@code false}.
*/ */
@SuppressWarnings("removal")
public static boolean getSunAwtErasebackgroundonresize() { 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. * Returns the locale in which the runtime was started.
*/ */
@SuppressWarnings("removal")
public static Locale getStartupLocale() { public static Locale getStartupLocale() {
if (startupLocale == null) { if (startupLocale == null) {
String language, region, country, variant; String language, region, country, variant;
language = AccessController.doPrivileged( language = System.getProperty("user.language", "en");
new GetPropertyAction("user.language", "en"));
// for compatibility, check for old user.region property // for compatibility, check for old user.region property
region = AccessController.doPrivileged( region = System.getProperty("user.region");
new GetPropertyAction("user.region"));
if (region != null) { if (region != null) {
// region can be of form country, country_variant, or _variant // region can be of form country, country_variant, or _variant
int i = region.indexOf('_'); int i = region.indexOf('_');
@ -1177,10 +1166,8 @@ public abstract class SunToolkit extends Toolkit
variant = ""; variant = "";
} }
} else { } else {
country = AccessController.doPrivileged( country = System.getProperty("user.country", "");
new GetPropertyAction("user.country", "")); variant = System.getProperty("user.variant", "");
variant = AccessController.doPrivileged(
new GetPropertyAction("user.variant", ""));
} }
startupLocale = Locale.of(language, country, 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 * @return {@code true}, if XEmbed is needed, {@code false} otherwise
*/ */
public static boolean needsXEmbed() { public static boolean needsXEmbed() {
@SuppressWarnings("removal") String noxembed = System.getProperty("sun.awt.noxembed", "false");
String noxembed = AccessController.
doPrivileged(new GetPropertyAction("sun.awt.noxembed", "false"));
if ("true".equals(noxembed)) { if ("true".equals(noxembed)) {
return false; return false;
} }
@ -1235,9 +1220,8 @@ public abstract class SunToolkit extends Toolkit
* developer. If true, Toolkit should return an * developer. If true, Toolkit should return an
* XEmbed-server-enabled CanvasPeer instead of the ordinary CanvasPeer. * XEmbed-server-enabled CanvasPeer instead of the ordinary CanvasPeer.
*/ */
@SuppressWarnings("removal")
protected final boolean isXEmbedServerRequested() { 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 * to be inapplicable in that case. In that headless case although
* this method will return "true" the toolkit will return a null map. * this method will return "true" the toolkit will return a null map.
*/ */
@SuppressWarnings("removal")
private static boolean useSystemAAFontSettings() { private static boolean useSystemAAFontSettings() {
if (!checkedSystemAAFontSettings) { if (!checkedSystemAAFontSettings) {
useSystemAAFontSettings = true; /* initially set this true */ useSystemAAFontSettings = true; /* initially set this true */
String systemAAFonts = null; String systemAAFonts = null;
Toolkit tk = Toolkit.getDefaultToolkit(); Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) { if (tk instanceof SunToolkit) {
systemAAFonts = systemAAFonts = System.getProperty("awt.useSystemAAFontSettings");
AccessController.doPrivileged(
new GetPropertyAction("awt.useSystemAAFontSettings"));
} }
if (systemAAFonts != null) { if (systemAAFonts != null) {
useSystemAAFontSettings = Boolean.parseBoolean(systemAAFonts); useSystemAAFontSettings = Boolean.parseBoolean(systemAAFonts);
@ -1859,11 +1840,9 @@ public abstract class SunToolkit extends Toolkit
* Returns the value of "sun.awt.disableMixing" property. Default * Returns the value of "sun.awt.disableMixing" property. Default
* value is {@code false}. * value is {@code false}.
*/ */
@SuppressWarnings("removal")
public static synchronized boolean getSunAwtDisableMixing() { public static synchronized boolean getSunAwtDisableMixing() {
if (sunAwtDisableMixing == null) { if (sunAwtDisableMixing == null) {
sunAwtDisableMixing = AccessController.doPrivileged( sunAwtDisableMixing = Boolean.getBoolean("sun.awt.disableMixing");
new GetBooleanAction("sun.awt.disableMixing"));
} }
return sunAwtDisableMixing.booleanValue(); return sunAwtDisableMixing.booleanValue();
} }

View File

@ -159,18 +159,11 @@ public abstract class ImageDecoder {
public abstract void produceImage() throws IOException, public abstract void produceImage() throws IOException,
ImageFormatException; ImageFormatException;
@SuppressWarnings("removal")
public void abort() { public void abort() {
aborted = true; aborted = true;
source.doneDecoding(this); source.doneDecoding(this);
close(); close();
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
feeder.interrupt(); feeder.interrupt();
return null;
}
});
} }
public synchronized void close() { public synchronized void close() {

View File

@ -276,7 +276,6 @@ class ImageFetcher extends Thread {
/** /**
* Create and start ImageFetcher threads in the appropriate ThreadGroup. * Create and start ImageFetcher threads in the appropriate ThreadGroup.
*/ */
@SuppressWarnings("removal")
private static void createFetchers(final FetcherInfo info) { private static void createFetchers(final FetcherInfo info) {
// We need to instantiate a new ImageFetcher thread. // We need to instantiate a new ImageFetcher thread.
// First, figure out which ThreadGroup we'll put the // First, figure out which ThreadGroup we'll put the
@ -310,9 +309,6 @@ class ImageFetcher extends Thread {
} }
final ThreadGroup fetcherGroup = fetcherThreadGroup; final ThreadGroup fetcherGroup = fetcherThreadGroup;
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
for (int i = 0; i < info.fetchers.length; i++) { for (int i = 0; i < info.fetchers.length; i++) {
if (info.fetchers[i] == null) { if (info.fetchers[i] == null) {
ImageFetcher f = new ImageFetcher(fetcherGroup, i); ImageFetcher f = new ImageFetcher(fetcherGroup, i);
@ -325,10 +321,6 @@ class ImageFetcher extends Thread {
} }
} }
} }
return null;
}
});
return;
} }
} }

View File

@ -29,10 +29,6 @@ import java.lang.ref.WeakReference;
import java.awt.Image; import java.awt.Image;
import java.awt.image.ImageObserver; import java.awt.image.ImageObserver;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
public abstract class ImageWatched { public abstract class ImageWatched {
public static Link endlink = new Link(); public static Link endlink = new Link();
@ -89,28 +85,16 @@ public abstract class ImageWatched {
} }
} }
static class AccWeakReference<T> extends WeakReference<T> {
@SuppressWarnings("removal")
private final AccessControlContext acc;
@SuppressWarnings("removal")
AccWeakReference(T ref) {
super(ref);
acc = AccessController.getContext();
}
}
/* /*
* Standard Link implementation to manage a Weak Reference * Standard Link implementation to manage a Weak Reference
* to an ImageObserver. * to an ImageObserver.
*/ */
public static class WeakLink extends Link { public static class WeakLink extends Link {
private final AccWeakReference<ImageObserver> myref; private final WeakReference<ImageObserver> myref;
private Link next; private Link next;
public WeakLink(ImageObserver obs, Link next) { public WeakLink(ImageObserver obs, Link next) {
myref = new AccWeakReference<ImageObserver>(obs); myref = new WeakReference<ImageObserver>(obs);
this.next = next; this.next = next;
} }
@ -136,20 +120,6 @@ public abstract class ImageWatched {
return this; 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<Boolean>) () -> {
return iw.imageUpdate(img, info, x, y, w, h);
}, acc);
}
return false;
}
public boolean newInfo(Image img, int info, public boolean newInfo(Image img, int info,
int x, int y, int w, int h) int x, int y, int w, int h)
{ {
@ -159,7 +129,7 @@ public abstract class ImageWatched {
if (myiw == null) { if (myiw == null) {
// My referent is null so we must prune in a second pass. // My referent is null so we must prune in a second pass.
ret = true; 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 // My referent has lost interest so clear it and ask
// for a pruning pass to remove it later. // for a pruning pass to remove it later.
myref.clear(); myref.clear();

View File

@ -37,8 +37,6 @@ import java.awt.image.LookupTable;
import java.awt.image.RasterOp; import java.awt.image.RasterOp;
import java.awt.image.Raster; import java.awt.image.Raster;
import java.awt.image.WritableRaster; import java.awt.image.WritableRaster;
import java.security.AccessController;
import java.security.PrivilegedAction;
/** /**
* This class provides a hook to access platform-specific * 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 * (in which case our java code will be executed) or may throw
* an exception. * an exception.
*/ */
@SuppressWarnings({"removal", "restricted"}) @SuppressWarnings("restricted")
public class ImagingLib { public class ImagingLib {
static boolean useLib = true; static boolean useLib = true;
@ -90,20 +88,14 @@ public class ImagingLib {
static { static {
PrivilegedAction<Boolean> doMlibInitialization = boolean success = false;
new PrivilegedAction<Boolean>() {
public Boolean run() {
try { try {
System.loadLibrary("mlib_image"); System.loadLibrary("mlib_image");
success = init();
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {
return Boolean.FALSE;
} }
boolean success = init();
return Boolean.valueOf(success);
}
};
useLib = AccessController.doPrivileged(doMlibInitialization); useLib = success;
// //
// Cache the class references of the operations we know about // Cache the class references of the operations we know about

View File

@ -42,7 +42,7 @@ import java.awt.image.*;
* *
* @author Jim Graham * @author Jim Graham
*/ */
@SuppressWarnings({"removal", "restricted"}) @SuppressWarnings("restricted")
public class JPEGImageDecoder extends ImageDecoder { public class JPEGImageDecoder extends ImageDecoder {
private static ColorModel RGBcolormodel; private static ColorModel RGBcolormodel;
private static ColorModel ARGBcolormodel; private static ColorModel ARGBcolormodel;
@ -54,13 +54,7 @@ public class JPEGImageDecoder extends ImageDecoder {
private ColorModel colormodel; private ColorModel colormodel;
static { static {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("javajpeg"); System.loadLibrary("javajpeg");
return null;
}
});
initIDs(InputStreamClass); initIDs(InputStreamClass);
RGBcolormodel = new DirectColorModel(24, 0xff0000, 0xff00, 0xff); RGBcolormodel = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
ARGBcolormodel = ColorModel.getRGBdefault(); ARGBcolormodel = ColorModel.getRGBdefault();

View File

@ -52,14 +52,8 @@ class NativeLibLoader {
* For now, we know it's done by the implementation, and we assume * For now, we know it's done by the implementation, and we assume
* that the name of the library is "awt". -br. * that the name of the library is "awt". -br.
*/ */
@SuppressWarnings({"removal", "restricted"}) @SuppressWarnings("restricted")
static void loadLibraries() { static void loadLibraries() {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt"); System.loadLibrary("awt");
return null;
}
});
} }
} }

View File

@ -35,11 +35,8 @@ public abstract class VSyncedBSManager {
private static VSyncedBSManager theInstance; private static VSyncedBSManager theInstance;
@SuppressWarnings("removal")
private static final boolean vSyncLimit = private static final boolean vSyncLimit =
Boolean.parseBoolean(java.security.AccessController.doPrivileged( Boolean.parseBoolean(System.getProperty("sun.java2d.vsynclimit", "true"));
new sun.security.action.GetPropertyAction(
"sun.java2d.vsynclimit", "true")));
private static VSyncedBSManager getInstance(boolean create) { private static VSyncedBSManager getInstance(boolean create) {
if (theInstance == null && create) { if (theInstance == null && create) {

View File

@ -72,7 +72,6 @@ import java.io.Writer;
* exist once those APIs are in place. * exist once those APIs are in place.
* @author Chet Haase * @author Chet Haase
*/ */
@SuppressWarnings("removal")
public class PerformanceLogger { public class PerformanceLogger {
// Timing values of global interest // Timing values of global interest
@ -87,16 +86,12 @@ public class PerformanceLogger {
private static long baseTime; private static long baseTime;
static { static {
String perfLoggingProp = String perfLoggingProp = System.getProperty("sun.perflog");
java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.perflog"));
if (perfLoggingProp != null) { if (perfLoggingProp != null) {
perfLoggingOn = true; perfLoggingOn = true;
// Check if we should use nanoTime // Check if we should use nanoTime
String perfNanoProp = String perfNanoProp = System.getProperty("sun.perflog.nano");
java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.perflog.nano"));
if (perfNanoProp != null) { if (perfNanoProp != null) {
useNanoTime = true; useNanoTime = true;
} }
@ -107,9 +102,6 @@ public class PerformanceLogger {
} }
if (logFileName != null) { if (logFileName != null) {
if (logWriter == null) { if (logWriter == null) {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
try { try {
File logFile = new File(logFileName); File logFile = new File(logFileName);
logFile.createNewFile(); logFile.createNewFile();
@ -119,9 +111,6 @@ public class PerformanceLogger {
logFileName + logFileName +
". Log to console"); ". Log to console");
} }
return null;
}
});
} }
} }
if (logWriter == null) { if (logWriter == null) {

View File

@ -31,8 +31,6 @@ import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue; import java.lang.ref.ReferenceQueue;
import java.lang.ref.PhantomReference; import java.lang.ref.PhantomReference;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ConcurrentLinkedDeque;
@ -50,7 +48,7 @@ import java.util.concurrent.ConcurrentLinkedDeque;
* *
* @see DisposerRecord * @see DisposerRecord
*/ */
@SuppressWarnings({"removal", "restricted"}) @SuppressWarnings("restricted")
public class Disposer implements Runnable { public class Disposer implements Runnable {
private static final ReferenceQueue<Object> queue = new ReferenceQueue<>(); private static final ReferenceQueue<Object> queue = new ReferenceQueue<>();
private static final Hashtable<java.lang.ref.Reference<Object>, DisposerRecord> records = private static final Hashtable<java.lang.ref.Reference<Object>, DisposerRecord> records =
@ -62,16 +60,9 @@ public class Disposer implements Runnable {
public static int refType = PHANTOM; public static int refType = PHANTOM;
static { static {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt"); System.loadLibrary("awt");
return null;
}
});
initIDs(); initIDs();
String type = java.security.AccessController.doPrivileged( String type = System.getProperty("sun.java2d.reftype");
new sun.security.action.GetPropertyAction("sun.java2d.reftype"));
if (type != null) { if (type != null) {
if (type.equals("weak")) { if (type.equals("weak")) {
refType = WEAK; refType = WEAK;
@ -82,7 +73,6 @@ public class Disposer implements Runnable {
} }
} }
disposerInstance = new Disposer(); disposerInstance = new Disposer();
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
String name = "Java2D Disposer"; String name = "Java2D Disposer";
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup(); ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
Thread t = new Thread(rootTG, disposerInstance, name, 0, false); Thread t = new Thread(rootTG, disposerInstance, name, 0, false);
@ -90,8 +80,6 @@ public class Disposer implements Runnable {
t.setDaemon(true); t.setDaemon(true);
t.setPriority(Thread.MAX_PRIORITY); t.setPriority(Thread.MAX_PRIORITY);
t.start(); t.start();
return null;
});
} }
/** /**

View File

@ -40,7 +40,6 @@ import java.awt.Toolkit;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.peer.ComponentPeer; import java.awt.peer.ComponentPeer;
import java.security.AccessController;
import java.util.Locale; import java.util.Locale;
import java.util.TreeMap; import java.util.TreeMap;
@ -50,7 +49,6 @@ import sun.font.FontManager;
import sun.font.FontManagerFactory; import sun.font.FontManagerFactory;
import sun.font.FontManagerForSGE; import sun.font.FontManagerForSGE;
import sun.java2d.pipe.Region; import sun.java2d.pipe.Region;
import sun.security.action.GetPropertyAction;
/** /**
* This is an implementation of a GraphicsEnvironment object for the * 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. */ /** Establish the default font to be used by SG2D. */
private final Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12); private final Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
@SuppressWarnings("removal")
private static final boolean uiScaleEnabled private static final boolean uiScaleEnabled
= "true".equals(AccessController.doPrivileged( = "true".equals(System.getProperty("sun.java2d.uiScale.enabled", "true"));
new GetPropertyAction("sun.java2d.uiScale.enabled", "true")));
private static final double debugScale = private static final double debugScale =
uiScaleEnabled ? getScaleFactor("sun.java2d.uiScale") : -1; uiScaleEnabled ? getScaleFactor("sun.java2d.uiScale") : -1;
@ -293,9 +289,7 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
public static double getScaleFactor(String propertyName) { public static double getScaleFactor(String propertyName) {
@SuppressWarnings("removal") String scaleFactor = System.getProperty(propertyName, "-1");
String scaleFactor = AccessController.doPrivileged(
new GetPropertyAction(propertyName, "-1"));
if (scaleFactor == null || scaleFactor.equals("-1")) { if (scaleFactor == null || scaleFactor.equals("-1")) {
return -1; return -1;

View File

@ -38,9 +38,6 @@ import sun.java2d.loops.Blit;
import sun.java2d.loops.BlitBg; import sun.java2d.loops.BlitBg;
import sun.awt.image.SurfaceManager; import sun.awt.image.SurfaceManager;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
/** /**
* The proxy class encapsulates the logic for managing alternate * The proxy class encapsulates the logic for managing alternate
* SurfaceData representations of a primary SurfaceData. * SurfaceData representations of a primary SurfaceData.
@ -70,18 +67,14 @@ public abstract class SurfaceDataProxy
static { static {
cachingAllowed = true; cachingAllowed = true;
@SuppressWarnings("removal") String manimg = System.getProperty("sun.java2d.managedimages");
String manimg = AccessController.doPrivileged(
new GetPropertyAction("sun.java2d.managedimages"));
if ("false".equals(manimg)) { if ("false".equals(manimg)) {
cachingAllowed = false; cachingAllowed = false;
System.out.println("Disabling managed images"); System.out.println("Disabling managed images");
} }
defaultThreshold = 1; defaultThreshold = 1;
@SuppressWarnings("removal") String num = System.getProperty("sun.java2d.accthreshold");
String num = AccessController.doPrivileged(
new GetPropertyAction("sun.java2d.accthreshold"));
if (num != null) { if (num != null) {
try { try {
int parsed = Integer.parseInt(num); int parsed = Integer.parseInt(num);

View File

@ -27,9 +27,6 @@ package sun.java2d.cmm;
import java.awt.color.CMMException; import java.awt.color.CMMException;
import java.awt.color.ICC_Profile; import java.awt.color.ICC_Profile;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
public final class CMSManager { public final class CMSManager {
@ -45,9 +42,7 @@ public final class CMSManager {
return cmmImpl; return cmmImpl;
} }
GetPropertyAction gpa = new GetPropertyAction("sun.java2d.cmm"); String cmmProviderClass = System.getProperty("sun.java2d.cmm");
@SuppressWarnings("removal")
String cmmProviderClass = AccessController.doPrivileged(gpa);
CMMServiceProvider provider = null; CMMServiceProvider provider = null;
if (cmmProviderClass != null) { if (cmmProviderClass != null) {
try { try {
@ -67,9 +62,7 @@ public final class CMSManager {
"No CM module found"); "No CM module found");
} }
gpa = new GetPropertyAction("sun.java2d.cmm.trace"); String cmmTrace = System.getProperty("sun.java2d.cmm.trace");
@SuppressWarnings("removal")
String cmmTrace = AccessController.doPrivileged(gpa);
if (cmmTrace != null) { if (cmmTrace != null) {
cmmImpl = new CMMTracer(cmmImpl); cmmImpl = new CMMTracer(cmmImpl);
} }

View File

@ -143,23 +143,17 @@ final class LCMS implements PCMM {
private static LCMS theLcms = null; private static LCMS theLcms = null;
@SuppressWarnings({"removal", "restricted"}) @SuppressWarnings("restricted")
static synchronized PCMM getModule() { static synchronized PCMM getModule() {
if (theLcms != null) { if (theLcms != null) {
return theLcms; return theLcms;
} }
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
/* We need to load awt here because of usage trace and /* We need to load awt here because of usage trace and
* disposer frameworks * disposer frameworks
*/ */
System.loadLibrary("awt"); System.loadLibrary("awt");
System.loadLibrary("lcms"); System.loadLibrary("lcms");
return null;
}
});
theLcms = new LCMS(); theLcms = new LCMS();

View File

@ -36,8 +36,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.StringTokenizer; import java.util.StringTokenizer;
@ -46,7 +44,6 @@ import sun.awt.image.BufImgSurfaceData;
import sun.awt.util.ThreadGroupUtils; import sun.awt.util.ThreadGroupUtils;
import sun.java2d.SurfaceData; import sun.java2d.SurfaceData;
import sun.java2d.pipe.Region; import sun.java2d.pipe.Region;
import sun.security.action.GetPropertyAction;
/** /**
* defines interface for primitives which can be placed into * defines interface for primitives which can be placed into
@ -336,9 +333,7 @@ public abstract class GraphicsPrimitive {
public static final int TRACECOUNTS = 4; public static final int TRACECOUNTS = 4;
static { static {
GetPropertyAction gpa = new GetPropertyAction("sun.java2d.trace"); String trace = System.getProperty("sun.java2d.trace");
@SuppressWarnings("removal")
String trace = AccessController.doPrivileged(gpa);
if (trace != null) { if (trace != null) {
boolean verbose = false; boolean verbose = false;
int traceflags = 0; int traceflags = 0;
@ -401,17 +396,12 @@ public abstract class GraphicsPrimitive {
private static PrintStream getTraceOutputFile() { private static PrintStream getTraceOutputFile() {
if (traceout == null) { if (traceout == null) {
if (tracefile != null) { if (tracefile != null) {
@SuppressWarnings("removal") FileOutputStream o;
FileOutputStream o = AccessController.doPrivileged(
new PrivilegedAction<FileOutputStream>() {
public FileOutputStream run() {
try { try {
return new FileOutputStream(tracefile); o = new FileOutputStream(tracefile);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
return null; o = null;
} }
}
});
if (o != null) { if (o != null) {
traceout = new PrintStream(o); traceout = new PrintStream(o);
} else { } else {
@ -425,17 +415,13 @@ public abstract class GraphicsPrimitive {
} }
public static class TraceReporter implements Runnable { public static class TraceReporter implements Runnable {
@SuppressWarnings("removal")
public static void setShutdownHook() { public static void setShutdownHook() {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
TraceReporter t = new TraceReporter(); TraceReporter t = new TraceReporter();
Thread thread = new Thread( Thread thread = new Thread(
ThreadGroupUtils.getRootThreadGroup(), t, ThreadGroupUtils.getRootThreadGroup(), t,
"TraceReporter", 0, false); "TraceReporter", 0, false);
thread.setContextClassLoader(null); thread.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(thread); Runtime.getRuntime().addShutdownHook(thread);
return null;
});
} }
public void run() { public void run() {

View File

@ -30,7 +30,6 @@ import java.awt.Shape;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.geom.Path2D; import java.awt.geom.Path2D;
import java.awt.geom.PathIterator; import java.awt.geom.PathIterator;
import java.security.AccessController;
import java.util.Arrays; import java.util.Arrays;
import sun.awt.geom.PathConsumer2D; import sun.awt.geom.PathConsumer2D;
import static sun.java2d.marlin.MarlinUtils.logInfo; import static sun.java2d.marlin.MarlinUtils.logInfo;
@ -40,7 +39,6 @@ import sun.java2d.ReentrantContextProviderTL;
import sun.java2d.pipe.AATileGenerator; import sun.java2d.pipe.AATileGenerator;
import sun.java2d.pipe.Region; import sun.java2d.pipe.Region;
import sun.java2d.pipe.RenderingEngine; import sun.java2d.pipe.RenderingEngine;
import sun.security.action.GetPropertyAction;
/** /**
* Marlin RendererEngine implementation (derived from Pisces) * Marlin RendererEngine implementation (derived from Pisces)
@ -1119,10 +1117,8 @@ public final class DMarlinRenderingEngine extends RenderingEngine
USE_THREAD_LOCAL = MarlinProperties.isUseThreadLocal(); USE_THREAD_LOCAL = MarlinProperties.isUseThreadLocal();
// Soft reference by default: // Soft reference by default:
@SuppressWarnings("removal") final String refType = System.getProperty("sun.java2d.renderer.useRef",
final String refType = AccessController.doPrivileged( "soft");
new GetPropertyAction("sun.java2d.renderer.useRef",
"soft"));
switch (refType) { switch (refType) {
default: default:
case "soft": case "soft":

View File

@ -25,9 +25,7 @@
package sun.java2d.marlin; package sun.java2d.marlin;
import java.security.AccessController;
import static sun.java2d.marlin.MarlinUtils.logInfo; import static sun.java2d.marlin.MarlinUtils.logInfo;
import sun.security.action.GetPropertyAction;
public final class MarlinProperties { public final class MarlinProperties {
@ -288,24 +286,18 @@ public final class MarlinProperties {
} }
// system property utilities // system property utilities
@SuppressWarnings("removal")
static String getString(final String key, final String def) { static String getString(final String key, final String def) {
return AccessController.doPrivileged( return System.getProperty(key, def);
new GetPropertyAction(key, def));
} }
@SuppressWarnings("removal")
static boolean getBoolean(final String key, final String def) { static boolean getBoolean(final String key, final String def) {
return Boolean.parseBoolean(AccessController.doPrivileged( return Boolean.parseBoolean(System.getProperty(key, def));
new GetPropertyAction(key, def)));
} }
static int getInteger(final String key, final int def, static int getInteger(final String key, final int def,
final int min, final int max) final int min, final int max)
{ {
@SuppressWarnings("removal") final String property = System.getProperty(key);
final String property = AccessController.doPrivileged(
new GetPropertyAction(key));
int value = def; int value = def;
if (property != null) { if (property != null) {
@ -334,9 +326,7 @@ public final class MarlinProperties {
final double min, final double max) final double min, final double max)
{ {
double value = def; double value = def;
@SuppressWarnings("removal") final String property = System.getProperty(key);
final String property = AccessController.doPrivileged(
new GetPropertyAction(key));
if (property != null) { if (property != null) {
try { try {

View File

@ -25,8 +25,6 @@
package sun.java2d.marlin; package sun.java2d.marlin;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
@ -357,10 +355,7 @@ public final class RendererStats implements MarlinConst {
private final ConcurrentLinkedQueue<RendererStats> allStats private final ConcurrentLinkedQueue<RendererStats> allStats
= new ConcurrentLinkedQueue<>(); = new ConcurrentLinkedQueue<>();
@SuppressWarnings("removal")
private RendererStatsHolder() { private RendererStatsHolder() {
AccessController.doPrivileged(
(PrivilegedAction<Void>) () -> {
final Thread hook = new Thread( final Thread hook = new Thread(
MarlinUtils.getRootThreadGroup(), MarlinUtils.getRootThreadGroup(),
new Runnable() { new Runnable() {
@ -383,9 +378,6 @@ public final class RendererStats implements MarlinConst {
} }
}, DUMP_INTERVAL, DUMP_INTERVAL); }, DUMP_INTERVAL, DUMP_INTERVAL);
} }
return null;
}
);
} }
void add(final Object parent, final RendererStats stats) { void add(final Object parent, final RendererStats stats) {

View File

@ -30,8 +30,6 @@ import sun.java2d.pipe.RenderBuffer;
import sun.java2d.pipe.RenderQueue; import sun.java2d.pipe.RenderQueue;
import static sun.java2d.pipe.BufferedOpCodes.*; import static sun.java2d.pipe.BufferedOpCodes.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
/** /**
* OGL-specific implementation of RenderQueue. This class provides a * OGL-specific implementation of RenderQueue. This class provides a
@ -44,13 +42,12 @@ public class OGLRenderQueue extends RenderQueue {
private static OGLRenderQueue theInstance; private static OGLRenderQueue theInstance;
private final QueueFlusher flusher; private final QueueFlusher flusher;
@SuppressWarnings("removal")
private OGLRenderQueue() { private OGLRenderQueue() {
/* /*
* The thread must be a member of a thread group * The thread must be a member of a thread group
* which will not get GCed before VM exit. * which will not get GCed before VM exit.
*/ */
flusher = AccessController.doPrivileged((PrivilegedAction<QueueFlusher>) QueueFlusher::new); flusher = new QueueFlusher();
} }
/** /**

View File

@ -178,31 +178,19 @@ public abstract class OGLSurfaceData extends SurfaceData
static { static {
if (!GraphicsEnvironment.isHeadless()) { if (!GraphicsEnvironment.isHeadless()) {
// fbobject currently enabled by default; use "false" to disable // fbobject currently enabled by default; use "false" to disable
@SuppressWarnings("removal") String fbo = System.getProperty("sun.java2d.opengl.fbobject");
String fbo = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(
"sun.java2d.opengl.fbobject"));
isFBObjectEnabled = !"false".equals(fbo); isFBObjectEnabled = !"false".equals(fbo);
// lcdshader currently enabled by default; use "false" to disable // lcdshader currently enabled by default; use "false" to disable
@SuppressWarnings("removal") String lcd = System.getProperty("sun.java2d.opengl.lcdshader");
String lcd = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(
"sun.java2d.opengl.lcdshader"));
isLCDShaderEnabled = !"false".equals(lcd); isLCDShaderEnabled = !"false".equals(lcd);
// biopshader currently enabled by default; use "false" to disable // biopshader currently enabled by default; use "false" to disable
@SuppressWarnings("removal") String biop = System.getProperty("sun.java2d.opengl.biopshader");
String biop = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(
"sun.java2d.opengl.biopshader"));
isBIOpShaderEnabled = !"false".equals(biop); isBIOpShaderEnabled = !"false".equals(biop);
// gradshader currently enabled by default; use "false" to disable // gradshader currently enabled by default; use "false" to disable
@SuppressWarnings("removal") String grad = System.getProperty("sun.java2d.opengl.gradshader");
String grad = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(
"sun.java2d.opengl.gradshader"));
isGradShaderEnabled = !"false".equals(grad); isGradShaderEnabled = !"false".equals(grad);
OGLRenderQueue rq = OGLRenderQueue.getInstance(); OGLRenderQueue rq = OGLRenderQueue.getInstance();

View File

@ -30,9 +30,6 @@ import java.awt.BasicStroke;
import java.awt.geom.PathIterator; import java.awt.geom.PathIterator;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
import sun.awt.geom.PathConsumer2D; import sun.awt.geom.PathConsumer2D;
/** /**
@ -120,10 +117,7 @@ public abstract class RenderingEngine {
/* Look first for an app-override renderer, /* Look first for an app-override renderer,
* if not specified or present, then look for marlin. * if not specified or present, then look for marlin.
*/ */
GetPropertyAction gpa = String reClass = System.getProperty("sun.java2d.renderer");
new GetPropertyAction("sun.java2d.renderer");
@SuppressWarnings("removal")
String reClass = AccessController.doPrivileged(gpa);
if (reClass != null) { if (reClass != null) {
try { try {
Class<?> cls = Class.forName(reClass); Class<?> cls = Class.forName(reClass);
@ -144,16 +138,12 @@ public abstract class RenderingEngine {
throw new InternalError("No RenderingEngine module found"); throw new InternalError("No RenderingEngine module found");
} }
gpa = new GetPropertyAction("sun.java2d.renderer.verbose"); String verbose = System.getProperty("sun.java2d.renderer.verbose");
@SuppressWarnings("removal")
String verbose = AccessController.doPrivileged(gpa);
if (verbose != null && verbose.startsWith("t")) { if (verbose != null && verbose.startsWith("t")) {
System.out.println("RenderingEngine = "+reImpl); System.out.println("RenderingEngine = "+reImpl);
} }
gpa = new GetPropertyAction("sun.java2d.renderer.trace"); String reTrace = System.getProperty("sun.java2d.renderer.trace");
@SuppressWarnings("removal")
String reTrace = AccessController.doPrivileged(gpa);
if (reTrace != null) { if (reTrace != null) {
reImpl = new Tracer(reImpl); reImpl = new Tracer(reImpl);
} }

View File

@ -338,18 +338,9 @@ public class PSPrinterJob extends RasterPrinterJob {
initStatic(); initStatic();
} }
@SuppressWarnings("removal")
private static void initStatic() { 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<Object>() {
public Object run() {
mFontProps = initProps(); mFontProps = initProps();
isMac = OSInfo.getOSType() == OSInfo.OSType.MACOSX; isMac = OSInfo.getOSType() == OSInfo.OSType.MACOSX;
return null;
}
});
} }
/* /*
@ -512,7 +503,6 @@ public class PSPrinterJob extends RasterPrinterJob {
* this method is called to mark the start of a * this method is called to mark the start of a
* document. * document.
*/ */
@SuppressWarnings("removal")
protected void startDoc() throws PrinterException { protected void startDoc() throws PrinterException {
// A security check has been performed in the // A security check has been performed in the
@ -551,7 +541,7 @@ public class PSPrinterJob extends RasterPrinterJob {
} }
} else { } else {
PrinterOpener po = new PrinterOpener(); PrinterOpener po = new PrinterOpener();
java.security.AccessController.doPrivileged(po); po.run();
if (po.pex != null) { if (po.pex != null) {
throw po.pex; throw po.pex;
} }
@ -641,22 +631,16 @@ public class PSPrinterJob extends RasterPrinterJob {
paperWidth + " "+ paperHeight+"]"); paperWidth + " "+ paperHeight+"]");
final PrintService pservice = getPrintService(); final PrintService pservice = getPrintService();
Boolean isPS = java.security.AccessController.doPrivileged( Boolean isPS = Boolean.TRUE;
new java.security.PrivilegedAction<Boolean>() {
public Boolean run() {
try { try {
Class<?> psClass = Class.forName("sun.print.IPPPrintService"); Class<?> psClass = Class.forName("sun.print.IPPPrintService");
if (psClass.isInstance(pservice)) { if (psClass.isInstance(pservice)) {
Method isPSMethod = psClass.getMethod("isPostscript", Method isPSMethod = psClass.getMethod("isPostscript",
(Class[])null); (Class[])null);
return (Boolean)isPSMethod.invoke(pservice, (Object[])null); isPS = (Boolean)isPSMethod.invoke(pservice, (Object[])null);
} }
} catch (Throwable t) { } catch (Throwable t) {
} }
return Boolean.TRUE;
}
}
);
if (isPS) { if (isPS) {
mPSStream.print(" /DeferredMediaSelection true"); mPSStream.print(" /DeferredMediaSelection true");
} }
@ -677,9 +661,9 @@ public class PSPrinterJob extends RasterPrinterJob {
mPSStream.println("%%EndSetup"); 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<OutputStream> { private class PrinterOpener {
PrinterException pex; PrinterException pex;
OutputStream result; 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<Object> { private class PrinterSpooler {
PrinterException pex; PrinterException pex;
private void handleProcessFailure(final Process failedProcess, private void handleProcessFailure(final Process failedProcess,
@ -767,21 +751,13 @@ public class PSPrinterJob extends RasterPrinterJob {
/** /**
* Invoked if the application cancelled the printjob. * Invoked if the application cancelled the printjob.
*/ */
@SuppressWarnings("removal")
protected void abortDoc() { protected void abortDoc() {
if (mPSStream != null && mDestType != RasterPrinterJob.STREAM) { if (mPSStream != null && mDestType != RasterPrinterJob.STREAM) {
mPSStream.close(); mPSStream.close();
} }
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
if (spoolFile != null && spoolFile.exists()) { if (spoolFile != null && spoolFile.exists()) {
spoolFile.delete(); spoolFile.delete();
} }
return null;
}
});
} }
/** /**
@ -789,7 +765,6 @@ public class PSPrinterJob extends RasterPrinterJob {
* this method is called after that last page * this method is called after that last page
* has been imaged. * has been imaged.
*/ */
@SuppressWarnings("removal")
protected void endDoc() throws PrinterException { protected void endDoc() throws PrinterException {
if (mPSStream != null) { if (mPSStream != null) {
mPSStream.println(EOF_COMMENT); mPSStream.println(EOF_COMMENT);
@ -814,7 +789,7 @@ public class PSPrinterJob extends RasterPrinterJob {
} }
} }
PrinterSpooler spooler = new PrinterSpooler(); PrinterSpooler spooler = new PrinterSpooler();
java.security.AccessController.doPrivileged(spooler); spooler.run();
if (spooler.pex != null) { if (spooler.pex != null) {
throw spooler.pex; throw spooler.pex;
} }
@ -859,28 +834,18 @@ public class PSPrinterJob extends RasterPrinterJob {
paperWidth + " " + paperHeight + "]"); paperWidth + " " + paperHeight + "]");
final PrintService pservice = getPrintService(); final PrintService pservice = getPrintService();
@SuppressWarnings("removal") Boolean isPS = Boolean.TRUE;
Boolean isPS = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Boolean>() {
public Boolean run() {
try { try {
Class<?> psClass = Class<?> psClass = Class.forName("sun.print.IPPPrintService");
Class.forName("sun.print.IPPPrintService");
if (psClass.isInstance(pservice)) { if (psClass.isInstance(pservice)) {
Method isPSMethod = Method isPSMethod =
psClass.getMethod("isPostscript", psClass.getMethod("isPostscript",
(Class[])null); (Class[])null);
return (Boolean) isPS = (Boolean) isPSMethod.invoke(pservice,
isPSMethod.invoke(pservice,
(Object[])null); (Object[])null);
} }
} catch (Throwable t) { } catch (Throwable t) {
} }
return Boolean.TRUE;
}
}
);
if (isPS) { if (isPS) {
mPSStream.print(" /DeferredMediaSelection true"); mPSStream.print(" /DeferredMediaSelection true");
} }

View File

@ -174,9 +174,7 @@ public abstract class RasterPrinterJob extends PrinterJob {
* use a particular pipeline. Either the raster * use a particular pipeline. Either the raster
* pipeline or the pdl pipeline can be forced. * pipeline or the pdl pipeline can be forced.
*/ */
@SuppressWarnings("removal") String forceStr = System.getProperty(FORCE_PIPE_PROP);
String forceStr = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(FORCE_PIPE_PROP));
if (forceStr != null) { if (forceStr != null) {
if (forceStr.equalsIgnoreCase(FORCE_PDL)) { if (forceStr.equalsIgnoreCase(FORCE_PDL)) {
@ -186,9 +184,7 @@ public abstract class RasterPrinterJob extends PrinterJob {
} }
} }
@SuppressWarnings("removal") String shapeTextStr = System.getProperty(SHAPE_TEXT_PROP);
String shapeTextStr =java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(SHAPE_TEXT_PROP));
if (shapeTextStr != null) { if (shapeTextStr != null) {
shapeTextProp = true; shapeTextProp = true;
@ -731,20 +727,9 @@ public abstract class RasterPrinterJob extends PrinterJob {
GraphicsEnvironment.getLocalGraphicsEnvironment(). GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration(); getDefaultScreenDevice().getDefaultConfiguration();
@SuppressWarnings("removal")
PrintService service = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<PrintService>() {
public PrintService run() {
PrintService service = getPrintService(); PrintService service = getPrintService();
if (service == null) { if (service == null) {
ServiceDialog.showNoPrintService(gc); ServiceDialog.showNoPrintService(gc);
return null;
}
return service;
}
});
if (service == null) {
return page; return page;
} }
updatePageAttributes(service, page); updatePageAttributes(service, page);
@ -812,22 +797,11 @@ public abstract class RasterPrinterJob extends PrinterJob {
} }
final GraphicsConfiguration gc = grCfg; final GraphicsConfiguration gc = grCfg;
@SuppressWarnings("removal")
PrintService service = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<PrintService>() {
public PrintService run() {
PrintService service = getPrintService(); PrintService service = getPrintService();
if (service == null) { if (service == null) {
ServiceDialog.showNoPrintService(gc); ServiceDialog.showNoPrintService(gc);
return null; return null;
} }
return service;
}
});
if (service == null) {
return null;
}
// we position the dialog a little beyond the upper-left corner of the window // we position the dialog a little beyond the upper-left corner of the window
// which is consistent with the NATIVE page dialog // which is consistent with the NATIVE page dialog
@ -953,7 +927,6 @@ public abstract class RasterPrinterJob extends PrinterJob {
* returns true. * returns true.
* @see java.awt.GraphicsEnvironment#isHeadless * @see java.awt.GraphicsEnvironment#isHeadless
*/ */
@SuppressWarnings("removal")
public boolean printDialog(final PrintRequestAttributeSet attributes) public boolean printDialog(final PrintRequestAttributeSet attributes)
throws HeadlessException { throws HeadlessException {
if (GraphicsEnvironment.isHeadless()) { if (GraphicsEnvironment.isHeadless()) {
@ -1008,19 +981,9 @@ public abstract class RasterPrinterJob extends PrinterJob {
} }
final GraphicsConfiguration gc = grCfg; final GraphicsConfiguration gc = grCfg;
PrintService service = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<PrintService>() {
public PrintService run() {
PrintService service = getPrintService(); PrintService service = getPrintService();
if (service == null) { if (service == null) {
ServiceDialog.showNoPrintService(gc); ServiceDialog.showNoPrintService(gc);
return null;
}
return service;
}
});
if (service == null) {
return false; return false;
} }
@ -1033,13 +996,7 @@ public abstract class RasterPrinterJob extends PrinterJob {
services[i] = spsFactories[i].getPrintService(null); services[i] = spsFactories[i].getPrintService(null);
} }
} else { } else {
services = java.security.AccessController.doPrivileged( services = PrinterJob.lookupPrintServices();
new java.security.PrivilegedAction<PrintService[]>() {
public PrintService[] run() {
PrintService[] services = PrinterJob.lookupPrintServices();
return services;
}
});
if ((services == null) || (services.length == 0)) { if ((services == null) || (services.length == 0)) {
/* /*

View File

@ -448,22 +448,14 @@ public class ServiceDialog extends JDialog implements ActionListener {
/** /**
* Initialize ResourceBundle * Initialize ResourceBundle
*/ */
@SuppressWarnings("removal")
public static void initResource() { public static void initResource() {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
try { try {
messageRB = ResourceBundle.getBundle(strBundle); messageRB = ResourceBundle.getBundle(strBundle);
return null;
} catch (java.util.MissingResourceException e) { } catch (java.util.MissingResourceException e) {
throw new Error("Fatal: Resource for ServiceUI " + throw new Error("Fatal: Resource for ServiceUI " +
"is missing"); "is missing");
} }
} }
}
);
}
/** /**
* Returns message string from resource * Returns message string from resource
@ -542,15 +534,7 @@ public class ServiceDialog extends JDialog implements ActionListener {
* Returns URL for image resource * Returns URL for image resource
*/ */
private static URL getImageResource(final String key) { private static URL getImageResource(final String key) {
@SuppressWarnings("removal") URL url = ServiceDialog.class.getResource("resources/" + key);
URL url = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<URL>() {
public URL run() {
URL url = ServiceDialog.class.getResource(
"resources/" + key);
return url;
}
});
if (url == null) { if (url == null) {
throw new Error("Fatal: Resource for ServiceUI is broken; " + 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)); super(new FlowLayout(FlowLayout.LEADING));
final URL imgURL = getImageResource(img); final URL imgURL = getImageResource(img);
@SuppressWarnings("removal")
Icon icon = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Icon>() {
public Icon run() {
Icon icon = new ImageIcon(imgURL); Icon icon = new ImageIcon(imgURL);
return icon;
}
});
lbl = new JLabel(icon); lbl = new JLabel(icon);
add(lbl); add(lbl);

View File

@ -40,7 +40,6 @@ import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt; import java.awt.image.DataBufferInt;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.security.AccessController;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLayeredPane; import javax.swing.JLayeredPane;
@ -55,7 +54,6 @@ import sun.awt.AWTAccessor;
import sun.awt.DisplayChangedListener; import sun.awt.DisplayChangedListener;
import sun.awt.LightweightFrame; import sun.awt.LightweightFrame;
import sun.awt.OverrideNativeWindowHandle; import sun.awt.OverrideNativeWindowHandle;
import sun.security.action.GetPropertyAction;
import sun.swing.SwingUtilities2.RepaintListener; 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()}, * by the lock (managed with the {@link LightweightContent#paintLock()},
* {@link LightweightContent#paintUnlock()} methods). * {@link LightweightContent#paintUnlock()} methods).
*/ */
@SuppressWarnings("removal") private static boolean copyBufferEnabled = "true".equals(
private static boolean copyBufferEnabled = "true".equals(AccessController. System.getProperty("swing.jlf.copyBufferEnabled", "true"));
doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true")));
private int[] copyBuffer; private int[] copyBuffer;
/** /**
* Constructs a new, initially invisible {@code JLightweightFrame} * Constructs a new, initially invisible {@code JLightweightFrame}
* instance. * instance.
*/ */
@SuppressWarnings("removal")
public JLightweightFrame() { public JLightweightFrame() {
super(); super();
AffineTransform defaultTransform = AffineTransform defaultTransform =
getGraphicsConfiguration().getDefaultTransform(); getGraphicsConfiguration().getDefaultTransform();
scaleFactorX = defaultTransform.getScaleX(); scaleFactorX = defaultTransform.getScaleX();
scaleFactorY = defaultTransform.getScaleY(); scaleFactorY = defaultTransform.getScaleY();
copyBufferEnabled = "true".equals(AccessController. copyBufferEnabled = "true".equals(System.getProperty("swing.jlf.copyBufferEnabled", "true"));
doPrivileged(new GetPropertyAction("swing.jlf.copyBufferEnabled", "true")));
add(rootPane, BorderLayout.CENTER); add(rootPane, BorderLayout.CENTER);
setFocusTraversalPolicy(new LayoutFocusTraversalPolicy()); setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
@ -331,7 +326,6 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
content.imageUpdated(x, y, width, height); content.imageUpdated(x, y, width, height);
} }
@SuppressWarnings("removal")
private void initInterior() { private void initInterior() {
contentPane = new JPanel() { contentPane = new JPanel() {
@Override @Override
@ -392,8 +386,7 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
contentPane.add(component); contentPane.add(component);
contentPane.revalidate(); contentPane.revalidate();
contentPane.repaint(); contentPane.repaint();
if ("true".equals(AccessController. if ("true".equals(System.getProperty("swing.jlf.contentPaneTransparent", "false")))
doPrivileged(new GetPropertyAction("swing.jlf.contentPaneTransparent", "false"))))
{ {
contentPane.setOpaque(false); contentPane.setOpaque(false);
} }

View File

@ -61,8 +61,6 @@ import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.AttributedCharacterIterator; import java.text.AttributedCharacterIterator;
import java.text.AttributedString; import java.text.AttributedString;
import java.text.BreakIterator; import java.text.BreakIterator;
@ -1706,10 +1704,8 @@ public class SwingUtilities2 {
final String imageFile, final String imageFile,
final boolean enablePrivileges) { final boolean enablePrivileges) {
return (UIDefaults.LazyValue) (table) -> { return (UIDefaults.LazyValue) (table) -> {
@SuppressWarnings("removal") byte[] buffer = enablePrivileges ?
byte[] buffer = enablePrivileges ? AccessController.doPrivileged( getIconBytes(baseClass, rootClass, imageFile)
(PrivilegedAction<byte[]>) ()
-> getIconBytes(baseClass, rootClass, imageFile))
: getIconBytes(baseClass, rootClass, imageFile); : getIconBytes(baseClass, rootClass, imageFile);
if (buffer == null) { if (buffer == null) {