mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2026-01-08 17:41:41 +01:00
JBR-3772 java/beans/PropertyEditor/TestFontClass.java: access denied ("java.util.PropertyPermission" "sun.awt.x11.trace" "read")
Instead of using System.getProperty() directly, wrap the call into
GetPropertyAction and use AccessController to execute it.
(cherry picked from commit 4fefc6244b)
This commit is contained in:
@@ -70,8 +70,10 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
private static final double debugScale;
|
||||
|
||||
static {
|
||||
String uiScaleEnabledPropValue = System.getProperty("sun.java2d.uiScale.enabled", "true");
|
||||
|
||||
uiScaleEnabled = FontUtilities.isMacOSX ||
|
||||
("true".equals(System.getProperty("sun.java2d.uiScale.enabled", "true")) &&
|
||||
("true".equals(uiScaleEnabledPropValue) &&
|
||||
(isWindows_8_1_orUpper() || FontUtilities.isLinux));
|
||||
|
||||
if (uiScaleEnabled && FontUtilities.isWindows) {
|
||||
|
||||
@@ -182,7 +182,9 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
}
|
||||
|
||||
static {
|
||||
final String trace = System.getProperty("sun.awt.x11.trace");
|
||||
final GetPropertyAction gpa = new GetPropertyAction("sun.awt.x11.trace");
|
||||
@SuppressWarnings("removal")
|
||||
final String trace = AccessController.doPrivileged(gpa);
|
||||
if (trace != null) {
|
||||
int traceFlags = 0;
|
||||
final StringTokenizer st = new StringTokenizer(trace, ",");
|
||||
|
||||
@@ -1333,9 +1333,12 @@ static int getRemoteX11WorkaroundProperty() {
|
||||
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
||||
jstring name = (*env)->NewStringUTF(env, WORKAROUND_PROPERTY_NAME);
|
||||
CHECK_NULL_RETURN(name, ret);
|
||||
jstring jPropValue = JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "getProperty",
|
||||
"(Ljava/lang/String;)Ljava/lang/String;", name).l;
|
||||
if (jPropValue != NULL) {
|
||||
jobject jPropGetAction = JNU_NewObjectByName(env, "sun/security/action/GetPropertyAction", "(Ljava/lang/String;)V", name);
|
||||
CHECK_NULL_RETURN(name, ret);
|
||||
jboolean ignoreExc;
|
||||
jstring jPropValue = JNU_CallStaticMethodByName(env, &ignoreExc, "java/security/AccessController", "doPrivileged",
|
||||
"(Ljava/security/PrivilegedAction;)Ljava/lang/Object;", jPropGetAction).l;
|
||||
if (jPropValue != NULL && JNU_IsInstanceOfByName(env, jPropValue, "java/lang/String")) {
|
||||
const char * utf8string = (*env)->GetStringUTFChars(env, jPropValue, NULL);
|
||||
if (utf8string != NULL) {
|
||||
if (strcmp(utf8string, "true") == 0) {
|
||||
@@ -1346,7 +1349,6 @@ static int getRemoteX11WorkaroundProperty() {
|
||||
}
|
||||
(*env)->ReleaseStringUTFChars(env, jPropValue, utf8string);
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, name);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user