projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.93k stars 2.4k forks source link

ClassCastException: Cannot cast HandleFieldDefaults to JavacASTVisitor (IntelliJ) #1046

Open chriskessel opened 8 years ago

chriskessel commented 8 years ago

This just started happening and I've no idea why. I dropped all my changes and reverted to master on my repo (so, no changes from last time this was working) and it's still happening, which is a bit baffling. I tried IntelliJ's invalidate cache feature as well. Annotation processing is enabled in IntelliJ's settings.

IntelliJ 15.0.4. JDK 1.8.0_20 Lombok 1.16.8 IntelliJ Lombok plugin 0.9.8.15

I also tried uninstall and reinstalling the IntelliJ lombok plugin.

It always fails with this error when I try to compile the project in IntelliJ. Compiling with "gradle build" externally does work. Warning:(9, 8) 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:3356) 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.(JavacTransformer.java:43) 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.(JavacProcessingEnvironment.java:500) 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)

chriskessel commented 8 years ago

After various fiddling, still fails, but the error is slightly different saying it can't cast HandleFieldDefaults to JavacAnnotationHandler. \Warning:(9, 8) 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:3356) 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.(JavacTransformer.java:43) 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.(JavacProcessingEnvironment.java:500) 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)

aplatypus commented 6 years ago

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: