问题
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.
回答1:
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
回答2:
Try updating lombok to the most recent version (Download 1.18.10). It worked for me.
回答3:
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.
回答4:
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.
来源:https://stackoverflow.com/questions/56175308/internal-compiler-error-classcast-exception