JDK 17 forbids access to internal com.sun packages
See original GitHub issueIn ReflectionUtils
, the following method violates the new security model in JDK 17:
public static void setTraversalEngine(Control control, Object engine) {
try {
Class<?> parentHelper = Class.forName("com.sun.javafx.scene.ParentHelper");
Method method = parentHelper.getMethod("setTraversalEngine", Parent.class, engine.getClass());
method.setAccessible(true);
method.invoke(parentHelper, control, engine);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
throw new RuntimeException("Cannot set Traversal Engine");
}
}
This prevents migration to JDK 17 for any JavaFX applications that use ControlsFX directly or indirectly (e.g., PreferencesFX).
FWIW, adding the export for scene traversal does not appear to resolve the issue:
def moduleSecurity = [
"--add-opens=javafx.controls/javafx.scene.control=ALL-UNNAMED",
"--add-opens=javafx.controls/javafx.scene.control.skin=ALL-UNNAMED",
"--add-opens=javafx.graphics/javafx.scene.text=ALL-UNNAMED",
"--add-opens=javafx.graphics/com.sun.javafx.css=ALL-UNNAMED",
"--add-opens=javafx.graphics/com.sun.javafx.text=ALL-UNNAMED",
"--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED",
"--add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED",
"--add-exports=javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED",
"--add-exports=javafx.graphics/com.sun.javafx.scene.traversal=ALL-UNNAMED",
"--add-exports=javafx.graphics/com.sun.javafx.text=ALL-UNNAMED",
]
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Java Platform, Standard Edition - Oracle JDK Migration Guide
By default, all internal elements of the JDK are strongly encapsulated, except for critical internal APIs such as sun.misc.Unsafe. However, it will no...
Read more >com.sun.management (Java SE 17 & JDK 17)
Platform-specific management interface for the Unix operating system on which the Java virtual machine is running.
Read more >Java Platform, Standard Edition Oracle JDK 9 Migration Guide
Critical internal JDK APIs such as sun.misc.Unsafe are still accessible in JDK 9, but most of the JDK's internal APIs are not accessible...
Read more >Oracle JDK Migration Guide - Java
This guide will help you migrate your application from Oracle JDK 8 to Oracle JDK 10.
Read more >A peek into Java 17: Encapsulating the Java runtime internals
Here is an example of direct access to internal classes, similar to ... URLCanonicalizer; ^ (package sun.net is declared in module java.base ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @DaveJarvis ,
import com.sun.javafx.scene.control.skin.ComboBoxListViewSkin
this shouldn’t exist in the latest ControlsFX code. You seem to be on themaster
branch which is still meant for JDK 8.Please checkout
jfx-13
branch and retry.Smoke tested. These changes appear to work with JDK 17, thank you.