Paullo612 / mlfx

OpenJFX's FXML language AOT compler
Apache License 2.0
12 stars 0 forks source link

inherited fields/methods need to be public #32

Open ennerf opened 1 year ago

ennerf commented 1 year ago

I did get the entire UI working now 👍 The only remaining issue I ran into was that the current injection does not work for inherited non-public fields, e.g.,

public abstract class AbstractController {

    @FXML
    protected ResourceBundle resources;

    @FXML
    protected URL location;

    @FXML
    protected void initialize() {
        // ...
    }

}

public SomeController extends AbstractController {

    @FXML
    protected Button button;

}

Micronaut generates the $Introspection class for both, but the instantiation fails because it can't find the field, e.g.,

Caused by: io.github.paullo612.mlfx.api.CompiledLoadException: Unable to find property "location" in class "test.SomeController".
    at io.github.paullo612.mlfx.api.internal.impl.ControllerAccessorImpl.lambda$setField$0(ControllerAccessorImpl.java:69)
    at java.base/java.util.Optional.orElseThrow(Optional.java:403)
    at io.github.paullo612.mlfx.api.internal.impl.ControllerAccessorImpl.setField(ControllerAccessorImpl.java:67)
    at io.github.paullo612.mlfx.api.MLFXLoader$ControllerAccessorDelegate.setField(MLFXLoader.java:105)
    at us.hebi.gui.views.scope.components.$Motordriver$CompiledFXMLLoader.doLoad(Unknown Source)
    at us.hebi.gui.views.scope.components.$Motordriver$CompiledFXMLLoader.doLoad(Unknown Source)
    at io.github.paullo612.mlfx.api.CompiledFXMLLoader.load(CompiledFXMLLoader.java:133)
    at us.hebi.gui.views.scope.$Scope$CompiledFXMLLoader.doLoad(Unknown Source)
    at us.hebi.gui.views.scope.$Scope$CompiledFXMLLoader.doLoad(Unknown Source)
    at io.github.paullo612.mlfx.api.CompiledFXMLLoader.load(CompiledFXMLLoader.java:133)
    at io.github.paullo612.mlfx.api.MLFXLoader.load(MLFXLoader.java:310)

It works when the inherited fxml fields and methods are public. Feel free to close in case this is a limitation by Micronaut or difficult to address (e.g. hard to see when to access the AbstractController$Introspection)