Starting with update 9-u175, java allows illegal access by default, thereby allowing you to use all the old tricks. It works fine, except when it comes to classes in control.skin (others may not have been tested as well) - to play, run the example below, click the button and see how the access succeeds while the line trying to access the private field in ButtonSkin. Stack:
Exception in thread "JavaFX Application Thread" java.lang.reflect.InaccessibleObjectException: Unable to make field private final com.sun.javafx.scene.control.behavior.BehaviorBase javafx.scene.control.skin.ButtonSkin.behavior accessible: module javafx.controls does not "opens javafx.scene.control.skin" to unnamed module @537fb2 at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:337) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:281) at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:176) at java.base/java.lang.reflect.Field.setAccessible(Field.java:170)
My context: jdk9-u175, eclipse-oxygen-R with a patch for java9, access rules in the project are set to allow javafx / **
Question: who is the criminal? FX, Eclipse, ea or ..?
Example:
import java.lang.reflect.Field; import java.util.logging.Logger; import javafx.application.Application; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.SkinBase; import javafx.scene.control.skin.ButtonSkin; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; import com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler; public class AccessFieldFX extends Application { private Parent getContent() { Button button = new Button("something to click on");
eclipse javafx java-9
kleopatra
source share