Paullo612 / mlfx

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

IntelliJ build fails #31

Closed ennerf closed 1 year ago

ennerf commented 1 year ago

I can generate the fxml code via maven, but when I execute it from IntelliJ the recompile fails due to IDProperty being an internal class:

image

Do you know of a way to fix that? I tried the usual opens/exports args, but apparently those don't have an effect when used as a compilerArgs. IDProperty seems like a rarely used feature - can you maybe wrap it in a try catch block to not break in the 99% case?

Paullo612 commented 1 year ago

I cannot say that it's rarely used, because javafx.scene.Node is annotated with it. Cannot reproduce this, but, the fix is likely to change class reference to string constant here.

Can you please try following patch and say whether the issue is gone?

Subject: [PATCH] Fix IDProperty
---
Index: compiler/compiler-core/src/main/java/io/github/paullo612/mlfx/compiler/elements/IdentifiableFXMLElement.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/compiler/compiler-core/src/main/java/io/github/paullo612/mlfx/compiler/elements/IdentifiableFXMLElement.java b/compiler/compiler-core/src/main/java/io/github/paullo612/mlfx/compiler/elements/IdentifiableFXMLElement.java
--- a/compiler/compiler-core/src/main/java/io/github/paullo612/mlfx/compiler/elements/IdentifiableFXMLElement.java  (revision 5beb9dfa07fe1f831af24a801bbd669cd58f8e89)
+++ b/compiler/compiler-core/src/main/java/io/github/paullo612/mlfx/compiler/elements/IdentifiableFXMLElement.java  (date 1685017964561)
@@ -77,7 +77,7 @@
     private void setIdProperty(CompilerContext context, String id) {
         ClassElement classElement = getClassElement();

-        AnnotationValue<IDProperty> annotation = classElement.getAnnotation(IDProperty.class);
+        AnnotationValue<IDProperty> annotation = classElement.getAnnotation("com.sun.javafx.beans.IDProperty");

         if (annotation == null) {
             // No ID property present, noting to do here.
ennerf commented 1 year ago

Yes, that fixed the build. IntelliJ also complains about the import, so maybe also get rid of the unnecessary generics reference

AnnotationValue<? extends Annotation> annotation = classElement.getAnnotation("com.sun.javafx.beans.IDProperty");