Skip to content

Commit

Permalink
Merge branch 'master' into 8342992-check-sm
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrushforth committed Nov 7, 2024
2 parents 6e905c1 + 3d15a30 commit 7ea58b3
Show file tree
Hide file tree
Showing 40 changed files with 381 additions and 861 deletions.
89 changes: 33 additions & 56 deletions modules/javafx.base/src/main/java/com/sun/javafx/PlatformUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

package com.sun.javafx;

import java.security.AccessController;
import java.security.PrivilegedAction;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
Expand All @@ -38,11 +36,6 @@

public class PlatformUtil {

// NOTE: since this class can be initialized by application code in some
// cases, we must encapsulate all calls to System.getProperty("...") in
// a doPrivileged block except for standard JVM properties such as
// os.name, os.version, os.arch, java.vm.name, etc.

private static final String os = System.getProperty("os.name");
private static final String version = System.getProperty("os.version");
private static final boolean embedded;
Expand All @@ -53,30 +46,19 @@ public class PlatformUtil {
private static String javafxPlatform;

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

loadProperties();

@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("glass.platform", "").toLowerCase(Locale.ROOT));
embeddedType = str2;

@SuppressWarnings("removal")
boolean bool2 = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> Boolean.getBoolean("use.egl"));
useEGL = bool2;
embedded = Boolean.getBoolean("com.sun.javafx.isEmbedded");
embeddedType = System.getProperty("glass.platform", "").toLowerCase(Locale.ROOT);
useEGL = Boolean.getBoolean("use.egl");

if (useEGL) {
@SuppressWarnings("removal")
boolean bool3 = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> Boolean.getBoolean("doNativeComposite"));
doEGLCompositing = bool3;
} else
doEGLCompositing = Boolean.getBoolean("doNativeComposite");
} else {
doEGLCompositing = false;
}
}

private static final boolean ANDROID = "android".equals(javafxPlatform) || "Dalvik".equals(System.getProperty("java.vm.name"));
Expand Down Expand Up @@ -150,9 +132,7 @@ public static boolean useEGLWindowComposition() {
}

public static boolean useGLES2() {
@SuppressWarnings("removal")
String useGles2 =
AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("use.gles2"));
String useGles2 = System.getProperty("use.gles2");
if ("true".equals(useGles2))
return true;
else
Expand Down Expand Up @@ -260,7 +240,6 @@ 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 All @@ -270,34 +249,32 @@ private static void loadProperties() {
(vmname != null && vmname.indexOf("Embedded") > 0))) {
return;
}
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
final File rtDir = getRTDir();
final String propertyFilename = "javafx.platform.properties";
File rtProperties = new File(rtDir, propertyFilename);
// First look for javafx.platform.properties in the JavaFX runtime
// Then in the installation directory of the JRE
if (rtProperties.exists()) {
loadPropertiesFromFile(rtProperties);
return null;
}
String javaHome = System.getProperty("java.home");
File javaHomeProperties = new File(javaHome,
"lib" + File.separator
+ propertyFilename);
if (javaHomeProperties.exists()) {
loadPropertiesFromFile(javaHomeProperties);
return null;
}

String javafxRuntimePath = System.getProperty("javafx.runtime.path");
File javafxRuntimePathProperties = new File(javafxRuntimePath,
File.separator + propertyFilename);
if (javafxRuntimePathProperties.exists()) {
loadPropertiesFromFile(javafxRuntimePathProperties);
return null;
}
return null;
});
final File rtDir = getRTDir();
final String propertyFilename = "javafx.platform.properties";
File rtProperties = new File(rtDir, propertyFilename);
// First look for javafx.platform.properties in the JavaFX runtime
// Then in the installation directory of the JRE
if (rtProperties.exists()) {
loadPropertiesFromFile(rtProperties);
return;
}
String javaHome = System.getProperty("java.home");
File javaHomeProperties = new File(javaHome,
"lib" + File.separator
+ propertyFilename);
if (javaHomeProperties.exists()) {
loadPropertiesFromFile(javaHomeProperties);
return;
}

String javafxRuntimePath = System.getProperty("javafx.runtime.path");
File javafxRuntimePathProperties = new File(javafxRuntimePath,
File.separator + propertyFilename);
if (javafxRuntimePathProperties.exists()) {
loadPropertiesFromFile(javafxRuntimePathProperties);
return;
}
}

public static boolean isAndroid() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

package com.sun.javafx.logging;

import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -54,15 +52,12 @@ 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 = AccessController.doPrivileged((PrivilegedAction<Integer>) () -> Integer.getInteger("javafx.pulseLogger.threshold", 17));
private static long THRESHOLD = 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));
private static final int EXIT_ON_PULSE = Integer.getInteger("javafx.pulseLogger.exitOnPulse", 0);

