mercredi 10 juin 2020

Scene Builder not loading custom control because of java.lang.reflect.InaccessibleObjectException

Scene Builder is throwing a javafx.fxml.LoadException for the following reason:

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private com.sun.javafx.scene.control.behavior.ListViewBehavior javafx.scene.control.skin.ListViewSkin.behavior accessible: module javafx.controls does not "opens javafx.scene.control.skin" to unnamed module @5f769b67

My working environment:

  • OS - Windows 10
  • IDE - Eclipse v. 2020-3

The problem relates to a custom control (a composite control based on ListView) and arose after I made some design changes that installed input event handlers (MouseEvent and KeyEvent) on the InputMap for the ListView's built-in-but-accessible-only-through-reflection ListViewBehavior. Before these changes the custom behavior was structured as an EventFilter that was added to the ListView. Because this effectively bypassed ListViewBehavior the custom control was not rejected by SceneBuilder.

Functionally, both techniques work equally well, but from a design standpoint using the InputMap approach is by far preferable ... except for the Scene Builder issues. The exact same problem exists for another custom control that has a similar design but is based on TableView and where the exception refers to TableViewBehavior instead of ListViewBehavior.

It should be noted that both controls work fine when run in a test application. In other words, the problem is not about successfully accessing the restricted behavior API by way of reflection, but instead due to one or more issues with Scene Builder's compatibility with that process.

I've reviewed the question and answers at [How to Start Scenebuilder with Java 11}, but the circumstances there differ materially from those here.

Thanks in advance for useful advice.





Aucun commentaire:

Enregistrer un commentaire