astonbitecode / j4rs

Java for Rust
Apache License 2.0
629 stars 35 forks source link

JavaFX and minification #80

Closed digitalmonks closed 6 months ago

digitalmonks commented 10 months ago

Hello and thanks for the great tool.

We've run into a minor issue because of the way that JavaFX is included in j4rs (there even if not used) it causes problems with minification on Android forcing the tool incorporating a library using j4rs to ignore the entire JavaFX package.

Here's an example of the type of issues.

ERROR: R8: Missing class javafx.application.Application (referenced from: void org.astonbitecode.j4rs.api.jfx.FxApplication.<init>() and 2 other contexts) Missing class javafx.application.Platform (referenced from: org.astonbitecode.j4rs.api.Instance org.astonbitecode.j4rs.api.invocation.JavaFxInvocation.invoke(java.lang.String, org.astonbitecode.j4rs.api.dtos.InvocationArg[]) and 3 other contexts) Missing class javafx.event.Event (referenced from: void org.astonbitecode.j4rs.api.jfx.handlers.J4rsEventHandler.handle(javafx.event.Event)) Missing class javafx.event.EventHandler (referenced from: void org.astonbitecode.j4rs.api.jfx.controllers.FxController.addEventHandler(java.lang.String, javafx.event.EventHandler, javafx.event.EventType) and 2 other contexts) Missing class javafx.event.EventType (referenced from: void org.astonbitecode.j4rs.api.jfx.controllers.FxController.addEventHandler(java.lang.String, javafx.event.EventHandler, javafx.event.EventType) and 1 other context) Missing class javafx.fxml.FXMLLoader (referenced from: org.astonbitecode.j4rs.api.jfx.controllers.FxController org.astonbitecode.j4rs.api.jfx.J4rsFxmlLoader.loadFxml(javafx.stage.Stage, java.lang.String)) Missing class javafx.fxml.Initializable (referenced from: org.astonbitecode.j4rs.api.jfx.controllers.FxController) Missing class javafx.scene.Node (referenced from: javafx.scene.Node org.astonbitecode.j4rs.api.jfx.controllers.FxController.getNodeById(java.lang.String) and 2 other contexts) Missing class javafx.scene.Parent (referenced from: org.astonbitecode.j4rs.api.jfx.controllers.FxController org.astonbitecode.j4rs.api.jfx.J4rsFxmlLoader.loadFxml(javafx.stage.Stage, java.lang.String)) Missing class javafx.scene.Scene (referenced from: javafx.scene.Scene org.astonbitecode.j4rs.api.jfx.controllers.FxControllerImpl.scene and 4 other contexts) Missing class javafx.stage.Stage (referenced from: void org.astonbitecode.j4rs.api.jfx.FxApplication.start(javafx.stage.Stage) and 1 other context) Missing class javafx.util.Callback (referenced from: org.astonbitecode.j4rs.api.jfx.controllers.FxController org.astonbitecode.j4rs.api.jfx.J4rsFxmlLoader.loadFxml(javafx.stage.Stage, java.lang.String))

Would it be possible for you to add a feature to only enable this a config/feature so that JavaFX isn't included for what I would assume is the majority of usage cases?

astonbitecode commented 10 months ago

Hi and thanks for the report.

I did not realize this issue, since the javafx libs are in scope provided in maven...

Could you please give an example on how you do the minification, in order to reproduce this and try to find an adequate solution? I have an android example here if you want to modify for reproducing the issue.

digitalmonks commented 10 months ago

I will look at your example and provide sample of what happens.

astonbitecode commented 6 months ago

Hi @digitalmonks, did you maybe have the chance to check?

astonbitecode commented 6 months ago

Seems not, closing