FXML and Classloading
greg.x.brown at oracle.com
Thu May 31 09:11:32 PDT 2012
> The problem is that if I'm using composition I don't get the correct
Sure you do. You just need to propagate it to your nested builder factory.
> I think you should not set a default classloader at all but let the
> type-classloader be the default - it is the classloader used by the
> FXMLLoader while constructing the Object graph.
OK. I *think* the only real issue here is whether or not we truly need to pass a class loader to JavaFXBuilderFactory. The only place where we actually need the class loader in JavaFXBuilderFactory is when we are trying to load the generated builder class for a given type. If we assume that the builder class will be loaded by the same class loader that was used to load the original type, then you are right - we don't need to explicitly pass a class loader to the JavaFXBuilderFactory constructor. However, I'm not sure that is a safe assumption. But I also don't think it is a major inconvenience to have to do so - if you need to use a custom class loader in your app, you just need to make sure you pass it to your JavaFXBuilderFactory instance.
More information about the openjfx-dev