FXML backwards compatibility issue

Greg Brown greg.x.brown at oracle.com
Wed Jun 27 06:26:43 PDT 2012


> In my FXML Controllers I have the following member variable:
> 
>    private ResourceBundle resources;
> 
> In version JFX 2.1 and lower this works fine but in version 2.2 it looks
> like JFX has decided it has control over this variable now?

OK, I see the problem. In 2.2, we added support for automatic injection of the "resources" and "location" fields. We only do this if the controller does not implement Initializable - the thinking being that, if the controller does implement Initializable, it will get the location and resources via the initialize() method. Otherwise, we assume that the controller wants to get these values via injection.

I'm guessing your controller does not implement Initializable, but also does not want these fields injected. The fix is simple - FXMLLoader can just ignore the IllegalAccessException when attempting to inject these fields. If we ever deprecate/remove Initializable, we can go back to throwing in this case. Make sense?

Greg



More information about the openjfx-dev mailing list