/**
* We have a simple counter that keeps track of the current pulse number.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -102,9 +100,8 @@ 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"));
return Boolean.getBoolean("javafx.pulseLogger");
}

// Loading known loggers reflectively, in case an expected module isn't available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@
import com.sun.javafx.reflect.MethodUtil;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import com.sun.javafx.reflect.ReflectUtil;

/**
* 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"));
= Boolean.getBoolean("sun.reflect.debugModuleAccessChecks");

private static final Module trampolineModule = MethodUtil.getTrampolineModule();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,17 @@ public class Disposer implements Runnable {

static {
disposerInstance = new Disposer();

@SuppressWarnings("removal")
var dummy = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<>() {
@Override
public Object run() {
/* The thread must be a member of a thread group
* which will not get GCed before VM exit.
* Make its parent the top-level thread group.
*/
ThreadGroup tg = Thread.currentThread().getThreadGroup();
for (ThreadGroup tgn = tg;
tgn != null;
tg = tgn, tgn = tg.getParent());
Thread t =
new Thread(tg, disposerInstance, "Property Disposer");
t.setContextClassLoader(null);
t.setDaemon(true);
t.setPriority(Thread.MAX_PRIORITY);
t.start();
return null;
}
}
);
/* The thread must be a member of a thread group
* which will not get GCed before VM exit.
* Make its parent the top-level thread group.
*/
ThreadGroup tg = Thread.currentThread().getThreadGroup();
for (ThreadGroup tgn = tg; tgn != null; tg = tgn, tgn = tg.getParent());
Thread t = new Thread(tg, disposerInstance, "Property Disposer");
t.setContextClassLoader(null);
t.setDaemon(true);
t.setPriority(Thread.MAX_PRIORITY);
t.start();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.security.AccessController;
import java.security.PermissionCollection;
import java.security.SecureClassLoader;
import java.security.PrivilegedExceptionAction;
import java.security.CodeSource;
import java.io.InputStream;
import java.io.IOException;
Expand Down Expand Up @@ -295,22 +294,15 @@ public static Object invoke(Method m, Object obj, Object[] params)
}
}

@SuppressWarnings("removal")
private static Method getTrampoline() {
try {
return AccessController.doPrivileged(
new PrivilegedExceptionAction<Method>() {
@Override
public Method run() throws Exception {
Class<?> t = getTrampolineClass();
Class<?>[] types = {
Method.class, Object.class, Object[].class
};
Method b = t.getDeclaredMethod("invoke", types);
b.setAccessible(true);
return b;
}
});
Class<?> t = getTrampolineClass();
Class<?>[] types = {
Method.class, Object.class, Object[].class
};
Method b = t.getDeclaredMethod("invoke", types);
b.setAccessible(true);
return b;
} catch (Exception e) {
throw new InternalError("bouncer cannot be found", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.UndeclaredThrowableException;

import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;

/**
* A {@code JavaBeanBooleanProperty} provides an adapter between a regular
* Java Bean property of type {@code boolean} or {@code Boolean} and a JavaFX
Expand Down Expand Up @@ -96,9 +92,6 @@ public final class JavaBeanBooleanProperty extends BooleanProperty implements Ja
private ObservableValue<? extends Boolean> observable = null;
private ExpressionHelper<Boolean> helper = null;

@SuppressWarnings("removal")
private final AccessControlContext acc = AccessController.getContext();

JavaBeanBooleanProperty(PropertyDescriptor<Boolean> descriptor, Object bean) {
this.descriptor = descriptor;
this.listener = descriptor.new Listener(bean, this);
Expand All @@ -113,18 +106,15 @@ public final class JavaBeanBooleanProperty extends BooleanProperty implements Ja
* property throws an {@code IllegalAccessException} or an
* {@code InvocationTargetException}.
*/
@SuppressWarnings("removal")
@Override
public boolean get() {
return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
try {
return (Boolean)MethodHelper.invoke(descriptor.getGetter(), getBean(), (Object[])null);
} catch (IllegalAccessException e) {
throw new UndeclaredThrowableException(e);
} catch (InvocationTargetException e) {
throw new UndeclaredThrowableException(e);
}
}, acc);
try {
return (Boolean)MethodHelper.invoke(descriptor.getGetter(), getBean(), (Object[])null);
} catch (IllegalAccessException e) {
throw new UndeclaredThrowableException(e);
} catch (InvocationTargetException e) {
throw new UndeclaredThrowableException(e);
}
}

/**
Expand All @@ -134,24 +124,19 @@ public boolean get() {
* property throws an {@code IllegalAccessException} or an
* {@code InvocationTargetException}.
*/
@SuppressWarnings("removal")
@Override
public void set(final boolean value) {
if (isBound()) {
throw new RuntimeException("A bound value cannot be set.");
}

AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
try {
MethodHelper.invoke(descriptor.getSetter(), getBean(), new Object[] {value});
ExpressionHelper.fireValueChangedEvent(helper);
} catch (IllegalAccessException e) {
throw new UndeclaredThrowableException(e);
} catch (InvocationTargetException e) {
throw new UndeclaredThrowableException(e);
}
return null;
}, acc);
try {
MethodHelper.invoke(descriptor.getSetter(), getBean(), new Object[] {value});
ExpressionHelper.fireValueChangedEvent(helper);
} catch (IllegalAccessException e) {
throw new UndeclaredThrowableException(e);
} catch (InvocationTargetException e) {
throw new UndeclaredThrowableException(e);
}
}

/**
Expand Down
Loading

0 comments on commit 7ea58b3

Please sign in to comment.