Skip to content

Commit 65f095e

Browse files
committed
Merge branch 'master' into feature/extended-window
2 parents 6a16536 + d0011b2 commit 65f095e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+278
-454
lines changed

.github/workflows/submit.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ jobs:
298298
java -version
299299
which ant
300300
ant -version
301-
sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer
301+
# We want to use Xcode 14, but GHA removed it from the macOS 14 runners
302+
# sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer
302303
xcodebuild -version
303304
304305
- name: Build JavaFX artifacts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package com.sun.javafx;
27+
28+
import java.lang.reflect.InvocationTargetException;
29+
import java.lang.reflect.Method;
30+
31+
/**
32+
* Utility class to check for the presence of a security manager.
33+
*/
34+
public class SecurityUtil {
35+
36+
// Prevent class from being instantiated.
37+
private SecurityUtil() {}
38+
39+
/**
40+
* Check for the presence of a security manager (from an older JDK) and
41+
* throw UnsupportedOperationException if enabled. Use reflection to avoid
42+
* a dependency on an API that is deprecated for removal. This method does
43+
* nothing if the security manager is not enabled or if
44+
* System::getSecurityManager cannot be invoked.
45+
*
46+
* @throws UnsupportedOperationException if the security manager is enabled
47+
*/
48+
public static void checkSecurityManager() {
49+
try {
50+
// Call System.getSecurityManager() using reflection. Throw an
51+
// UnsupportedOperationException if it returns a non-null object.
52+
// If we cannot find or invoke getSecurityManager, ignore the error.
53+
Method meth = System.class.getMethod("getSecurityManager");
54+
Object sm = meth.invoke(null);
55+
if (sm != null) {
56+
throw new UnsupportedOperationException("JavaFX does not support running with the Security Manager");
57+
}
58+
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
59+
// Ignore the error
60+
}
61+
}
62+
}

modules/javafx.base/src/main/java/com/sun/javafx/reflect/MethodUtil.java

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
package com.sun.javafx.reflect;
2727

