question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JDK 17 forbids access to internal com.sun packages

See original GitHub issue

In 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:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
abhinayagarwalcommented, Oct 3, 2021

Hi @DaveJarvis ,

import com.sun.javafx.scene.control.skin.ComboBoxListViewSkin this shouldn’t exist in the latest ControlsFX code. You seem to be on the master branch which is still meant for JDK 8.

Please checkout jfx-13 branch and retry.

0reactions
DaveJarviscommented, Oct 3, 2021

Please checkout jfx-13 branch and retry.

Smoke tested. These changes appear to work with JDK 17, thank you.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found