13

I am getting below error at the start of java file right at letter 'p' of package

Internal compiler error: java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.MethodBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.FieldBinding at org.eclipse.jdt.internal.compiler.ast.ASTNode.resolveAnnotations(ASTNode.java:817)

Project compiles fine from command prompt. but eclipse is showing this error.I am using jdk 8. any help is highly appreciated

I tried restarting eclipse, cleaning project, installing different versions of eclipse etc.

7
  • 2
    Can you please show the code, specific JVM version, Eclipse version, and OS?
    – WJS
    May 16, 2019 at 19:25
  • you are using ecj compiler in eclipse which is != from command line.
    – Eugene
    May 16, 2019 at 19:25
  • 1
    Sounds like a bug in the eclipse compiler. File a report? May 16, 2019 at 19:26
  • @ThorbjørnRavnAndersen Before submitting a bug report, always make sure that not using an outdated version and that the problem has not yet been reported by someone else.
    – howlger
    May 17, 2019 at 6:20
  • @howlger Yes. Others took care of that. Do we agree this looks like a bug in the eclipse compiler? May 17, 2019 at 15:45

4 Answers 4

27

I had a similar issue. It turned out to be a compatibility issue between Lombok 1.18.8 and Eclipse 4.11. I reverted to Lombok 1.18.2 to get it working again. The Eclipse ticket that was closed recommends using Lombok 1.16.18. https://bugs.eclipse.org/bugs/show_bug.cgi?id=547244

4
  • I got this error sometimes not often and 1.18.2 did not work as well. So I am using 1.16.18 without any errors! Jun 10, 2019 at 8:35
  • 1
    The issue should be fixed in the current lombok snapshot (projectlombok.org/download-edge) and in the forthcoming release 1.18.10.
    – Jan Rieke
    Aug 29, 2019 at 21:33
  • I just got the error on Lombok 1.18.8, but then I updated to the most recent lombok version (1.18.10) and the exception is gone.
    – shiramy
    Sep 17, 2019 at 20:00
  • Worked for me!..I think lombok does not support in @JsonProperty POJO's. Thank you so much for the answer Aug 11, 2021 at 12:54
10

I noticed that in my workspace the error only occurs with the classes containing the annotation @JsonProperty. The workaround that I found - comment all these annotations in the class out, save and let the workspace build run. Then uncomment and save, so that the class file returns to its original state. In my case the error disappears until Eclipse compiles the class again. Normally it wouldn't happen as long as the class is not changed.

1
  • You are right. in my case also error went after commenting this annotation. I have one doubt, in other class also this annotation is there, but this error coming for only one class. any idea? Apr 23, 2021 at 7:11
5

Try updating lombok to the most recent version (Download 1.18.10). It worked for me.

2
  • 1
    For those like me who updated the maven/gradle dependency's version that won't fix your IDE problem, you have to download the lombok JAR file (for instance 1.18.10), execute the jar, and point the installation program to your IDE's main directory.
    – atavio
    Nov 29, 2019 at 20:33
  • This was the solution for my case! I heard that it is related to @JsonProperty
    – Mohammed H
    Dec 17, 2019 at 5:31
1

In my case the "Internal compiler error: java.lang.ClassCastException" came from a different version of lombok.jar - one was installed in the eclipse directory as javaagent and the second was in my maven project. After updating the lombok.jar in the eclipse directory anything works fine.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.