8344058: Remove doPrivileged calls from macos platform sources in the java.desktop module
Reviewed-by: prr, aivanov
This commit is contained in:
parent
70eb95f848
commit
92271af635
@ -25,12 +25,9 @@
|
||||
|
||||
package apple.laf;
|
||||
|
||||
import java.security.AccessController;
|
||||
|
||||
import apple.laf.JRSUIConstants.Hit;
|
||||
import apple.laf.JRSUIConstants.ScrollBarPart;
|
||||
import com.apple.laf.AquaImageFactory.NineSliceMetrics;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
public final class JRSUIUtils {
|
||||
|
||||
@ -69,8 +66,7 @@ public final class JRSUIUtils {
|
||||
final int majorVersion, final int minorVersion, final boolean inclusive,
|
||||
final boolean matchBelow, final boolean matchAbove) {
|
||||
// split the "x.y.z" version number
|
||||
@SuppressWarnings("removal")
|
||||
String osVersion = AccessController.doPrivileged(new GetPropertyAction("os.version"));
|
||||
String osVersion = System.getProperty("os.version");
|
||||
String[] fragments = osVersion.split("\\.");
|
||||
|
||||
if (fragments.length < 2) return false;
|
||||
|
@ -58,15 +58,9 @@ public class FileManager {
|
||||
loadOSXLibrary();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings("restricted")
|
||||
private static void loadOSXLibrary() {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("osx");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
System.loadLibrary("osx");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,15 +65,9 @@ class AquaFileView extends FileView {
|
||||
loadOSXUILibrary();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings("restricted")
|
||||
private static void loadOSXUILibrary() {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("osxui");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
System.loadLibrary("osxui");
|
||||
}
|
||||
|
||||
// TODO: Un-comment this out when the native version exists
|
||||
|
@ -27,11 +27,11 @@ package com.apple.laf;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
import com.apple.eawt.Application;
|
||||
import sun.lwawt.macosx.LWCToolkit;
|
||||
import apple.laf.JRSUIConstants.AlignmentHorizontal;
|
||||
import apple.laf.JRSUIConstants.AlignmentVertical;
|
||||
@ -82,22 +82,12 @@ public class AquaImageFactory {
|
||||
return getAppIconCompositedOn(lockIcon);
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
static Image getGenericJavaIcon() {
|
||||
return java.security.AccessController.doPrivileged(new PrivilegedAction<Image>() {
|
||||
public Image run() {
|
||||
return com.apple.eawt.Application.getApplication().getDockIconImage();
|
||||
}
|
||||
});
|
||||
return Application.getApplication().getDockIconImage();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
static String getPathToThisApplication() {
|
||||
return java.security.AccessController.doPrivileged(new PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
return FileManager.getPathToApplicationBundle();
|
||||
}
|
||||
});
|
||||
return FileManager.getPathToApplicationBundle();
|
||||
}
|
||||
|
||||
static IconUIResource getAppIconCompositedOn(final SystemIcon systemIcon) {
|
||||
|
@ -154,22 +154,10 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
|
||||
* @see #uninitialize
|
||||
* @see UIManager#setLookAndFeel
|
||||
*/
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings("restricted")
|
||||
public void initialize() {
|
||||
java.security.AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("osxui");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
java.security.AccessController.doPrivileged(new PrivilegedAction<Void>(){
|
||||
@Override
|
||||
public Void run() {
|
||||
JRSUIControl.initJRSUI();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
System.loadLibrary("osxui");
|
||||
JRSUIControl.initJRSUI();
|
||||
|
||||
super.initialize();
|
||||
final ScreenPopupFactory spf = new ScreenPopupFactory();
|
||||
|
@ -29,7 +29,6 @@ import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.MenuBar;
|
||||
import java.security.AccessController;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
@ -38,18 +37,13 @@ import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicMenuBarUI;
|
||||
|
||||
import sun.lwawt.macosx.LWCToolkit;
|
||||
import sun.security.action.GetBooleanAction;
|
||||
|
||||
// MenuBar implementation for Mac L&F
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings("restricted")
|
||||
public class AquaMenuBarUI extends BasicMenuBarUI implements ScreenMenuBarProvider {
|
||||
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
(java.security.PrivilegedAction<Void>) () -> {
|
||||
System.loadLibrary("osxui");
|
||||
return null;
|
||||
});
|
||||
System.loadLibrary("osxui");
|
||||
}
|
||||
|
||||
// Utilities
|
||||
@ -151,7 +145,6 @@ public class AquaMenuBarUI extends BasicMenuBarUI implements ScreenMenuBarProvid
|
||||
public static boolean getScreenMenuBarProperty() {
|
||||
// Do not allow AWT to set the screen menu bar if it's embedded in another UI toolkit
|
||||
if (LWCToolkit.isEmbedded()) return false;
|
||||
return AccessController.doPrivileged(new GetBooleanAction(
|
||||
AquaLookAndFeel.sPropertyPrefix + "useScreenMenuBar"));
|
||||
return Boolean.getBoolean(AquaLookAndFeel.sPropertyPrefix + "useScreenMenuBar");
|
||||
}
|
||||
}
|
||||
|
@ -32,16 +32,10 @@ import javax.swing.plaf.UIResource;
|
||||
|
||||
import com.apple.laf.AquaUtils.RecyclableSingleton;
|
||||
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings("restricted")
|
||||
public class AquaNativeResources {
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("osxui");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
System.loadLibrary("osxui");
|
||||
}
|
||||
|
||||
// TODO: removing CColorPaint for now
|
||||
|
@ -27,7 +27,6 @@ package com.apple.laf;
|
||||
|
||||
import java.awt.*;
|
||||
import java.beans.*;
|
||||
import java.security.AccessController;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
@ -38,7 +37,6 @@ import apple.laf.JRSUIConstants.*;
|
||||
|
||||
import com.apple.laf.AquaUtils.RecyclableSingleton;
|
||||
import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
public class AquaUtilControlSize {
|
||||
protected static final String CLIENT_PROPERTY_KEY = "JComponent.sizeVariant";
|
||||
@ -72,9 +70,7 @@ public class AquaUtilControlSize {
|
||||
}
|
||||
|
||||
private static Size getDefaultSize() {
|
||||
@SuppressWarnings("removal")
|
||||
final String sizeProperty = AccessController.doPrivileged(
|
||||
new GetPropertyAction(SYSTEM_PROPERTY_KEY));
|
||||
final String sizeProperty = System.getProperty(SYSTEM_PROPERTY_KEY);
|
||||
final JRSUIConstants.Size size = getSizeFromString(sizeProperty);
|
||||
if (size != null) return size;
|
||||
return JRSUIConstants.Size.REGULAR;
|
||||
|
@ -29,8 +29,6 @@ import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
@ -41,7 +39,6 @@ import sun.awt.AppContext;
|
||||
|
||||
import sun.lwawt.macosx.CPlatformWindow;
|
||||
import sun.reflect.misc.ReflectUtil;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import com.apple.laf.AquaImageFactory.SlicedImageControl;
|
||||
@ -205,9 +202,7 @@ final class AquaUtils {
|
||||
private static final RecyclableSingleton<Boolean> enableAnimations = new RecyclableSingleton<Boolean>() {
|
||||
@Override
|
||||
protected Boolean getInstance() {
|
||||
@SuppressWarnings("removal")
|
||||
final String sizeProperty = (String) AccessController.doPrivileged((PrivilegedAction<?>)new GetPropertyAction(
|
||||
ANIMATIONS_PROPERTY));
|
||||
final String sizeProperty = System.getProperty(ANIMATIONS_PROPERTY);
|
||||
return !"false".equals(sizeProperty); // should be true by default
|
||||
}
|
||||
};
|
||||
@ -332,25 +327,17 @@ final class AquaUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static final RecyclableSingleton<Method> getJComponentGetFlagMethod = new RecyclableSingleton<Method>() {
|
||||
@Override
|
||||
protected Method getInstance() {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<Method>() {
|
||||
@Override
|
||||
public Method run() {
|
||||
try {
|
||||
final Method method = JComponent.class.getDeclaredMethod(
|
||||
"getFlag", new Class<?>[] { int.class });
|
||||
method.setAccessible(true);
|
||||
return method;
|
||||
} catch (final Throwable ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
try {
|
||||
final Method method = JComponent.class.getDeclaredMethod(
|
||||
"getFlag", new Class<?>[]{int.class});
|
||||
method.setAccessible(true);
|
||||
return method;
|
||||
} catch (final Throwable ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -45,15 +45,9 @@ final class ScreenMenu extends Menu
|
||||
loadAWTLibrary();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings("restricted")
|
||||
private static void loadAWTLibrary() {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("awt");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
System.loadLibrary("awt");
|
||||
}
|
||||
|
||||
// screen menu stuff
|
||||
|
@ -27,17 +27,12 @@ package sun.awt;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Toolkit;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings({"restricted"})
|
||||
public class PlatformGraphicsInfo {
|
||||
|
||||
static {
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
System.loadLibrary("awt");
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public static GraphicsEnvironment createGE() {
|
||||
|
@ -27,8 +27,6 @@ package sun.font;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
@ -147,10 +145,7 @@ public final class CFontManager extends SunFontManager {
|
||||
protected void registerFontsInDir(final String dirName, boolean useJavaRasterizer,
|
||||
int fontRank, boolean defer, boolean resolveSymLinks) {
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
String[] files = AccessController.doPrivileged((PrivilegedAction<String[]>) () -> {
|
||||
return new File(dirName).list(getTrueTypeFilter());
|
||||
});
|
||||
String[] files = new File(dirName).list(getTrueTypeFilter());
|
||||
|
||||
if (files == null) {
|
||||
return;
|
||||
@ -205,24 +200,17 @@ public final class CFontManager extends SunFontManager {
|
||||
Object waitForFontsToBeLoaded = new Object();
|
||||
private boolean loadedAllFonts = false;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
|
||||
public void loadFonts()
|
||||
{
|
||||
synchronized(waitForFontsToBeLoaded)
|
||||
{
|
||||
super.loadFonts();
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
if (!loadedAllFonts) {
|
||||
loadNativeFonts();
|
||||
registerItalicDerived();
|
||||
loadedAllFonts = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
if (!loadedAllFonts) {
|
||||
loadNativeFonts();
|
||||
registerItalicDerived();
|
||||
loadedAllFonts = true;
|
||||
}
|
||||
|
||||
String defaultFont = "Lucida Grande";
|
||||
String defaultFallback = "Lucida Grande";
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.java2d;
|
||||
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.java2d.metal.MTLGraphicsConfig;
|
||||
import sun.java2d.opengl.CGLGraphicsConfig;
|
||||
|
||||
@ -83,59 +82,53 @@ public class MacOSFlags {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static void initJavaFlags() {
|
||||
java.security.AccessController.doPrivileged(
|
||||
(PrivilegedAction<Object>) () -> {
|
||||
PropertyState oglState = getBooleanProp("sun.java2d.opengl", PropertyState.UNSPECIFIED);
|
||||
PropertyState metalState = getBooleanProp("sun.java2d.metal", PropertyState.UNSPECIFIED);
|
||||
PropertyState oglState = getBooleanProp("sun.java2d.opengl", PropertyState.UNSPECIFIED);
|
||||
PropertyState metalState = getBooleanProp("sun.java2d.metal", PropertyState.UNSPECIFIED);
|
||||
|
||||
// Handle invalid combinations to use the default rendering pipeline
|
||||
// The default rendering pipeline is Metal
|
||||
if ((oglState == PropertyState.UNSPECIFIED && metalState == PropertyState.UNSPECIFIED) ||
|
||||
(oglState == PropertyState.DISABLED && metalState == PropertyState.DISABLED) ||
|
||||
(oglState == PropertyState.ENABLED && metalState == PropertyState.ENABLED)) {
|
||||
metalState = PropertyState.ENABLED; // Enable default pipeline
|
||||
oglState = PropertyState.DISABLED; // Disable non-default pipeline
|
||||
}
|
||||
// Handle invalid combinations to use the default rendering pipeline
|
||||
// The default rendering pipeline is Metal
|
||||
if ((oglState == PropertyState.UNSPECIFIED && metalState == PropertyState.UNSPECIFIED) ||
|
||||
(oglState == PropertyState.DISABLED && metalState == PropertyState.DISABLED) ||
|
||||
(oglState == PropertyState.ENABLED && metalState == PropertyState.ENABLED)) {
|
||||
metalState = PropertyState.ENABLED; // Enable default pipeline
|
||||
oglState = PropertyState.DISABLED; // Disable non-default pipeline
|
||||
}
|
||||
|
||||
if (metalState == PropertyState.UNSPECIFIED) {
|
||||
if (oglState == PropertyState.DISABLED) {
|
||||
oglEnabled = false;
|
||||
metalEnabled = true;
|
||||
} else {
|
||||
oglEnabled = true;
|
||||
metalEnabled = false;
|
||||
}
|
||||
} else if (metalState == PropertyState.ENABLED) {
|
||||
oglEnabled = false;
|
||||
metalEnabled = true;
|
||||
} else if (metalState == PropertyState.DISABLED) {
|
||||
oglEnabled = true;
|
||||
metalEnabled = false;
|
||||
}
|
||||
if (metalState == PropertyState.UNSPECIFIED) {
|
||||
if (oglState == PropertyState.DISABLED) {
|
||||
oglEnabled = false;
|
||||
metalEnabled = true;
|
||||
} else {
|
||||
oglEnabled = true;
|
||||
metalEnabled = false;
|
||||
}
|
||||
} else if (metalState == PropertyState.ENABLED) {
|
||||
oglEnabled = false;
|
||||
metalEnabled = true;
|
||||
} else if (metalState == PropertyState.DISABLED) {
|
||||
oglEnabled = true;
|
||||
metalEnabled = false;
|
||||
}
|
||||
|
||||
oglVerbose = isBooleanPropTrueVerbose("sun.java2d.opengl");
|
||||
metalVerbose = isBooleanPropTrueVerbose("sun.java2d.metal");
|
||||
oglVerbose = isBooleanPropTrueVerbose("sun.java2d.opengl");
|
||||
metalVerbose = isBooleanPropTrueVerbose("sun.java2d.metal");
|
||||
|
||||
if (oglEnabled && !metalEnabled) {
|
||||
// Check whether OGL is available
|
||||
if (!CGLGraphicsConfig.isCGLAvailable()) {
|
||||
if (oglVerbose) {
|
||||
System.out.println("Could not enable OpenGL pipeline (CGL not available)");
|
||||
}
|
||||
oglEnabled = false;
|
||||
metalEnabled = true;
|
||||
}
|
||||
}
|
||||
if (oglEnabled && !metalEnabled) {
|
||||
// Check whether OGL is available
|
||||
if (!CGLGraphicsConfig.isCGLAvailable()) {
|
||||
if (oglVerbose) {
|
||||
System.out.println("Could not enable OpenGL pipeline (CGL not available)");
|
||||
}
|
||||
oglEnabled = false;
|
||||
metalEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// At this point one of the rendering pipeline must be enabled.
|
||||
if (!metalEnabled && !oglEnabled) {
|
||||
throw new InternalError("Error - unable to initialize any rendering pipeline.");
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
// At this point one of the rendering pipeline must be enabled.
|
||||
if (!metalEnabled && !oglEnabled) {
|
||||
throw new InternalError("Error - unable to initialize any rendering pipeline.");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isMetalEnabled() {
|
||||
|
@ -58,8 +58,6 @@ import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.io.File;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import static sun.java2d.metal.MTLContext.MTLContextCaps.CAPS_EXT_GRAD_SHADER;
|
||||
import static sun.java2d.pipe.hw.AccelSurface.TEXTURE;
|
||||
@ -73,11 +71,10 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
|
||||
{
|
||||
private static ImageCapabilities imageCaps = new MTLImageCaps();
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static final String mtlShadersLib = AccessController.doPrivileged(
|
||||
(PrivilegedAction<String>) () ->
|
||||
|
||||
private static final String mtlShadersLib =
|
||||
System.getProperty("java.home", "") + File.separator +
|
||||
"lib" + File.separator + "shaders.metallib");
|
||||
"lib" + File.separator + "shaders.metallib";
|
||||
|
||||
|
||||
private BufferCapabilities bufferCaps;
|
||||
|
@ -29,9 +29,6 @@ import sun.awt.util.ThreadGroupUtils;
|
||||
import sun.java2d.pipe.RenderBuffer;
|
||||
import sun.java2d.pipe.RenderQueue;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import static sun.java2d.pipe.BufferedOpCodes.DISPOSE_CONFIG;
|
||||
import static sun.java2d.pipe.BufferedOpCodes.SYNC;
|
||||
|
||||
@ -46,13 +43,12 @@ public class MTLRenderQueue extends RenderQueue {
|
||||
private static MTLRenderQueue theInstance;
|
||||
private final QueueFlusher flusher;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private MTLRenderQueue() {
|
||||
/*
|
||||
* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
*/
|
||||
flusher = AccessController.doPrivileged((PrivilegedAction<QueueFlusher>) QueueFlusher::new);
|
||||
flusher = new QueueFlusher();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,8 +58,6 @@ import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.ContainerPeer;
|
||||
import java.awt.peer.KeyboardFocusManagerPeer;
|
||||
import java.lang.reflect.Field;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
@ -260,37 +258,26 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
|
||||
* This method must be called under Toolkit.getDefaultToolkit() lock
|
||||
* and followed by setToolkitAWTEventListener()
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
protected final AWTEventListener getToolkitAWTEventListener() {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<AWTEventListener>() {
|
||||
public AWTEventListener run() {
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
try {
|
||||
Field field = Toolkit.class.getDeclaredField("eventListener");
|
||||
field.setAccessible(true);
|
||||
return (AWTEventListener) field.get(toolkit);
|
||||
} catch (Exception e) {
|
||||
throw new InternalError(e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
try {
|
||||
Field field = Toolkit.class.getDeclaredField("eventListener");
|
||||
field.setAccessible(true);
|
||||
return (AWTEventListener) field.get(toolkit);
|
||||
} catch (Exception e) {
|
||||
throw new InternalError(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
protected final void setToolkitAWTEventListener(final AWTEventListener listener) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
try {
|
||||
Field field = Toolkit.class.getDeclaredField("eventListener");
|
||||
field.setAccessible(true);
|
||||
field.set(toolkit, listener);
|
||||
} catch (Exception e) {
|
||||
throw new InternalError(e.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
try {
|
||||
Field field = Toolkit.class.getDeclaredField("eventListener");
|
||||
field.setAccessible(true);
|
||||
field.set(toolkit, listener);
|
||||
} catch (Exception e) {
|
||||
throw new InternalError(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,6 @@ import java.awt.datatransfer.*;
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.image.*;
|
||||
import java.awt.peer.*;
|
||||
import java.security.*;
|
||||
import java.util.*;
|
||||
|
||||
import sun.awt.*;
|
||||
@ -69,27 +68,23 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
* This method waits for the toolkit to be completely initialized
|
||||
* and returns before the message pump is started.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
protected final void init() {
|
||||
AWTAutoShutdown.notifyToolkitThreadBusy();
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
Runnable shutdownRunnable = () -> {
|
||||
shutdown();
|
||||
waitForRunState(STATE_CLEANUP);
|
||||
};
|
||||
Thread shutdown = new Thread(
|
||||
ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable,
|
||||
"AWT-Shutdown", 0, false);
|
||||
shutdown.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(shutdown);
|
||||
String name = "AWT-LW";
|
||||
Thread toolkitThread = new Thread(
|
||||
ThreadGroupUtils.getRootThreadGroup(), this, name, 0, false);
|
||||
toolkitThread.setDaemon(true);
|
||||
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
toolkitThread.start();
|
||||
return null;
|
||||
});
|
||||
Runnable shutdownRunnable = () -> {
|
||||
shutdown();
|
||||
waitForRunState(STATE_CLEANUP);
|
||||
};
|
||||
Thread shutdown = new Thread(
|
||||
ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable,
|
||||
"AWT-Shutdown", 0, false);
|
||||
shutdown.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(shutdown);
|
||||
String name = "AWT-LW";
|
||||
Thread toolkitThread = new Thread(
|
||||
ThreadGroupUtils.getRootThreadGroup(), this, name, 0, false);
|
||||
toolkitThread.setDaemon(true);
|
||||
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
toolkitThread.start();
|
||||
waitForRunState(STATE_MESSAGELOOP);
|
||||
}
|
||||
|
||||
|
@ -77,16 +77,10 @@ class CAccessibility implements PropertyChangeListener {
|
||||
loadAWTLibrary();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings("restricted")
|
||||
private static void loadAWTLibrary() {
|
||||
// Need to load the native library for this code.
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("awt");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
System.loadLibrary("awt");
|
||||
}
|
||||
|
||||
static CAccessibility sAccessibility;
|
||||
|
@ -59,8 +59,7 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
|
||||
private static double fMaxImageSize = 128.0;
|
||||
|
||||
static {
|
||||
@SuppressWarnings("removal")
|
||||
String propValue = java.security.AccessController.doPrivileged(new sun.security.action.GetPropertyAction("apple.awt.dnd.defaultDragImageSize"));
|
||||
String propValue = System.getProperty("apple.awt.dnd.defaultDragImageSize");
|
||||
if (propValue != null) {
|
||||
try {
|
||||
double value = Double.parseDouble(propValue);
|
||||
|
@ -51,12 +51,10 @@ import java.awt.peer.ContainerPeer;
|
||||
import java.awt.peer.FileDialogPeer;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.security.AccessController;
|
||||
import java.util.List;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.java2d.pipe.Region;
|
||||
import sun.security.action.GetBooleanAction;
|
||||
|
||||
class CFileDialog implements FileDialogPeer {
|
||||
|
||||
@ -65,12 +63,8 @@ class CFileDialog implements FileDialogPeer {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@SuppressWarnings("removal")
|
||||
boolean navigateApps = !AccessController.doPrivileged(
|
||||
new GetBooleanAction("apple.awt.use-file-dialog-packages"));
|
||||
@SuppressWarnings("removal")
|
||||
boolean chooseDirectories = AccessController.doPrivileged(
|
||||
new GetBooleanAction("apple.awt.fileDialogForDirectories"));
|
||||
boolean navigateApps = !Boolean.getBoolean("apple.awt.use-file-dialog-packages");
|
||||
boolean chooseDirectories = Boolean.getBoolean("apple.awt.fileDialogForDirectories");
|
||||
|
||||
int dialogMode = target.getMode();
|
||||
String title = target.getTitle();
|
||||
|
@ -46,7 +46,6 @@ import java.awt.event.WindowStateListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.AccessController;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
@ -70,7 +69,6 @@ import sun.lwawt.LWToolkit;
|
||||
import sun.lwawt.LWWindowPeer;
|
||||
import sun.lwawt.LWWindowPeer.PeerType;
|
||||
import sun.lwawt.PlatformWindow;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
|
||||
@ -131,9 +129,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
|
||||
// This system property is named as jdk.* because it is not specific to AWT
|
||||
// and it is also used in JavaFX
|
||||
@SuppressWarnings("removal")
|
||||
public static final String MAC_OS_TABBED_WINDOW = AccessController.doPrivileged(
|
||||
new GetPropertyAction("jdk.allowMacOSTabbedWindows"));
|
||||
public static final String MAC_OS_TABBED_WINDOW = System.getProperty("jdk.allowMacOSTabbedWindows");
|
||||
|
||||
// Yeah, I know. But it's easier to deal with ints from JNI
|
||||
static final int MODELESS = 0;
|
||||
|
@ -31,8 +31,6 @@ import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.print.*;
|
||||
import java.net.URI;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.print.*;
|
||||
@ -284,7 +282,6 @@ public final class CPrinterJob extends RasterPrinterJob {
|
||||
return destinationAttr;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
@Override
|
||||
public void print(PrintRequestAttributeSet attributes) throws PrinterException {
|
||||
// NOTE: Some of this code is copied from RasterPrinterJob.
|
||||
@ -344,14 +341,7 @@ public final class CPrinterJob extends RasterPrinterJob {
|
||||
|
||||
onEventThread = true;
|
||||
|
||||
printingLoop = AccessController.doPrivileged(new PrivilegedAction<SecondaryLoop>() {
|
||||
@Override
|
||||
public SecondaryLoop run() {
|
||||
return Toolkit.getDefaultToolkit()
|
||||
.getSystemEventQueue()
|
||||
.createSecondaryLoop();
|
||||
}
|
||||
});
|
||||
printingLoop = Toolkit.getDefaultToolkit().getSystemEventQueue().createSecondaryLoop();
|
||||
|
||||
try {
|
||||
// Fire off the print rendering loop on the AppKit thread, and don't have
|
||||
|
@ -45,8 +45,6 @@ import java.awt.geom.Point2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.peer.TrayIconPeer;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.UIManager;
|
||||
@ -71,10 +69,7 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
|
||||
// events between MOUSE_PRESSED and MOUSE_RELEASED for particular button
|
||||
private static int mouseClickButtons = 0;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static final boolean useTemplateImages = AccessController.doPrivileged((PrivilegedAction<Boolean>)
|
||||
() -> Boolean.getBoolean("apple.awt.enableTemplateImages")
|
||||
);
|
||||
private static final boolean useTemplateImages = Boolean.getBoolean("apple.awt.enableTemplateImages");
|
||||
|
||||
CTrayIcon(TrayIcon target) {
|
||||
super(0, true);
|
||||
|
@ -87,8 +87,6 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -146,24 +144,14 @@ public final class LWCToolkit extends LWToolkit {
|
||||
static {
|
||||
System.err.flush();
|
||||
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
ResourceBundle platformResources = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<ResourceBundle>() {
|
||||
@Override
|
||||
public ResourceBundle run() {
|
||||
ResourceBundle platformResources = null;
|
||||
try {
|
||||
platformResources = ResourceBundle.getBundle("sun.awt.resources.awtosx");
|
||||
} catch (MissingResourceException e) {
|
||||
// No resource file; defaults will be used.
|
||||
}
|
||||
ResourceBundle platformResources = null;
|
||||
try {
|
||||
platformResources = ResourceBundle.getBundle("sun.awt.resources.awtosx");
|
||||
} catch (MissingResourceException e) {
|
||||
// No resource file; defaults will be used.
|
||||
}
|
||||
|
||||
System.loadLibrary("awt");
|
||||
System.loadLibrary("fontmanager");
|
||||
|
||||
return platformResources;
|
||||
}
|
||||
});
|
||||
loadLibrary();
|
||||
|
||||
if (!GraphicsEnvironment.isHeadless() &&
|
||||
!PlatformGraphicsInfo.isInAquaSession())
|
||||
@ -178,32 +166,28 @@ public final class LWCToolkit extends LWToolkit {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("restricted")
|
||||
private static void loadLibrary() {
|
||||
System.loadLibrary("awt");
|
||||
System.loadLibrary("fontmanager");
|
||||
}
|
||||
|
||||
/*
|
||||
* If true we operate in normal mode and nested runloop is executed in JavaRunLoopMode
|
||||
* If false we operate in singleThreaded FX/AWT interop mode and nested loop uses NSDefaultRunLoopMode
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private static final boolean inAWT
|
||||
= AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
|
||||
@Override
|
||||
public Boolean run() {
|
||||
return !Boolean.parseBoolean(
|
||||
= !Boolean.parseBoolean(
|
||||
System.getProperty("javafx.embed.singleThread", "false"));
|
||||
}
|
||||
});
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public LWCToolkit() {
|
||||
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);
|
||||
System.setProperty(extraButtons, "" + areExtraMouseButtonsEnabled);
|
||||
initAppkit(ThreadGroupUtils.getRootThreadGroup(),
|
||||
GraphicsEnvironment.isHeadless());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
@ -254,13 +238,9 @@ public final class LWCToolkit extends LWToolkit {
|
||||
}
|
||||
|
||||
// This is only called from native code.
|
||||
@SuppressWarnings("removal")
|
||||
static void systemColorsChanged() {
|
||||
EventQueue.invokeLater(() -> {
|
||||
AccessController.doPrivileged( (PrivilegedAction<Object>) () -> {
|
||||
AWTAccessor.getSystemColorAccessor().updateSystemColors();
|
||||
return null;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -592,13 +572,9 @@ public final class LWCToolkit extends LWToolkit {
|
||||
private static final String APPKIT_THREAD_NAME = "AppKit Thread";
|
||||
|
||||
// Intended to be called from the LWCToolkit.m only.
|
||||
@SuppressWarnings("removal")
|
||||
private static void installToolkitThreadInJava() {
|
||||
Thread.currentThread().setName(APPKIT_THREAD_NAME);
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
Thread.currentThread().setContextClassLoader(null);
|
||||
return null;
|
||||
});
|
||||
Thread.currentThread().setContextClassLoader(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user