28+
import com.sun.javafx.SecurityUtil;
2829
import java.security.AllPermission;
2930
import java.security.AccessController;
3031
import java.security.PermissionCollection;
@@ -76,6 +77,12 @@ private static Object invoke(Method m, Object obj, Object[] params)
7677
* Create a trampoline class.
7778
*/
7879
public final class MethodUtil extends SecureClassLoader {
80+
81+
static {
82+
// Check for security manager (throws exception if enabled)
83+
SecurityUtil.checkSecurityManager();
84+
}
85+
7986
private static final String MISC_PKG = "com.sun.javafx.reflect.";
8087
private static final String TRAMPOLINE = MISC_PKG + "Trampoline";
8188
private static final Method bounce = getTrampoline();

modules/javafx.base/src/main/java/com/sun/javafx/reflect/ReflectUtil.java

+6
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@
2626

2727
package com.sun.javafx.reflect;
2828

29+
import com.sun.javafx.SecurityUtil;
2930
import java.lang.reflect.Proxy;
3031

3132
public final class ReflectUtil {
3233

34+
static {
35+
// Check for security manager (throws exception if enabled)
36+
SecurityUtil.checkSecurityManager();
37+
}
38+
3339
private ReflectUtil() {
3440
}
3541

modules/javafx.graphics/src/main/java/com/sun/glass/ui/Accessible.java

+13-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,6 @@
2828
import static javafx.scene.AccessibleAttribute.PARENT;
2929
import static javafx.scene.AccessibleAttribute.ROLE;
3030
import java.security.AccessControlContext;
31-
import java.security.AccessController;
32-
import java.security.PrivilegedAction;
3331
import com.sun.javafx.scene.NodeHelper;
3432
import com.sun.javafx.scene.SceneHelper;
3533
import com.sun.javafx.tk.quantum.QuantumToolkit;
@@ -39,6 +37,8 @@
3937
import javafx.scene.Node;
4038
import javafx.scene.Scene;
4139

40+
import java.util.function.Supplier;
41+
4242
public abstract class Accessible {
4343

4444
private EventHandler eventHandler;
@@ -137,10 +137,10 @@ private final AccessControlContext getAccessControlContext() {
137137
return acc;
138138
}
139139

140-
private class GetAttribute implements PrivilegedAction<Object> {
140+
private class GetAttribute implements Supplier<Object> {
141141
AccessibleAttribute attribute;
142142
Object[] parameters;
143-
@Override public Object run() {
143+
@Override public Object get() {
144144
Object result = eventHandler.getAttribute(attribute, parameters);
145145
if (result != null) {
146146
Class<?> clazz = attribute.getReturnType();
@@ -162,37 +162,27 @@ private class GetAttribute implements PrivilegedAction<Object> {
162162

163163
private GetAttribute getAttribute = new GetAttribute();
164164

165-
@SuppressWarnings("removal")
166165
public Object getAttribute(AccessibleAttribute attribute, Object... parameters) {
167-
AccessControlContext acc = getAccessControlContext();
168-
if (acc == null) return null;
169-
return QuantumToolkit.runWithoutRenderLock(() -> {
170-
getAttribute.attribute = attribute;
171-
getAttribute.parameters = parameters;
172-
return AccessController.doPrivileged(getAttribute, acc);
173-
});
166+
getAttribute.attribute = attribute;
167+
getAttribute.parameters = parameters;
168+
return QuantumToolkit.runWithoutRenderLock(getAttribute);
174169
}
175170

176-
private class ExecuteAction implements PrivilegedAction<Void> {
171+
private class ExecuteAction implements Supplier<Void> {
177172
AccessibleAction action;
178173
Object[] parameters;
179-
@Override public Void run() {
174+
@Override public Void get() {
180175
eventHandler.executeAction(action, parameters);
181176
return null;
182177
}
183178
}
184179

185180
private ExecuteAction executeAction = new ExecuteAction();
186181

187-
@SuppressWarnings("removal")
188182
public void executeAction(AccessibleAction action, Object... parameters) {
189-
AccessControlContext acc = getAccessControlContext();
190-
if (acc == null) return;
191-
QuantumToolkit.runWithoutRenderLock(() -> {
192-
executeAction.action = action;
193-
executeAction.parameters = parameters;
194-
return AccessController.doPrivileged(executeAction, acc);
195-
});
183+
executeAction.action = action;
184+
executeAction.parameters = parameters;
185+
QuantumToolkit.runWithoutRenderLock(executeAction);
196186
}
197187

198188
public abstract void sendNotification(AccessibleAttribute notification);

modules/javafx.graphics/src/main/java/com/sun/glass/ui/Application.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@
3232
import java.io.File;
3333
import java.nio.ByteBuffer;
3434
import java.nio.IntBuffer;
35-
import java.security.AccessController;
36-
import java.security.PrivilegedAction;
3735
import java.util.List;
3836
import java.util.Map;
3937
import java.util.LinkedList;
4038
import java.util.Optional;
39+
import java.util.function.Supplier;
4140

4241
public abstract class Application {
4342

@@ -96,13 +95,11 @@ public void handlePreferencesChanged(Map<String, Object> preferences) {
9695
private static boolean loaded = false;
9796
private static Application application;
9897
private static Thread eventThread;
99-
@SuppressWarnings("removal")
100-
private static final boolean disableThreadChecks =
101-
AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
102-
final String str =
98+
private static final boolean disableThreadChecks = ((Supplier<Boolean>) () -> {
99+
final String str =
103100
System.getProperty("glass.disableThreadChecks", "false");
104101
return "true".equalsIgnoreCase(str);
105-
});
102+
}).get();
106103

107104
// May be called on any thread.
108105
protected static synchronized void loadNativeLibrary(final String libname) {
@@ -215,8 +212,7 @@ public void setName(String name) {
215212
*/
216213
public String getDataDirectory() {
217214
checkEventThread();
218-
@SuppressWarnings("removal")
219-
String userHome = AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("user.home"));
215+
String userHome = System.getProperty("user.home");
220216
return userHome + File.separator + "." + name + File.separator;
221217
}
222218

modules/javafx.graphics/src/main/java/com/sun/glass/ui/Platform.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
*/
2525
package com.sun.glass.ui;
2626

27-
import java.security.AccessController;
28-
import java.security.PrivilegedAction;
2927
import com.sun.javafx.PlatformUtil;
3028

3129
final class Platform {
@@ -42,9 +40,7 @@ static public synchronized String determinePlatform() {
4240
if (type == null) {
4341

4442
// Provide for a runtime override, allowing EGL for example
45-
@SuppressWarnings("removal")
46-
String userPlatform =
47-
AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty("glass.platform"));
43+
String userPlatform = System.getProperty("glass.platform");
4844

4945
if (userPlatform != null) {
5046
if (userPlatform.equals("macosx"))

modules/javafx.graphics/src/main/java/com/sun/glass/ui/Screen.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,6 @@
2424
*/
2525
package com.sun.glass.ui;
2626

27-
import java.security.AccessController;
28-
import java.security.PrivilegedAction;
2927
import java.util.Arrays;
3028
import java.util.Collections;
3129
import java.util.List;
@@ -37,9 +35,8 @@ public final class Screen {
3735
private static volatile List<Screen> screens = null ;
3836

3937
// If dpiOverride is non-zero, use its value as screen DPI
40-
@SuppressWarnings("removal")
41-
private static final int dpiOverride = AccessController.doPrivileged((PrivilegedAction<Integer>) () ->
42-
Integer.getInteger("com.sun.javafx.screenDPI", 0)).intValue();
38+
private static final int dpiOverride =
39+
Integer.getInteger("com.sun.javafx.screenDPI", 0);
4340

4441
public static class EventHandler {
4542
public void handleSettingsChanged() {

modules/javafx.graphics/src/main/java/com/sun/glass/ui/View.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@
2929
import javafx.scene.Node;
3030
import java.lang.annotation.Native;
3131
import java.lang.ref.WeakReference;
32-
import java.security.AccessController;
33-
import java.security.PrivilegedAction;
3432
import java.util.Map;
33+
import java.util.function.Supplier;
3534

3635
public abstract class View {
3736

@@ -44,8 +43,7 @@ public abstract class View {
4443
@Native public final static byte IME_ATTR_TARGET_NOTCONVERTED = 0x03;
4544
@Native public final static byte IME_ATTR_INPUT_ERROR = 0x04;
4645

47-
@SuppressWarnings("removal")
48-
final static boolean accessible = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
46+
final static boolean accessible = ((Supplier<Boolean>) () -> {
4947
String force = System.getProperty("glass.accessible.force");
5048
if (force != null) return Boolean.parseBoolean(force);
5149

@@ -60,7 +58,7 @@ public abstract class View {
6058
} catch (Exception e) {
6159
return false;
6260
}
63-
});
61+
}).get();
6462

6563
public static class EventHandler {
6664
public void handleViewEvent(View view, long time, int type) {

0 commit comments

Comments
 (0)