Skip to content

Commit

Permalink
8264139: Suppress removal warnings for Security Manager methods
Browse files Browse the repository at this point in the history
Co-authored-by: Weijun Wang <weijun@openjdk.org>
Co-authored-by: Kevin Rushforth <kcr@openjdk.org>
Reviewed-by: aghaisas, arapte
  • Loading branch information
kevinrushforth and wangweij committed Jun 15, 2021
1 parent 0ffa8e2 commit c81a722
Show file tree
Hide file tree
Showing 194 changed files with 586 additions and 144 deletions.
30 changes: 23 additions & 7 deletions modules/javafx.base/src/main/java/com/sun/javafx/PlatformUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,28 @@ public class PlatformUtil {
private static String javafxPlatform;

static {
javafxPlatform = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("javafx.platform"));
@SuppressWarnings("removal")
String str1 = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("javafx.platform"));
javafxPlatform = str1;

loadProperties();
embedded = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> Boolean.getBoolean("com.sun.javafx.isEmbedded"));
embeddedType = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("embedded"));
useEGL = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> Boolean.getBoolean("use.egl"));

@SuppressWarnings("removal")
boolean bool1 = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> Boolean.getBoolean("com.sun.javafx.isEmbedded"));
embedded = bool1;

@SuppressWarnings("removal")
String str2 = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("embedded"));
embeddedType = str2;

@SuppressWarnings("removal")
boolean bool2 = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> Boolean.getBoolean("use.egl"));
useEGL = bool2;

if (useEGL) {
doEGLCompositing = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> Boolean.getBoolean("doNativeComposite"));
@SuppressWarnings("removal")
boolean bool3 = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> Boolean.getBoolean("doNativeComposite"));
doEGLCompositing = bool3;
} else
doEGLCompositing = false;
}
Expand Down Expand Up @@ -134,8 +149,8 @@ public static boolean useEGLWindowComposition() {
}

public static boolean useGLES2() {
String useGles2 = "false";
useGles2 =
@SuppressWarnings("removal")
String useGles2 =
AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("use.gles2"));
if ("true".equals(useGles2))
return true;
Expand Down Expand Up @@ -244,6 +259,7 @@ private static File getRTDir() {
}
}

@SuppressWarnings("removal")
private static void loadProperties() {
final String vmname = System.getProperty("java.vm.name");
final String arch = System.getProperty("os.arch");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ class PrintLogger extends Logger {
* the threshold, then it is logged, otherwise an abbreviated representation including
* only the time of the pulse is logged.
*/
@SuppressWarnings("removal")
private static long THRESHOLD = (long)
AccessController.doPrivileged((PrivilegedAction<Integer>) () -> Integer.getInteger("javafx.pulseLogger.threshold", 17));

/**
* Optionally exit after a given number of pulses
*/
@SuppressWarnings("removal")
private static final int EXIT_ON_PULSE =
AccessController.doPrivileged((PrivilegedAction<Integer>) () -> Integer.getInteger("javafx.pulseLogger.exitOnPulse", 0));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public static void newInput(String name) {
* @return true if the user requested pulse logging by setting the system
* property javafx.pulseLogger to true, false otherwise.
*/
@SuppressWarnings("removal")
public static boolean isPulseLoggingRequested() {
return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> Boolean.getBoolean("javafx.pulseLogger"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* Utility class to wrap method invocation.
*/
public class MethodHelper {
@SuppressWarnings("removal")
private static final boolean logAccessErrors
= AccessController.doPrivileged((PrivilegedAction<Boolean>) ()
-> Boolean.getBoolean("sun.reflect.debugModuleAccessChecks"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@

package com.sun.javafx.property;

import static java.security.AccessController.doPrivileged;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.PrivilegedAction;

import javafx.beans.property.ReadOnlyProperty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class Disposer implements Runnable {
static {
disposerInstance = new Disposer();

java.security.AccessController.doPrivileged(
@SuppressWarnings("removal")
var dummy = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
/* The thread must be a member of a thread group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Trampoline {
}
}

@SuppressWarnings("removal")
private static void ensureInvocableMethod(Method m)
throws InvocationTargetException
{
Expand Down Expand Up @@ -107,6 +108,7 @@ public static Method[] getMethods(Class<?> cls) {
* we're done.
*/
/*public*/
@SuppressWarnings("removal")
static Method[] getPublicMethods(Class<?> cls) {
// compatibility for update release
if (System.getSecurityManager() == null) {
Expand Down Expand Up @@ -291,6 +293,7 @@ public static Object invoke(Method m, Object obj, Object[] params)
}
}

@SuppressWarnings("removal")
private static Method getTrampoline() {
try {
return AccessController.doPrivileged(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private ReflectUtil() {
* also check the package access on the proxy interfaces.
*/
public static void checkPackageAccess(Class<?> clazz) {
@SuppressWarnings("removal")
SecurityManager s = System.getSecurityManager();
if (s != null) {
privateCheckPackageAccess(s, clazz);
Expand All @@ -50,7 +51,7 @@ public static void checkPackageAccess(Class<?> clazz) {
/**
* NOTE: should only be called if a SecurityManager is installed
*/
private static void privateCheckPackageAccess(SecurityManager s, Class<?> clazz) {
private static void privateCheckPackageAccess(@SuppressWarnings("removal") SecurityManager s, Class<?> clazz) {
while (clazz.isArray()) {
clazz = clazz.getComponentType();
}
Expand All @@ -72,6 +73,7 @@ private static void privateCheckPackageAccess(SecurityManager s, Class<?> clazz)
* the true caller (application).
*/
public static void checkPackageAccess(String name) {
@SuppressWarnings("removal")
SecurityManager s = System.getSecurityManager();
if (s != null) {
String cname = name.replace('/', '.');
Expand Down Expand Up @@ -100,7 +102,7 @@ public static boolean isPackageAccessible(Class<?> clazz) {
/**
* NOTE: should only be called if a SecurityManager is installed
*/
private static void privateCheckProxyPackageAccess(SecurityManager s, Class<?> clazz) {
private static void privateCheckProxyPackageAccess(@SuppressWarnings("removal") SecurityManager s, Class<?> clazz) {
// check proxy interfaces if the given class is a proxy class
if (Proxy.isProxyClass(clazz)) {
for (Class<?> intf : clazz.getInterfaces()) {
Expand Down