IntelliJ 15.0.4
lombok 1.16.8
Compiles fine with Gradle (2.3). When compiling in IntelliJ, it gives the following error. I think it might be classpath related since sometimes if I add a new dependency it starts working again until I swizzle dependencies around. I'm not positive on that though. For instance, I upgraded lombok from 1.16.6 -> lombok 1.16.8 and it started working. Yay! Then I upgraded another (Dropwizard) library and it started failing again.
Warning:(14, 17) java: lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this compilation: java.lang.ClassCastException: Cannot cast lombok.javac.handlers.HandleFieldDefaults to lombok.javac.JavacAnnotationHandler
at java.lang.Class.cast(Class.java:3369)
at lombok.core.SpiLoadUtil$1$1.next(SpiLoadUtil.java:111)
at lombok.javac.HandlerLibrary.loadAnnotationHandlers(HandlerLibrary.java:170)
at lombok.javac.HandlerLibrary.load(HandlerLibrary.java:155)
at lombok.javac.JavacTransformer.
at lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:86)
at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:87)
at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:141)
at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:53)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.
at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:597)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:690)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:168)
at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:388)
at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:289)
at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:197)
at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:168)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1230)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:904)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:976)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:870)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:695)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:386)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:193)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:137)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:294)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:232)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Hmm, found one spot still pointed at lombok 1.16.6. I updated that to 1.16.8 and the problem has gone away again.
However, it used to work with 1.16.6 at one point. Updating was my shot at trying to make the error go away. I'm not sure if the update has fixed it or swizzled the classpath such that it doesn't happen.
Hello Chris,
can you make some minimal example of a project to reproduce your error?
I think, without some example nobody it would be extreme difficult for me or lombok guys to find any solution.
Sadly, no :frowning: . Or at least I haven't been able to yet. Anytime I strip it down to a minimal project the error vanishes.
I'll pay extra attention whenever a library is added/removed/updated and if this comes up again, maybe I can at least give the IntelliJ compile invocation lines that cause it and that should highlight the paths and the library change.
For now, it's working. Hopefully it'll stay that way :four_leaf_clover:
Is your project working in "classpath file mode"? Can you check your .idea/workspace.xml file please, does it contains:
<property name="dynamic.classpath" value="true" />
?
I don't have that value set. Should I have it set? I don't see a checkbox for it in the IntelliJ settings.
No, you should not. Is it possible, that on big project Intellij automatically switch to classpath file mode for compiling. That could explain problems like yours...
One interesting fact to remember is that IDEA 2016.1 introduced a much better handling of Gradle, so it might actually be related to IDEA itself.
This happened to me in intelliJ - if you have multiple version of lombok in project libraries - check list of libs in Libraries under in project settings - in my case I migrated from maven to gradle build and it imported libs from maven pom file(older lombok) that I used earlier and also libs from gradle file(newever lombok version) so it doubled the deps and unfortunatelly idea compiler picks the older one. Once older one is removed from this list it works like a charm.
@javamachr same issue here. multiple version of lombok lib. Thanks
Sorry for our delayed responses.
What I read based on your comments is that the issue is when you have multiple version of Lombok on CP and this causes issues? Is this correct?
Yes that was the issue in my case.
yup issue was when i had multiple version of lombok.
The external libs in IntelliJ had two version- 1.16.4 & 1.16.8.
After removing 1.16.4, it started working.
Closed, as it is not an issue with plugin self
I have this problem on 3 x projects that worked Monday (today being Friday) and started failing after upgrading to Gradle v4.9. Just using:
gradle build
:
I suggest people follow the discussion under the Annotation Processor plugin project issue:
Most helpful comment
yup issue was when i had multiple version of lombok.
The external libs in IntelliJ had two version- 1.16.4 & 1.16.8.
After removing 1.16.4, it started working.