Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] UI Error when a generated Field is used on annotation #3529

Closed
c-koell opened this issue Oct 24, 2023 · 18 comments · Fixed by #3587
Closed

[BUG] UI Error when a generated Field is used on annotation #3529

c-koell opened this issue Oct 24, 2023 · 18 comments · Fixed by #3587
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail bug eclipse
Milestone

Comments

@c-koell
Copy link

c-koell commented Oct 24, 2023

Describe the bug
We are using lombok 1.18.30 within eclipse 2023-09.

We use the @FieldNameConstants Annotation a InnerClass with static final Fields will be generated.

If we use the static final Fields on a annotation there is no Compile Error but we see a Error on the Classs itself
Eclipse IDE

To Reproduce
The Problems View is empty, and the code works if you run it ...

You will find a sample eclipse project here
Sample-Project.zip

I have also created a issue in jdt-ui eclipse-jdt/eclipse.jdt.ui#865 but a project member thought it is maybe a problem of lombok.

Thanks for any help.

@rspilker
Copy link
Collaborator

Does using a fully qualified name fix the problem? For example: com.example.Person.Fields.id. If it does, then this is a known probleem, and not something we can easily fix.

@c-koell
Copy link
Author

c-koell commented Oct 25, 2023

Hi @rspilker !

Also with full qualified name the problem exists :-(

thanks for your help !

@Rawi01
Copy link
Collaborator

Rawi01 commented Oct 25, 2023

Can reproduce this in eclipse, two files are required. I have already found out that at some point the initializer of the generated field gets replaced with null.

@Rawi01 Rawi01 added bug eclipse accepted The issue/enhancement is valid, sensible, and explained in sufficient detail labels Oct 25, 2023
@c-koell
Copy link
Author

c-koell commented Nov 6, 2023

@Rawi01 do you have some plan how to fix it ?

@Rawi01
Copy link
Collaborator

Rawi01 commented Nov 6, 2023

Yes, I have almost finished my patch for this problem

@c-koell
Copy link
Author

c-koell commented Nov 6, 2023

@Rawi01 that sounds great ! I would also test your patch if you like.

Rawi01 added a commit to Rawi01/lombok that referenced this issue Nov 6, 2023
Eclipse copies the field initializer source code if it is a constant.
For generated nodes we have to read it from the ast node and not from
the source file.
Rawi01 added a commit to Rawi01/lombok that referenced this issue Nov 9, 2023
Eclipse copies the field initializer source code if it is a constant.
For generated nodes we have to read it from the ast node and not from
the source file.
@c-koell
Copy link
Author

c-koell commented Dec 5, 2023

@Rawi01 do you know when this fix will be available ? Thanks !

@c-koell
Copy link
Author

c-koell commented Jan 15, 2024

@Rawi01 any news here ? It would be great if we could have some fix for it .. thanks lot !

Rawi01 added a commit to Rawi01/lombok that referenced this issue Jan 15, 2024
Eclipse copies the field initializer source code if it is a constant.
For generated nodes we have to read it from the ast node and not from
the source file.
@Rawi01
Copy link
Collaborator

Rawi01 commented Jan 15, 2024

Oh, I forgot to create a pull request for the changes, sorry.

@c-koell
Copy link
Author

c-koell commented Jan 17, 2024

@Rawi01 thank you for the fix ! How often will the Snapshot be build so that i can try it ?

@rzwitserloot
Copy link
Collaborator

rzwitserloot commented Jan 18, 2024

@c-koell Anytime we do something even remotely significant. Possibly tonight (thursday evening), @rspilker and I usually find some time to do some work. I suggest you reload the edge-release page on friday and have a look ;)

@c-koell
Copy link
Author

c-koell commented Feb 16, 2024

@rzwitserloot the edge-release page says always version: 1.18.31 (2024-01-12 00:13:12 UTC)
should it contain that fix ?

@rspilker
Copy link
Collaborator

This is part of the latest edge release, all feedback is welcome.

@getzabelz
Copy link

getzabelz commented Apr 11, 2024

Now It's even worse to me, everytime I change a java class file the errors for the constants comes back

Only workaround I found is everytime i change a class file to delete all error messages, maven package, and refresh. I'll go back to lombok 31 subversion which was only throwing this errors from time to time

@c-koell
Copy link
Author

c-koell commented Apr 14, 2024

@getzabelz i see no more problems .. that's interesting that you have now more problems ..

@getzabelz
Copy link

getzabelz commented Apr 15, 2024

@c-koell

@getzabelz i see no more problems .. that's interesting that you have now more problems ..

Maybe I have something wrong in my local? Tried with a fresh installed Eclipse and I still get the same, actual config is:

  • Version: 2024-03 (4.31.0)
  • Build id: 20240307-1437
  • Lombok v1.18.32 "Envious Ferret" is installed. https://projectlombok.org/
  • JDK 17

An example usage that throws error:
@JsonIgnoreProperties(Entity.Fields.field1)

throws following error marker:
The value for annotation attribute JsonIgnoreProperties.value must be a constant expression

Only workaround that temporarily works for me is removing all markers, maven package and refresh and still It only works half of the times...

any idea?

@Rawi01
Copy link
Collaborator

Rawi01 commented Apr 15, 2024

@getzabelz Can you share a full example and also check if there is an error in your eclipse error log?

@getzabelz
Copy link

getzabelz commented Apr 16, 2024

@Rawi01

@getzabelz Can you share a full example and also check if there is an error in your eclipse error log?

Checked eclipse logs and I don't see anything related to Lombok. I've been doing tests in a fresh setup and It seems that It breaks whenever I use QueryDSL with Lombok and @FieldNameConstants, could it be a conflict in between processors? I can't find any information or workaround, anyone got any clue?

My pom.xml configuration related to both in case It's useful:

<querydsl.version>5.1.0</querydsl.version>
<dependency>
	<groupId>com.querydsl</groupId>
	<artifactId>querydsl-jpa</artifactId>
	<classifier>jakarta</classifier>
	<version>${querydsl.version}</version>
</dependency>
<dependency>
	<groupId>org.projectlombok</groupId>
	<artifactId>lombok</artifactId>
	<scope>provided</scope>
</dependency>

<plugin>
  <groupId>com.mysema.maven</groupId>
  <version>1.1.3</version>
  <artifactId>apt-maven-plugin</artifactId>
  <executions>
	  <execution>
		  <goals>
			  <goal>process</goal>
		  </goals>
		  <phase>generate-sources</phase>
		  <configuration>
			  <outputDirectory>target/generated-sources/java</outputDirectory>
			  <processors>
				  <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
				  <processor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</processor>
			  </processors>
		  </configuration>
	  </execution>
  </executions>
  <dependencies>
	  <dependency>
		  <groupId>com.querydsl</groupId>
		  <artifactId>querydsl-apt</artifactId>
		  <version>${querydsl.version}</version>
		  <classifier>jakarta</classifier>
	  </dependency>
  </dependencies>
</plugin>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail bug eclipse
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants