Frege / frege-native-gen

Frege code generator for Java classes
17 stars 9 forks source link

JavaFX classes cannot be loaded: hook needed #16

Closed Dierk closed 9 years ago

Dierk commented 9 years ago

JavaFX classes cannot be loaded out of context. We need some kind of hook to start the whole process inside com.sun.javafx.application.PlatformImpl.runLater.

Stack trace:

java -jar native-gen-1.0-SNAPSHOT.jar javafx.scene.control.Button Exception in thread "main" java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) .. at frege.nativegen.Main.main(Main.java:737) Caused by: java.lang.IllegalStateException: Toolkit not initialized at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:273) .. at javafx.scene.control.Control.(Control.java:87)

mmhelloworld commented 9 years ago

This was caused by class initialization by using Class.forName(String) to obtain the class object. I fixed it by using the other variant Class.forName(String name, boolean initialize, ClassLoader loader). The new jar with this fix is available in the releases page.

Dierk commented 9 years ago

cool, thanks!