Describe the bug
When building the project in Eclipse 2019-03, the following exception occurs:
Errors occurred during the build. Errors running builder 'Java Builder' on project 'project_name'. class org.eclipse.jdt.internal.compiler.lookup.MethodBinding cannot be cast to class org.eclipse.jdt.internal.compiler.lookup.FieldBinding (org.eclipse.jdt.internal.compiler.lookup.MethodBinding and org.eclipse.jdt.internal.compiler.lookup.FieldBinding are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @3566d527)
To Reproduce
I'm not sure what specific source code triggers this bug — it's a large project. I haven't been able to isolate the code that breaks Lombok.
However, it occurs in Eclipse 2019-03 running under Java 11 with Lombok 1.18.8. Neither 1.18.4 nor 1.18.6 are affected.
The version of Lombok used as the project build dependency does not seem to matter. The project currently uses 1.18.4.
Expected behavior
The project should build normally, as it does with 1.18.4 and 1.18.6.
Version info (please complete the following information):
Yes,I found the same problem too !
Same issue in Eclipse 2019-06 (4.12.0; ID 20190614-1200) after updating from lombok 1.18.6 to 1.18.8.
Also found this related issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=547244
I tried to make a sample to reproduce the issue but failed. Once I removed other non-lombok classes from the project, or copied the class that presumably failed or removed class members step by step, or removed the lombok annotations then eclipse could compile the workspace again (I cleaned the project between all steps). The only combination that fails is the project as is but this I cannot share unfortunately.
I tried to make a sample to reproduce the issue but failed. Once I removed other non-lombok classes from the project, or copied the class that presumably failed or removed class members step by step, or removed the lombok annotations then eclipse could compile the workspace again (I cleaned the project between all steps). The only combination that fails is the project as is but this I cannot share unfortunately.
I had the same problem. I tried copying the lombok-enabled class listed in the error message into a new project, but its compilation then succeeded.
I had the same problem, was able to fix it by switching to lombok-1.18.2
Can someone please provide a stacktrace?
Oh, and instead of adding a comment with just "+1", please use the +:smile: on the right hand top of the comment you're +1-ing
Am facing same issue::
Eclipse IDE for Enterprise Java Developers.
Version: 2019-03 (4.11.0)
Build id: 20190314-1200
lombok-1.18.4
Markers
Description Resource Path Location Type
Internal compiler error: java.lang.ClassCastException ABC.java /com/test line 0 Java Problem
A slightly different message:
Internal compiler error: java.lang.ClassCastException: class org.eclipse.jdt.internal.compiler.lookup.MethodBinding cannot be cast to class org.eclipse.jdt.internal.compiler.lookup.FieldBinding (org.eclipse.jdt.internal.compiler.lookup.MethodBinding and org.eclipse.jdt.internal.compiler.lookup.FieldBinding are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @2433bcd4) at org.eclipse.jdt.internal.compiler.ast.ASTNode.resolveAnnotations(ASTNode.java:822)
Okay, we've found a probable cause.
We've found a problem when annotations we're copied to the setter. Since v1.18.8 we have built-in support for handling @JsonProperty and @JsonValue. But it is also possibly to configure your own list of annotations that should be copied to the setter.
This one was a bit harder to find because it only occurs if the annotation is copied from the field to the method after it has already been resolved. Presumably, this only happens under certain circumstances.
In my companies we have 30+ compilation units that generate a setter on @JsonProperty, but only one gave the CCE.
For all developer out there having same issue:
@setter gives this issue with eclipse replace it with @data and it fixes the problems for me thanks @rspilker for pointing me to the right direction with your comment about @settter!