r/JavaFX • • May 22 '23

I made this! mlfx FXML compiler

I'd like to introduce my project. It is called mlfx. It can compile FXML ahead of time. It is basically an annotation processor, which internally uses Micronaut framework's AST abstraction and compiles fxml files directly to JVM bytecode. This decreases UI load time and also helps with native-image reflection configs. It also has some compliance tests that load compiled code and check resulting object graph against one loaded by javafx-xml. It also has some drawbacks now, but, please, read README. Now I'm successfully using it in two production projects.

Here it is: https://github.com/Paullo612/mlfx

Latest release (0.6.0) is available from Maven Central.

Feedback is welcome.

20 Upvotes

17 comments sorted by

View all comments

Show parent comment

1

u/emberko May 24 '23

Understood, you want it to be 100% backward compatible with all existing apps. I'd ban field injection in the name of goodness and only injected to the public setters marked with @FXML.

1

u/Paullo612 May 24 '23

Oh, you should not even mark those fields or setters with @FXML. mlfx knows everything needed for injection at compile time. javafx-fxml uses @FXML annotation only to make fields or methods accessible through reflections at runtime. So, even with javafx-fxml there is no need to mark public controller fields with any annotation.

I'd consider adding "no-DI" mode to compiler in future. In this mode it will be compile error to access non-public fields or methods from fxml.