8344057: Remove doPrivileged calls from unix platform sources in the java.desktop module
Reviewed-by: prr
This commit is contained in:
parent
da2d7a09f9
commit
b9bf447209
@ -28,8 +28,6 @@ package sun.awt;
|
||||
import java.io.File;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Toolkit;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
public class PlatformGraphicsInfo {
|
||||
|
||||
@ -47,14 +45,10 @@ public class PlatformGraphicsInfo {
|
||||
* headless mode, in the case the application did not specify
|
||||
* a value for the java.awt.headless system property.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public static boolean getDefaultHeadlessProperty() {
|
||||
boolean noDisplay =
|
||||
AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
|
||||
final String display = System.getenv("DISPLAY");
|
||||
boolean noDisplay = (display == null || display.trim().isEmpty());
|
||||
|
||||
final String display = System.getenv("DISPLAY");
|
||||
return display == null || display.trim().isEmpty();
|
||||
});
|
||||
if (noDisplay) {
|
||||
return true;
|
||||
}
|
||||
@ -67,18 +61,16 @@ public class PlatformGraphicsInfo {
|
||||
* code is also set up as headless from the start - it is not so easy
|
||||
* to try headful and then unwind that and then retry as headless.
|
||||
*/
|
||||
boolean headless =
|
||||
AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
|
||||
String[] libDirs = System.getProperty("sun.boot.library.path", "").split(":");
|
||||
for (String libDir : libDirs) {
|
||||
File headlessLib = new File(libDir, "libawt_headless.so");
|
||||
File xawtLib = new File(libDir, "libawt_xawt.so");
|
||||
if (headlessLib.exists() && !xawtLib.exists()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
boolean headless = false;
|
||||
String[] libDirs = System.getProperty("sun.boot.library.path", "").split(":");
|
||||
for (String libDir : libDirs) {
|
||||
File headlessLib = new File(libDir, "libawt_headless.so");
|
||||
File xawtLib = new File(libDir, "libawt_xawt.so");
|
||||
if (headlessLib.exists() && !xawtLib.exists()) {
|
||||
headless = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return headless;
|
||||
}
|
||||
|
||||
|
@ -105,9 +105,7 @@ public abstract class UNIXToolkit extends SunToolkit
|
||||
private BufferedImage tmpImage = null;
|
||||
|
||||
public static int getDatatransferTimeout() {
|
||||
@SuppressWarnings("removal")
|
||||
Integer dt = AccessController.doPrivileged(
|
||||
new GetIntegerAction("sun.awt.datatransfer.timeout"));
|
||||
Integer dt = Integer.getInteger("sun.awt.datatransfer.timeout");
|
||||
if (dt == null || dt <= 0) {
|
||||
return DEFAULT_DATATRANSFER_TIMEOUT;
|
||||
} else {
|
||||
@ -118,18 +116,12 @@ public abstract class UNIXToolkit extends SunToolkit
|
||||
@Override
|
||||
public String getDesktop() {
|
||||
String gnome = "gnome";
|
||||
@SuppressWarnings("removal")
|
||||
String gsi = AccessController.doPrivileged(
|
||||
(PrivilegedAction<String>) ()
|
||||
-> System.getenv("GNOME_DESKTOP_SESSION_ID"));
|
||||
String gsi = System.getenv("GNOME_DESKTOP_SESSION_ID");
|
||||
if (gsi != null) {
|
||||
return gnome;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
String desktop = AccessController.doPrivileged(
|
||||
(PrivilegedAction<String>) ()
|
||||
-> System.getenv("XDG_CURRENT_DESKTOP"));
|
||||
String desktop = System.getenv("XDG_CURRENT_DESKTOP");
|
||||
return (desktop != null && desktop.toLowerCase().contains(gnome))
|
||||
? gnome : null;
|
||||
}
|
||||
@ -252,11 +244,7 @@ public abstract class UNIXToolkit extends SunToolkit
|
||||
result = shouldDisableSystemTray;
|
||||
if (result == null) {
|
||||
if ("gnome".equals(getDesktop())) {
|
||||
@SuppressWarnings("removal")
|
||||
Integer gnomeShellMajorVersion =
|
||||
AccessController
|
||||
.doPrivileged((PrivilegedAction<Integer>)
|
||||
this::getGnomeShellMajorVersion);
|
||||
Integer gnomeShellMajorVersion = getGnomeShellMajorVersion();
|
||||
|
||||
if (gnomeShellMajorVersion == null
|
||||
|| gnomeShellMajorVersion < 45) {
|
||||
@ -486,9 +474,7 @@ public abstract class UNIXToolkit extends SunToolkit
|
||||
}
|
||||
|
||||
public static GtkVersions getEnabledGtkVersion() {
|
||||
@SuppressWarnings("removal")
|
||||
String version = AccessController.doPrivileged(
|
||||
new GetPropertyAction("jdk.gtk.version"));
|
||||
String version = System.getProperty("jdk.gtk.version");
|
||||
if ("3".equals(version)) {
|
||||
return GtkVersions.GTK3;
|
||||
}
|
||||
@ -499,32 +485,22 @@ public abstract class UNIXToolkit extends SunToolkit
|
||||
return GtkVersions.getVersion(get_gtk_version());
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public static boolean isGtkVerbose() {
|
||||
return AccessController.doPrivileged((PrivilegedAction<Boolean>)()
|
||||
-> Boolean.getBoolean("jdk.gtk.verbose"));
|
||||
return Boolean.getBoolean("jdk.gtk.verbose");
|
||||
}
|
||||
|
||||
private static volatile Boolean isOnWayland = null;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public static boolean isOnWayland() {
|
||||
Boolean result = isOnWayland;
|
||||
if (result == null) {
|
||||
synchronized (GTK_LOCK) {
|
||||
result = isOnWayland;
|
||||
if (result == null) {
|
||||
final String display = System.getenv("WAYLAND_DISPLAY");
|
||||
isOnWayland
|
||||
= result
|
||||
= AccessController.doPrivileged(
|
||||
(PrivilegedAction<Boolean>) () -> {
|
||||
final String display =
|
||||
System.getenv("WAYLAND_DISPLAY");
|
||||
|
||||
return display != null
|
||||
&& !display.trim().isEmpty();
|
||||
}
|
||||
);
|
||||
= (display != null && !display.trim().isEmpty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,6 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.text.BreakIterator;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
|
||||
@ -227,16 +225,8 @@ public abstract class InfoWindow extends Window {
|
||||
textLabel.setText(tooltipString);
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
Point pointer = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Point>() {
|
||||
public Point run() {
|
||||
if (!isPointerOverTrayIcon(liveArguments.getBounds())) {
|
||||
return null;
|
||||
}
|
||||
return MouseInfo.getPointerInfo().getLocation();
|
||||
}
|
||||
});
|
||||
Point pointer = !isPointerOverTrayIcon(liveArguments.getBounds())
|
||||
? null : MouseInfo.getPointerInfo().getLocation();
|
||||
if (pointer == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -27,8 +27,6 @@ package sun.awt.X11;
|
||||
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import java.util.Vector;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/**
|
||||
* This class contains the collection of utility functions to help work with
|
||||
@ -43,13 +41,7 @@ class Native {
|
||||
|
||||
static int dataModel;
|
||||
static {
|
||||
@SuppressWarnings("removal")
|
||||
String dataModelProp = AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
return System.getProperty("sun.arch.data.model");
|
||||
}
|
||||
});
|
||||
String dataModelProp = System.getProperty("sun.arch.data.model");
|
||||
try {
|
||||
dataModel = Integer.parseInt(dataModelProp);
|
||||
} catch (Exception e) {
|
||||
|
@ -29,14 +29,12 @@ import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.util.SortedMap;
|
||||
import java.io.IOException;
|
||||
import java.security.AccessController;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import sun.awt.UNIXToolkit;
|
||||
import sun.awt.datatransfer.DataTransferer;
|
||||
import sun.awt.datatransfer.SunClipboard;
|
||||
import sun.awt.datatransfer.ClipboardTransferable;
|
||||
import sun.security.action.GetIntegerAction;
|
||||
|
||||
/**
|
||||
* A class which interfaces with the X11 selection service in order to support
|
||||
@ -129,13 +127,11 @@ public final class XClipboard extends SunClipboard implements OwnershipListener
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static int getPollInterval() {
|
||||
synchronized (XClipboard.classLock) {
|
||||
if (pollInterval <= 0) {
|
||||
pollInterval = AccessController.doPrivileged(
|
||||
new GetIntegerAction("awt.datatransfer.clipboard.poll.interval",
|
||||
defaultPollInterval));
|
||||
pollInterval = Integer.getInteger("awt.datatransfer.clipboard.poll.interval"
|
||||
, defaultPollInterval);
|
||||
if (pollInterval <= 0) {
|
||||
pollInterval = defaultPollInterval;
|
||||
}
|
||||
|
@ -35,9 +35,6 @@ import sun.util.logging.PlatformLogger;
|
||||
import java.util.*;
|
||||
import static sun.awt.X11.XEmbedHelper.*;
|
||||
|
||||
import java.security.AccessController;
|
||||
import sun.security.action.GetBooleanAction;
|
||||
|
||||
public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener, KeyEventPostProcessor, ModalityListener, WindowIDProvider {
|
||||
private static final PlatformLogger xembedLog = PlatformLogger.getLogger("sun.awt.X11.xembed.XEmbedCanvasPeer");
|
||||
|
||||
@ -439,12 +436,11 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
void canvasFocusLost(FocusEvent e) {
|
||||
if (isXEmbedActive() && !e.isTemporary()) {
|
||||
xembedLog.fine("Forwarding FOCUS_LOST");
|
||||
int num = 0;
|
||||
if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.xembed.testing"))) {
|
||||
if (Boolean.getBoolean("sun.awt.xembed.testing")) {
|
||||
Component opp = e.getOppositeComponent();
|
||||
try {
|
||||
num = Integer.parseInt(opp.getName());
|
||||
|
@ -24,9 +24,7 @@
|
||||
*/
|
||||
package sun.awt.X11;
|
||||
|
||||
import java.security.AccessController;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.security.action.GetBooleanAction;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
/**
|
||||
@ -59,9 +57,7 @@ public final class XErrorHandlerUtil {
|
||||
/**
|
||||
* Value of sun.awt.noisyerrorhandler system property.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private static boolean noisyAwtHandler = AccessController.doPrivileged(
|
||||
new GetBooleanAction("sun.awt.noisyerrorhandler"));
|
||||
private static boolean noisyAwtHandler = Boolean.getBoolean("sun.awt.noisyerrorhandler");
|
||||
|
||||
/**
|
||||
* The flag indicating that {@code init} was called already.
|
||||
|
@ -32,8 +32,6 @@ import java.awt.peer.*;
|
||||
import java.io.*;
|
||||
import java.util.Locale;
|
||||
import java.util.Arrays;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import sun.awt.AWTAccessor.ComponentAccessor;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
@ -139,7 +137,7 @@ class XFileDialogPeer extends XDialogPeer
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"removal","deprecation"})
|
||||
@SuppressWarnings("deprecation")
|
||||
private void init(FileDialog target) {
|
||||
fileDialog = target; //new Dialog(target, target.getTitle(), false);
|
||||
this.title = target.getTitle();
|
||||
@ -151,12 +149,7 @@ class XFileDialogPeer extends XDialogPeer
|
||||
savedDir = target.getDirectory();
|
||||
// Shouldn't save 'user.dir' to 'savedDir'
|
||||
// since getDirectory() will be incorrect after handleCancel
|
||||
userDir = AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
return System.getProperty("user.dir");
|
||||
}
|
||||
});
|
||||
userDir = System.getProperty("user.dir");
|
||||
|
||||
installStrings();
|
||||
gbl = new GridBagLayout();
|
||||
|
@ -28,7 +28,6 @@ package sun.awt.X11;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.peer.RobotPeer;
|
||||
import java.security.AccessController;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.SunToolkit;
|
||||
@ -36,9 +35,7 @@ import sun.awt.UNIXToolkit;
|
||||
import sun.awt.X11GraphicsConfig;
|
||||
import sun.awt.X11GraphicsDevice;
|
||||
import sun.awt.screencast.ScreencastHelper;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
final class XRobotPeer implements RobotPeer {
|
||||
|
||||
private static final boolean tryGtk;
|
||||
@ -50,10 +47,8 @@ final class XRobotPeer implements RobotPeer {
|
||||
loadNativeLibraries();
|
||||
|
||||
tryGtk = Boolean.parseBoolean(
|
||||
AccessController.doPrivileged(
|
||||
new GetPropertyAction("awt.robot.gtk",
|
||||
"true")
|
||||
));
|
||||
System.getProperty("awt.robot.gtk", "true")
|
||||
);
|
||||
|
||||
boolean isOnWayland = false;
|
||||
|
||||
@ -61,13 +56,12 @@ final class XRobotPeer implements RobotPeer {
|
||||
isOnWayland = sunToolkit.isRunningOnWayland();
|
||||
}
|
||||
|
||||
screenshotMethod = AccessController.doPrivileged(
|
||||
new GetPropertyAction(
|
||||
screenshotMethod = System.getProperty(
|
||||
"awt.robot.screenshotMethod",
|
||||
isOnWayland
|
||||
? METHOD_SCREENCAST
|
||||
: METHOD_X11
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
private static volatile boolean useGtk;
|
||||
|
@ -31,9 +31,6 @@ import java.awt.peer.TaskbarPeer;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
import sun.awt.UNIXToolkit;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
final class XTaskbarPeer implements TaskbarPeer {
|
||||
|
||||
@ -44,10 +41,7 @@ final class XTaskbarPeer implements TaskbarPeer {
|
||||
private static boolean isUnity;
|
||||
|
||||
static {
|
||||
@SuppressWarnings("removal")
|
||||
String de = AccessController.doPrivileged(
|
||||
(PrivilegedAction<String>) ()
|
||||
-> System.getenv("XDG_CURRENT_DESKTOP"));
|
||||
String de = System.getenv("XDG_CURRENT_DESKTOP");
|
||||
isUnity = "Unity".equals(de);
|
||||
}
|
||||
|
||||
@ -55,9 +49,7 @@ final class XTaskbarPeer implements TaskbarPeer {
|
||||
XToolkit.awtLock();
|
||||
try {
|
||||
if (!initExecuted) {
|
||||
@SuppressWarnings("removal")
|
||||
String dname = AccessController.doPrivileged(
|
||||
new GetPropertyAction("java.desktop.appName", ""));
|
||||
String dname = System.getProperty("java.desktop.appName", "");
|
||||
nativeLibraryLoaded = init(dname,
|
||||
UNIXToolkit.getEnabledGtkVersion().ordinal(),
|
||||
UNIXToolkit.isGtkVerbose());
|
||||
|
@ -111,8 +111,6 @@ import java.awt.peer.TextFieldPeer;
|
||||
import java.awt.peer.TrayIconPeer;
|
||||
import java.awt.peer.WindowPeer;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -147,8 +145,6 @@ import sun.awt.util.ThreadGroupUtils;
|
||||
import sun.font.FontConfigManager;
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
import sun.print.PrintJob2D;
|
||||
import sun.security.action.GetBooleanAction;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import static sun.awt.X11.XlibUtil.scaleDown;
|
||||
@ -246,9 +242,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
|
||||
static void initSecurityWarning() {
|
||||
// Enable warning only for internal builds
|
||||
@SuppressWarnings("removal")
|
||||
String runtime = AccessController.doPrivileged(
|
||||
new GetPropertyAction("java.runtime.version"));
|
||||
String runtime = System.getProperty("java.runtime.version");
|
||||
securityWarningEnabled = (runtime != null && runtime.contains("internal"));
|
||||
}
|
||||
|
||||
@ -326,7 +320,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
void init() {
|
||||
awtLock();
|
||||
try {
|
||||
@ -339,13 +332,10 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
arrowCursor = XlibWrapper.XCreateFontCursor(XToolkit.getDisplay(),
|
||||
XCursorFontConstants.XC_arrow);
|
||||
final String extraButtons = "sun.awt.enableExtraMouseButtons";
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
areExtraMouseButtonsEnabled =
|
||||
Boolean.parseBoolean(System.getProperty(extraButtons, "true"));
|
||||
//set system property if not yet assigned
|
||||
System.setProperty(extraButtons, ""+areExtraMouseButtonsEnabled);
|
||||
return null;
|
||||
});
|
||||
areExtraMouseButtonsEnabled =
|
||||
Boolean.parseBoolean(System.getProperty(extraButtons, "true"));
|
||||
//set system property if not yet assigned
|
||||
System.setProperty(extraButtons, "" + areExtraMouseButtonsEnabled);
|
||||
// Detect display mode changes
|
||||
XlibWrapper.XSelectInput(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), XConstants.StructureNotifyMask);
|
||||
XToolkit.addEventDispatcher(XToolkit.getDefaultRootWindow(), new XEventDispatcher() {
|
||||
@ -370,28 +360,24 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
} finally {
|
||||
awtUnlock();
|
||||
}
|
||||
PrivilegedAction<Void> a = () -> {
|
||||
Runnable r = () -> {
|
||||
XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
|
||||
if (peer != null) {
|
||||
peer.dispose();
|
||||
}
|
||||
if (xs != null) {
|
||||
((XAWTXSettings)xs).dispose();
|
||||
}
|
||||
freeXKB();
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
dumpPeers();
|
||||
}
|
||||
};
|
||||
String name = "XToolkt-Shutdown-Thread";
|
||||
Thread shutdownThread = new Thread(
|
||||
ThreadGroupUtils.getRootThreadGroup(), r, name, 0, false);
|
||||
shutdownThread.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(shutdownThread);
|
||||
return null;
|
||||
Runnable r = () -> {
|
||||
XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
|
||||
if (peer != null) {
|
||||
peer.dispose();
|
||||
}
|
||||
if (xs != null) {
|
||||
((XAWTXSettings)xs).dispose();
|
||||
}
|
||||
freeXKB();
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
dumpPeers();
|
||||
}
|
||||
};
|
||||
AccessController.doPrivileged(a);
|
||||
String name = "XToolkt-Shutdown-Thread";
|
||||
Thread shutdownThread = new Thread(
|
||||
ThreadGroupUtils.getRootThreadGroup(), r, name, 0, false);
|
||||
shutdownThread.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(shutdownThread);
|
||||
}
|
||||
|
||||
static String getCorrectXIDString(String val) {
|
||||
@ -409,7 +395,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
return awtAppClassName;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public XToolkit() {
|
||||
super();
|
||||
if (PerformanceLogger.loggingEnabled()) {
|
||||
@ -432,16 +417,13 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
init();
|
||||
XWM.init();
|
||||
|
||||
toolkitThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
|
||||
String name = "AWT-XAWT";
|
||||
Thread thread = new Thread(
|
||||
String name = "AWT-XAWT";
|
||||
toolkitThread = new Thread(
|
||||
ThreadGroupUtils.getRootThreadGroup(), this, name,
|
||||
0, false);
|
||||
thread.setContextClassLoader(null);
|
||||
thread.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
});
|
||||
toolkitThread.setContextClassLoader(null);
|
||||
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
toolkitThread.setDaemon(true);
|
||||
toolkitThread.start();
|
||||
}
|
||||
}
|
||||
@ -1120,11 +1102,9 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
* Returns the value of "sun.awt.disableGtkFileDialogs" property. Default
|
||||
* value is {@code false}.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public static synchronized boolean getSunAwtDisableGtkFileDialogs() {
|
||||
if (sunAwtDisableGtkFileDialogs == null) {
|
||||
sunAwtDisableGtkFileDialogs = AccessController.doPrivileged(
|
||||
new GetBooleanAction("sun.awt.disableGtkFileDialogs"));
|
||||
sunAwtDisableGtkFileDialogs = Boolean.getBoolean("sun.awt.disableGtkFileDialogs");
|
||||
}
|
||||
return sunAwtDisableGtkFileDialogs.booleanValue();
|
||||
}
|
||||
@ -2139,9 +2119,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
}
|
||||
|
||||
private static void setBackingStoreType() {
|
||||
@SuppressWarnings("removal")
|
||||
String prop = AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("sun.awt.backingStore"));
|
||||
String prop = System.getProperty("sun.awt.backingStore");
|
||||
|
||||
if (prop == null) {
|
||||
backingStoreType = XConstants.NotUseful;
|
||||
@ -2565,8 +2543,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
* Returns the value of "sun.awt.disablegrab" property. Default
|
||||
* value is {@code false}.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public static boolean getSunAwtDisableGrab() {
|
||||
return AccessController.doPrivileged(new GetBooleanAction("sun.awt.disablegrab"));
|
||||
return Boolean.getBoolean("sun.awt.disablegrab");
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,6 @@ import java.awt.event.*;
|
||||
import java.awt.peer.TrayIconPeer;
|
||||
import sun.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
@ -66,7 +64,6 @@ public class XTrayIconPeer implements TrayIconPeer,
|
||||
static final int TRAY_ICON_WIDTH = 24;
|
||||
static final int TRAY_ICON_HEIGHT = 24;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
XTrayIconPeer(TrayIcon target)
|
||||
throws AWTException
|
||||
{
|
||||
@ -84,12 +81,7 @@ public class XTrayIconPeer implements TrayIconPeer,
|
||||
// Fix for 6317038: as EmbeddedFrame is instance of Frame, it is blocked
|
||||
// by modal dialogs, but in the case of TrayIcon it shouldn't. So we
|
||||
// set ModalExclusion property on it.
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
eframe.setModalExclusionType(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
eframe.setModalExclusionType(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
|
||||
|
||||
|
||||
if (XWM.getWMID() != XWM.METACITY_WM) {
|
||||
|
@ -25,10 +25,7 @@
|
||||
|
||||
package sun.awt.X11;
|
||||
|
||||
import java.security.AccessController;
|
||||
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
final class XlibWrapper {
|
||||
|
||||
@ -585,9 +582,7 @@ static native String XSetLocaleModifiers(String modifier_list);
|
||||
static final boolean isBuildInternal;
|
||||
|
||||
static {
|
||||
@SuppressWarnings("removal")
|
||||
String dataModelProp = AccessController.doPrivileged(
|
||||
new GetPropertyAction("sun.arch.data.model"));
|
||||
String dataModelProp = System.getProperty("sun.arch.data.model");
|
||||
try {
|
||||
dataModel = Integer.parseInt(dataModelProp);
|
||||
} catch (Exception e) {
|
||||
@ -639,9 +634,7 @@ static native String XSetLocaleModifiers(String modifier_list);
|
||||
}
|
||||
|
||||
private static boolean getBuildInternal() {
|
||||
@SuppressWarnings("removal")
|
||||
String javaVersion = AccessController.doPrivileged(
|
||||
new GetPropertyAction("java.version"));
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
return javaVersion != null && javaVersion.contains("internal");
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,6 @@ import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Window;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -447,7 +445,6 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
return modes.toArray(retArray);
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
@Override
|
||||
public synchronized void setDisplayMode(DisplayMode dm) {
|
||||
if (!isDisplayChangeSupported()) {
|
||||
@ -474,24 +471,20 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
// is already in the original DisplayMode at that time, this
|
||||
// hook will have no effect)
|
||||
shutdownHookRegistered = true;
|
||||
PrivilegedAction<Void> a = () -> {
|
||||
Runnable r = () -> {
|
||||
Window old = getFullScreenWindow();
|
||||
if (old != null) {
|
||||
exitFullScreenExclusive(old);
|
||||
if (isDisplayChangeSupported()) {
|
||||
setDisplayMode(origDisplayMode);
|
||||
}
|
||||
Runnable r = () -> {
|
||||
Window old = getFullScreenWindow();
|
||||
if (old != null) {
|
||||
exitFullScreenExclusive(old);
|
||||
if (isDisplayChangeSupported()) {
|
||||
setDisplayMode(origDisplayMode);
|
||||
}
|
||||
};
|
||||
String name = "Display-Change-Shutdown-Thread-" + screen;
|
||||
Thread t = new Thread(
|
||||
ThreadGroupUtils.getRootThreadGroup(), r, name, 0, false);
|
||||
t.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(t);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
AccessController.doPrivileged(a);
|
||||
String name = "Display-Change-Shutdown-Thread-" + screen;
|
||||
Thread t = new Thread(
|
||||
ThreadGroupUtils.getRootThreadGroup(), r, name, 0, false);
|
||||
t.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(t);
|
||||
}
|
||||
|
||||
// switch to the new DisplayMode
|
||||
|
@ -59,78 +59,71 @@ public final class X11GraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
initStatic();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings("restricted")
|
||||
private static void initStatic() {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
System.loadLibrary("awt");
|
||||
System.loadLibrary("awt");
|
||||
|
||||
/*
|
||||
* Note: The XToolkit object depends on the static initializer
|
||||
* of X11GraphicsEnvironment to initialize the connection to
|
||||
* the X11 server.
|
||||
*/
|
||||
if (!isHeadless()) {
|
||||
// first check the OGL system property
|
||||
boolean glxRequested = false;
|
||||
String prop = System.getProperty("sun.java2d.opengl");
|
||||
if (prop != null) {
|
||||
if (prop.equals("true") || prop.equals("t")) {
|
||||
glxRequested = true;
|
||||
} else if (prop.equals("True") || prop.equals("T")) {
|
||||
glxRequested = true;
|
||||
glxVerbose = true;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Note: The XToolkit object depends on the static initializer
|
||||
* of X11GraphicsEnvironment to initialize the connection to
|
||||
* the X11 server.
|
||||
*/
|
||||
if (!isHeadless()) {
|
||||
// first check the OGL system property
|
||||
boolean glxRequested = false;
|
||||
String prop = System.getProperty("sun.java2d.opengl");
|
||||
if (prop != null) {
|
||||
if (prop.equals("true") || prop.equals("t")) {
|
||||
glxRequested = true;
|
||||
} else if (prop.equals("True") || prop.equals("T")) {
|
||||
glxRequested = true;
|
||||
glxVerbose = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Now check for XRender system property
|
||||
boolean xRenderRequested = true;
|
||||
boolean xRenderIgnoreLinuxVersion = false;
|
||||
String xProp = System.getProperty("sun.java2d.xrender");
|
||||
if (xProp != null) {
|
||||
if (xProp.equals("false") || xProp.equals("f")) {
|
||||
xRenderRequested = false;
|
||||
} else if (xProp.equals("True") || xProp.equals("T")) {
|
||||
xRenderRequested = true;
|
||||
xRenderVerbose = true;
|
||||
}
|
||||
|
||||
if(xProp.equalsIgnoreCase("t") || xProp.equalsIgnoreCase("true")) {
|
||||
xRenderIgnoreLinuxVersion = true;
|
||||
}
|
||||
}
|
||||
|
||||
// initialize the X11 display connection
|
||||
initDisplay(glxRequested);
|
||||
|
||||
// only attempt to initialize GLX if it was requested
|
||||
if (glxRequested) {
|
||||
glxAvailable = initGLX();
|
||||
if (glxVerbose && !glxAvailable) {
|
||||
System.out.println(
|
||||
"Could not enable OpenGL " +
|
||||
"pipeline (GLX 1.3 not available)");
|
||||
}
|
||||
}
|
||||
|
||||
// only attempt to initialize Xrender if it was requested
|
||||
if (xRenderRequested) {
|
||||
xRenderAvailable = initXRender(xRenderVerbose, xRenderIgnoreLinuxVersion);
|
||||
if (xRenderVerbose && !xRenderAvailable) {
|
||||
System.out.println(
|
||||
"Could not enable XRender pipeline");
|
||||
}
|
||||
}
|
||||
|
||||
if (xRenderAvailable) {
|
||||
XRSurfaceData.initXRSurfaceData();
|
||||
}
|
||||
// Now check for XRender system property
|
||||
boolean xRenderRequested = true;
|
||||
boolean xRenderIgnoreLinuxVersion = false;
|
||||
String xProp = System.getProperty("sun.java2d.xrender");
|
||||
if (xProp != null) {
|
||||
if (xProp.equals("false") || xProp.equals("f")) {
|
||||
xRenderRequested = false;
|
||||
} else if (xProp.equals("True") || xProp.equals("T")) {
|
||||
xRenderRequested = true;
|
||||
xRenderVerbose = true;
|
||||
}
|
||||
|
||||
return null;
|
||||
if (xProp.equalsIgnoreCase("t") || xProp.equalsIgnoreCase("true")) {
|
||||
xRenderIgnoreLinuxVersion = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// initialize the X11 display connection
|
||||
initDisplay(glxRequested);
|
||||
|
||||
// only attempt to initialize GLX if it was requested
|
||||
if (glxRequested) {
|
||||
glxAvailable = initGLX();
|
||||
if (glxVerbose && !glxAvailable) {
|
||||
System.out.println(
|
||||
"Could not enable OpenGL " +
|
||||
"pipeline (GLX 1.3 not available)");
|
||||
}
|
||||
}
|
||||
|
||||
// only attempt to initialize Xrender if it was requested
|
||||
if (xRenderRequested) {
|
||||
xRenderAvailable = initXRender(xRenderVerbose, xRenderIgnoreLinuxVersion);
|
||||
if (xRenderVerbose && !xRenderAvailable) {
|
||||
System.out.println(
|
||||
"Could not enable XRender pipeline");
|
||||
}
|
||||
}
|
||||
|
||||
if (xRenderAvailable) {
|
||||
XRSurfaceData.initXRSurfaceData();
|
||||
}
|
||||
}
|
||||
|
||||
// Install the correct surface manager factory.
|
||||
SurfaceManagerFactory.setInstance(new UnixSurfaceManagerFactory());
|
||||
@ -299,9 +292,7 @@ public final class X11GraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
String isRemote = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("sun.java2d.remote"));
|
||||
String isRemote = System.getProperty("sun.java2d.remote");
|
||||
if (isRemote != null) {
|
||||
return isRemote.equals("false");
|
||||
}
|
||||
@ -322,41 +313,35 @@ public final class X11GraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
Boolean result = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Boolean>() {
|
||||
public Boolean run() {
|
||||
InetAddress[] remAddr = null;
|
||||
Enumeration<InetAddress> locals = null;
|
||||
Enumeration<NetworkInterface> interfaces = null;
|
||||
try {
|
||||
interfaces = NetworkInterface.getNetworkInterfaces();
|
||||
remAddr = InetAddress.getAllByName(hostName);
|
||||
if (remAddr == null) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
System.err.println("Unknown host: " + hostName);
|
||||
return Boolean.FALSE;
|
||||
} catch (SocketException e1) {
|
||||
System.err.println(e1.getMessage());
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
InetAddress[] remAddr = null;
|
||||
Enumeration<InetAddress> locals = null;
|
||||
Enumeration<NetworkInterface> interfaces = null;
|
||||
try {
|
||||
interfaces = NetworkInterface.getNetworkInterfaces();
|
||||
remAddr = InetAddress.getAllByName(hostName);
|
||||
if (remAddr == null) {
|
||||
return false;
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
System.err.println("Unknown host: " + hostName);
|
||||
return false;
|
||||
} catch (SocketException e1) {
|
||||
System.err.println(e1.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
for (; interfaces.hasMoreElements();) {
|
||||
locals = interfaces.nextElement().getInetAddresses();
|
||||
for (; locals.hasMoreElements();) {
|
||||
final InetAddress localAddr = locals.nextElement();
|
||||
for (int i = 0; i < remAddr.length; i++) {
|
||||
if (localAddr.equals(remAddr[i])) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
for (; interfaces.hasMoreElements();) {
|
||||
locals = interfaces.nextElement().getInetAddresses();
|
||||
for (; locals.hasMoreElements();) {
|
||||
final InetAddress localAddr = locals.nextElement();
|
||||
for (int i = 0; i < remAddr.length; i++) {
|
||||
if (localAddr.equals(remAddr[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}});
|
||||
return result.booleanValue();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,14 +27,12 @@ package sun.awt.screencast;
|
||||
|
||||
import sun.awt.UNIXToolkit;
|
||||
import sun.java2d.pipe.Region;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.security.AccessController;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -48,7 +46,6 @@ import java.util.stream.IntStream;
|
||||
* org.freedesktop.portal.ScreenCast API</a>
|
||||
*/
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public class ScreencastHelper {
|
||||
|
||||
static final boolean SCREENCAST_DEBUG;
|
||||
@ -70,13 +67,7 @@ public class ScreencastHelper {
|
||||
}
|
||||
|
||||
static {
|
||||
SCREENCAST_DEBUG = Boolean.parseBoolean(
|
||||
AccessController.doPrivileged(
|
||||
new GetPropertyAction(
|
||||
"awt.robot.screenshotDebug",
|
||||
"false"
|
||||
)
|
||||
));
|
||||
SCREENCAST_DEBUG = Boolean.getBoolean("awt.robot.screenshotDebug");
|
||||
|
||||
boolean loadFailed = false;
|
||||
|
||||
|
@ -37,8 +37,6 @@ import java.nio.file.WatchEvent;
|
||||
import java.nio.file.WatchKey;
|
||||
import java.nio.file.WatchService;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
@ -73,18 +71,8 @@ final class TokenStorage {
|
||||
private static final Path PROPS_PATH;
|
||||
private static final Path PROP_FILENAME;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static void doPrivilegedRunnable(Runnable runnable) {
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
runnable.run();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
@SuppressWarnings("removal")
|
||||
Path propsPath = AccessController
|
||||
.doPrivileged((PrivilegedAction<Path>) () -> setupPath());
|
||||
Path propsPath = setupPath();
|
||||
|
||||
PROPS_PATH = propsPath;
|
||||
|
||||
@ -226,9 +214,9 @@ final class TokenStorage {
|
||||
}
|
||||
|
||||
if (kind == ENTRY_CREATE) {
|
||||
doPrivilegedRunnable(() -> setFilePermission(PROPS_PATH));
|
||||
setFilePermission(PROPS_PATH);
|
||||
} else if (kind == ENTRY_MODIFY) {
|
||||
doPrivilegedRunnable(() -> readTokens(PROPS_PATH));
|
||||
readTokens(PROPS_PATH);
|
||||
} else if (kind == ENTRY_DELETE) {
|
||||
synchronized (PROPS) {
|
||||
PROPS.clear();
|
||||
@ -244,25 +232,23 @@ final class TokenStorage {
|
||||
private static WatchService watchService;
|
||||
|
||||
private static void setupWatch() {
|
||||
doPrivilegedRunnable(() -> {
|
||||
try {
|
||||
watchService =
|
||||
FileSystems.getDefault().newWatchService();
|
||||
try {
|
||||
watchService =
|
||||
FileSystems.getDefault().newWatchService();
|
||||
|
||||
PROPS_PATH
|
||||
.getParent()
|
||||
.register(watchService,
|
||||
ENTRY_CREATE,
|
||||
ENTRY_DELETE,
|
||||
ENTRY_MODIFY);
|
||||
PROPS_PATH
|
||||
.getParent()
|
||||
.register(watchService,
|
||||
ENTRY_CREATE,
|
||||
ENTRY_DELETE,
|
||||
ENTRY_MODIFY);
|
||||
|
||||
} catch (Exception e) {
|
||||
if (SCREENCAST_DEBUG) {
|
||||
System.err.printf("Token storage: failed to setup " +
|
||||
"file watch %s\n", e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (SCREENCAST_DEBUG) {
|
||||
System.err.printf("Token storage: failed to setup " +
|
||||
"file watch %s\n", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (watchService != null) {
|
||||
new WatcherThread(watchService).start();
|
||||
@ -317,7 +303,7 @@ final class TokenStorage {
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
doPrivilegedRunnable(() -> store(PROPS_PATH, "save tokens"));
|
||||
store(PROPS_PATH, "save tokens");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -372,7 +358,7 @@ final class TokenStorage {
|
||||
.toList();
|
||||
}
|
||||
|
||||
doPrivilegedRunnable(() -> removeMalformedRecords(malformed));
|
||||
removeMalformedRecords(malformed);
|
||||
|
||||
// 1. Try to find exact matches
|
||||
for (TokenItem tokenItem : allTokenItems) {
|
||||
|
@ -363,11 +363,6 @@ public class FcFontConfiguration extends FontConfiguration {
|
||||
|
||||
private File getFcInfoFile() {
|
||||
if (fcInfoFileName == null) {
|
||||
// NB need security permissions to get true IP address, and
|
||||
// we should have those as the whole initialisation is in a
|
||||
// doPrivileged block. But in this case no exception is thrown,
|
||||
// and it returns the loop back address, and so we end up with
|
||||
// "localhost"
|
||||
String hostname;
|
||||
try {
|
||||
hostname = InetAddress.getLocalHost().getHostName();
|
||||
|
@ -210,9 +210,7 @@ public abstract class X11SurfaceData extends XSurfaceData {
|
||||
|
||||
initIDs(XORComposite.class);
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
String xtextpipe = java.security.AccessController.doPrivileged
|
||||
(new sun.security.action.GetPropertyAction("sun.java2d.xtextpipe"));
|
||||
String xtextpipe = System.getProperty("sun.java2d.xtextpipe");
|
||||
if (xtextpipe == null || "true".startsWith(xtextpipe)) {
|
||||
if ("true".equals(xtextpipe)) {
|
||||
// Only verbose if they use the full string "true"
|
||||
@ -248,9 +246,7 @@ public abstract class X11SurfaceData extends XSurfaceData {
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
accelerationEnabled = Boolean.FALSE;
|
||||
} else {
|
||||
@SuppressWarnings("removal")
|
||||
String prop = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("sun.java2d.pmoffscreen"));
|
||||
String prop = System.getProperty("sun.java2d.pmoffscreen");
|
||||
if (prop != null) {
|
||||
// true iff prop==true, false otherwise
|
||||
accelerationEnabled = Boolean.valueOf(prop);
|
||||
|
@ -30,8 +30,6 @@ import java.awt.Composite;
|
||||
import java.awt.Paint;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.NoninvertibleTransformException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import sun.awt.image.PixelConverter;
|
||||
import sun.font.XRTextRenderer;
|
||||
@ -93,13 +91,7 @@ public class XRCompositeManager {
|
||||
private XRCompositeManager(XRSurfaceData surface) {
|
||||
con = new XRBackendNative();
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
String gradProp =
|
||||
AccessController.doPrivileged(new PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
return System.getProperty("sun.java2d.xrgradcache");
|
||||
}
|
||||
});
|
||||
String gradProp = System.getProperty("sun.java2d.xrgradcache");
|
||||
|
||||
enableGradCache = gradProp == null ||
|
||||
!(gradProp.equalsIgnoreCase("false") ||
|
||||
|
@ -90,16 +90,10 @@ public class CUPSPrinter {
|
||||
initStatic();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings("restricted")
|
||||
private static void initStatic() {
|
||||
// load awt library to access native code
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("awt");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
System.loadLibrary("awt");
|
||||
libFound = initIDs();
|
||||
if (libFound) {
|
||||
cupsServer = getCupsServer();
|
||||
@ -308,18 +302,12 @@ public class CUPSPrinter {
|
||||
IPPPrintService.getIPPConnection(url);
|
||||
|
||||
if (urlConnection != null) {
|
||||
@SuppressWarnings("removal")
|
||||
OutputStream os = java.security.AccessController.
|
||||
doPrivileged(new java.security.PrivilegedAction<OutputStream>() {
|
||||
public OutputStream run() {
|
||||
try {
|
||||
return urlConnection.getOutputStream();
|
||||
} catch (Exception e) {
|
||||
IPPPrintService.debug_println(debugPrefix+e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = urlConnection.getOutputStream();
|
||||
} catch (Exception e) {
|
||||
IPPPrintService.debug_println(debugPrefix+e);
|
||||
}
|
||||
|
||||
if (os == null) {
|
||||
return null;
|
||||
@ -424,17 +412,11 @@ public class CUPSPrinter {
|
||||
IPPPrintService.getIPPConnection(url);
|
||||
|
||||
if (urlConnection != null) {
|
||||
@SuppressWarnings("removal")
|
||||
OutputStream os = java.security.AccessController.
|
||||
doPrivileged(new java.security.PrivilegedAction<OutputStream>() {
|
||||
public OutputStream run() {
|
||||
try {
|
||||
return urlConnection.getOutputStream();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = urlConnection.getOutputStream();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
if (os == null) {
|
||||
return null;
|
||||
@ -507,12 +489,9 @@ public class CUPSPrinter {
|
||||
return domainSocketPathname;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static boolean isSandboxedApp() {
|
||||
if (PrintServiceLookupProvider.isMac()) {
|
||||
return java.security.AccessController
|
||||
.doPrivileged((java.security.PrivilegedAction<Boolean>) () ->
|
||||
System.getenv("APP_SANDBOX_CONTAINER_ID") != null);
|
||||
return (System.getenv("APP_SANDBOX_CONTAINER_ID") != null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -119,9 +119,7 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
private static final String FORCE_PIPE_PROP = "sun.print.ippdebug";
|
||||
|
||||
static {
|
||||
@SuppressWarnings("removal")
|
||||
String debugStr = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction(FORCE_PIPE_PROP));
|
||||
String debugStr = System.getProperty(FORCE_PIPE_PROP);
|
||||
|
||||
debugPrint = "true".equalsIgnoreCase(debugStr);
|
||||
}
|
||||
@ -1874,18 +1872,12 @@ public class IPPPrintService implements PrintService, SunPrinterJobService {
|
||||
AttributeClass.TAG_URI,
|
||||
""+myURI)};
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
OutputStream os = java.security.AccessController.
|
||||
doPrivileged(new java.security.PrivilegedAction<OutputStream>() {
|
||||
public OutputStream run() {
|
||||
try {
|
||||
return urlConnection.getOutputStream();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = urlConnection.getOutputStream();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (os == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -28,12 +28,8 @@ package sun.print;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Vector;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import javax.print.DocFlavor;
|
||||
import javax.print.MultiDocPrintService;
|
||||
import javax.print.PrintService;
|
||||
@ -95,9 +91,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup
|
||||
* can be used to force the printing code to poll or not poll
|
||||
* for PrintServices.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
String pollStr = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("sun.java2d.print.polling"));
|
||||
String pollStr = System.getProperty("sun.java2d.print.polling");
|
||||
|
||||
if (pollStr != null) {
|
||||
if (pollStr.equalsIgnoreCase("true")) {
|
||||
@ -111,10 +105,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup
|
||||
* can be used to specify minimum refresh time (in seconds)
|
||||
* for polling PrintServices. The default is 120.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
String refreshTimeStr = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction(
|
||||
"sun.java2d.print.minRefreshTime"));
|
||||
String refreshTimeStr = System.getProperty("sun.java2d.print.minRefreshTime");
|
||||
|
||||
if (refreshTimeStr != null) {
|
||||
try {
|
||||
@ -132,9 +123,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup
|
||||
* take lots of time if thousands of printers are attached to a server.
|
||||
*/
|
||||
if (isAIX()) {
|
||||
@SuppressWarnings("removal")
|
||||
String aixPrinterEnumerator = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("sun.java2d.print.aix.lpstat"));
|
||||
String aixPrinterEnumerator = System.getProperty("sun.java2d.print.aix.lpstat");
|
||||
|
||||
if (aixPrinterEnumerator != null) {
|
||||
if (aixPrinterEnumerator.equalsIgnoreCase("lpstat")) {
|
||||
@ -202,18 +191,15 @@ public class PrintServiceLookupProvider extends PrintServiceLookup
|
||||
return BSD_LPD;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public PrintServiceLookupProvider() {
|
||||
// start the printer listener thread
|
||||
if (pollServices) {
|
||||
AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
|
||||
Thread thr = new Thread(ThreadGroupUtils.getRootThreadGroup(),
|
||||
new PrinterChangeListener(),
|
||||
"PrinterListener", 0, false);
|
||||
thr.setContextClassLoader(null);
|
||||
thr.setDaemon(true);
|
||||
return thr;
|
||||
}).start();
|
||||
Thread thr = new Thread(ThreadGroupUtils.getRootThreadGroup(),
|
||||
new PrinterChangeListener(),
|
||||
"PrinterListener", 0, false);
|
||||
thr.setContextClassLoader(null);
|
||||
thr.setDaemon(true);
|
||||
thr.start();
|
||||
IPPPrintService.debug_println(debugPrefix+"polling turned on");
|
||||
}
|
||||
}
|
||||
@ -871,7 +857,6 @@ public class PrintServiceLookupProvider extends PrintServiceLookup
|
||||
return printerNames.toArray(new String[printerNames.size()]);
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
static String[] execCmd(final String command) {
|
||||
ArrayList<String> results = null;
|
||||
try {
|
||||
@ -886,51 +871,46 @@ public class PrintServiceLookupProvider extends PrintServiceLookup
|
||||
cmd[2] = "LC_ALL=C " + command;
|
||||
}
|
||||
|
||||
results = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<ArrayList<String>>() {
|
||||
public ArrayList<String> run() throws IOException {
|
||||
Process proc;
|
||||
BufferedReader bufferedReader = null;
|
||||
File f = Files.createTempFile("prn", "xc")
|
||||
.toFile();
|
||||
cmd[2] = cmd[2] + ">" + f.getAbsolutePath();
|
||||
|
||||
Process proc;
|
||||
BufferedReader bufferedReader = null;
|
||||
File f = Files.createTempFile("prn","xc").toFile();
|
||||
cmd[2] = cmd[2]+">"+f.getAbsolutePath();
|
||||
|
||||
proc = Runtime.getRuntime().exec(cmd);
|
||||
try {
|
||||
boolean done = false; // in case of interrupt.
|
||||
while (!done) {
|
||||
try {
|
||||
proc.waitFor();
|
||||
done = true;
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (proc.exitValue() == 0) {
|
||||
FileReader reader = new FileReader(f);
|
||||
bufferedReader = new BufferedReader(reader);
|
||||
String line;
|
||||
ArrayList<String> results = new ArrayList<>();
|
||||
while ((line = bufferedReader.readLine())
|
||||
!= null) {
|
||||
results.add(line);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
} finally {
|
||||
f.delete();
|
||||
// promptly close all streams.
|
||||
if (bufferedReader != null) {
|
||||
bufferedReader.close();
|
||||
}
|
||||
proc.getInputStream().close();
|
||||
proc.getErrorStream().close();
|
||||
proc.getOutputStream().close();
|
||||
}
|
||||
return null;
|
||||
proc = Runtime.getRuntime().exec(cmd);
|
||||
try {
|
||||
boolean done = false; // in case of interrupt.
|
||||
while (!done) {
|
||||
try {
|
||||
proc.waitFor();
|
||||
done = true;
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
});
|
||||
} catch (PrivilegedActionException e) {
|
||||
}
|
||||
|
||||
if (proc.exitValue() == 0) {
|
||||
FileReader reader = new FileReader(f);
|
||||
bufferedReader = new BufferedReader(reader);
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine())
|
||||
!= null) {
|
||||
results.add(line);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
f.delete();
|
||||
// promptly close all streams.
|
||||
if (bufferedReader != null) {
|
||||
bufferedReader.close();
|
||||
}
|
||||
proc.getInputStream()
|
||||
.close();
|
||||
proc.getErrorStream()
|
||||
.close();
|
||||
proc.getOutputStream()
|
||||
.close();
|
||||
}
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
if (results == null) {
|
||||
return new String[0];
|
||||
|
@ -86,7 +86,6 @@ import java.awt.print.Printable;
|
||||
import java.awt.print.PrinterException;
|
||||
|
||||
|
||||
|
||||
public class UnixPrintJob implements CancelablePrintJob {
|
||||
private static String debugPrefix = "UnixPrintJob>> ";
|
||||
|
||||
@ -525,8 +524,7 @@ public class UnixPrintJob implements CancelablePrintJob {
|
||||
|
||||
// now spool the print data.
|
||||
PrinterOpener po = new PrinterOpener();
|
||||
@SuppressWarnings("removal")
|
||||
var dummy = java.security.AccessController.doPrivileged(po);
|
||||
po.run();
|
||||
if (po.pex != null) {
|
||||
throw po.pex;
|
||||
}
|
||||
@ -599,8 +597,7 @@ public class UnixPrintJob implements CancelablePrintJob {
|
||||
|
||||
if (mDestType == UnixPrintJob.DESTPRINTER) {
|
||||
PrinterSpooler spooler = new PrinterSpooler();
|
||||
@SuppressWarnings("removal")
|
||||
var dummy2 = java.security.AccessController.doPrivileged(spooler);
|
||||
spooler.run();
|
||||
if (spooler.pex != null) {
|
||||
throw spooler.pex;
|
||||
}
|
||||
@ -911,9 +908,7 @@ public class UnixPrintJob implements CancelablePrintJob {
|
||||
private String mDestination, mOptions="";
|
||||
private boolean mNoJobSheet = false;
|
||||
|
||||
// Inner class to run "privileged" to open the printer output stream.
|
||||
|
||||
private class PrinterOpener implements java.security.PrivilegedAction<OutputStream> {
|
||||
private class PrinterOpener {
|
||||
PrintException pex;
|
||||
OutputStream result;
|
||||
|
||||
@ -941,9 +936,7 @@ public class UnixPrintJob implements CancelablePrintJob {
|
||||
}
|
||||
}
|
||||
|
||||
// Inner class to run "privileged" to invoke the system print command
|
||||
|
||||
private class PrinterSpooler implements java.security.PrivilegedAction<Object> {
|
||||
private class PrinterSpooler {
|
||||
PrintException pex;
|
||||
|
||||
private void handleProcessFailure(final Process failedProcess,
|
||||
|
@ -145,9 +145,7 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
|
||||
"| grep -E '^[ 0-9a-zA-Z_-]*@' | awk '{print $4}'"
|
||||
};
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static String encoding = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("file.encoding"));
|
||||
private static String encoding = System.getProperty("file.encoding");
|
||||
|
||||
/* let's try to support a few of these */
|
||||
private static final Class<?>[] serviceAttrCats = {
|
||||
|
Loading…
Reference in New Issue
Block a user