IntelliJ Idea mapstruct java: Internal error in the mapping processor:com.sun.tools.javac.jvm.ClassReader$BadClassFile: bad class file - intellij-idea

Recently I started getting bad class file during build in IntelliJ IDEA 2021.2.2 and MapStruct version 1.4.2.Final. Maven build is running fine. Does anyone have a clue? Thanks a lot!!
Intellij compiler logs:
DEBUG - s.incremental.java.JavaBuilder - java:ERROR:Internal error in the mapping processor: com.sun.tools.javac.jvm.ClassReader$BadClassFile: bad class file: Please remove or make sure it appears in the correct subdirectory of the classpath.
at com.sun.tools.javac.jvm.ClassReader.badClassFile(ClassReader.java:357)
at com.sun.tools.javac.jvm.ClassReader.readEnclosingMethodAttr(ClassReader.java:1276)
at com.sun.tools.javac.jvm.ClassReader$12.read(ClassReader.java:1130)
at com.sun.tools.javac.jvm.ClassReader.readAttrs(ClassReader.java:1381)
at com.sun.tools.javac.jvm.ClassReader.readClassAttrs(ClassReader.java:1396)
at com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:2226)
at com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2324)
at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2511)
at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2442)
at com.sun.tools.javac.jvm.ClassReader.access$000(ClassReader.java:76)
at com.sun.tools.javac.jvm.ClassReader$1.complete(ClassReader.java:240)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:574)
at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1037)
at com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:973)
at com.sun.tools.javac.code.Symbol$TypeSymbol.getEnclosedElements(Symbol.java:734)
at javax.lang.model.util.ElementScanner6.visitPackage(ElementScanner6.java:167)
at com.sun.tools.javac.code.Symbol$PackageSymbol.accept(Symbol.java:901)
at com.sun.tools.javac.processing.JavacRoundEnvironment$AnnotationSetScanner.scan(JavacRoundEnvironment.java:158)
at com.sun.tools.javac.processing.JavacRoundEnvironment$AnnotationSetScanner.scan(JavacRoundEnvironment.java:127)
at com.sun.tools.javac.processing.JavacRoundEnvironment.getElementsAnnotatedWith(JavacRoundEnvironment.java:121)
at org.mapstruct.ap.MappingProcessor.getMappers(MappingProcessor.java:235)
at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:165)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:802)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:713)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1043)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1184)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)

Related

IntelliJ IDEA crash on startup (NoClassDefFoundError: Could not initialize class com.sun.jna.Native)

Okay so I am using Windows 10, I am having issues starting up intelliJ IDEA as every time I run it, it throws the following error and crashes,
Internal error. Please refer to
https://jb.gg/ide/critical-startup-errors
com.intellij.ide.plugins.StartupAbortedException: Cannot start app
at com.intellij.idea.StartupUtil.lambda$start$15(StartupUtil.java:265)
at java.base/java.util.concurrent.CompletableFuture.uniExceptionally(CompletableFuture.java:990)
at java.base/java.util.concurrent.CompletableFuture$UniExceptionally.tryFire(CompletableFuture.java:974)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class
com.sun.jna.Native
at com.sun.jna.platform.win32.WinReg$HKEYByReference.(WinReg.java:52)
at com.sun.jna.platform.win32.WinReg$HKEYByReference.(WinReg.java:48)
at com.sun.jna.platform.win32.Advapi32Util.registryGetStringValue(Advapi32Util.java:736)
at com.sun.jna.platform.win32.Advapi32Util.registryGetStringValue(Advapi32Util.java:717)
at com.intellij.openapi.util.WinBuildVersionKt.getWinBuildNumberInternal(WinBuildVersion.kt:14)
at com.intellij.openapi.util.WinBuildVersionKt.access$getWinBuildNumberInternal(WinBuildVersion.kt:1)
at com.intellij.openapi.util.WinBuildVersionKt$getWinBuildNumber$1.invoke(WinBuildVersion.kt:33)
at com.intellij.openapi.util.WinBuildVersionKt$getWinBuildNumber$1.invoke(WinBuildVersion.kt)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.intellij.openapi.util.WinBuildVersionKt.getWinBuildNumber(WinBuildVersion.kt:33)
at com.intellij.openapi.util.SystemInfo.getWinBuildNumber(SystemInfo.java:123)
at com.intellij.openapi.wm.impl.customFrameDecorations.header.CustomHeader$CustomFrameTopBorder.calculateAffectsBorders(CustomHeader.kt:276)
at com.intellij.openapi.wm.impl.customFrameDecorations.header.CustomHeader$CustomFrameTopBorder.addNotify(CustomHeader.kt:346)
at com.intellij.openapi.wm.impl.customFrameDecorations.header.CustomHeader.addNotify(CustomHeader.kt:158)
at com.intellij.openapi.wm.impl.customFrameDecorations.header.DialogHeader.addNotify(DialogHeader.kt:59)
at java.desktop/java.awt.Container.addNotify(Container.java:2804)
at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4847)
at java.desktop/java.awt.Container.addNotify(Container.java:2804)
at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4847)
at java.desktop/java.awt.Container.addNotify(Container.java:2804)
at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4847)
at java.desktop/javax.swing.JRootPane.addNotify(JRootPane.java:729)
at java.desktop/java.awt.Container.addNotify(Container.java:2804)
at java.desktop/java.awt.Window.addNotify(Window.java:797)
at java.desktop/java.awt.Dialog.addNotify(Dialog.java:770)
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.addNotify(DialogWrapperPeerImpl.java:641)
at java.desktop/java.awt.Window.pack(Window.java:835)
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.pack(DialogWrapperPeerImpl.java:311)
at com.intellij.openapi.ui.DialogWrapper.pack(DialogWrapper.java:1432)
at com.intellij.ide.gdpr.AgreementUi.pack(AgreementUi.kt:254)
at com.intellij.ide.gdpr.Agreements.showEndUserAndDataSharingAgreements(Agreements.kt:19)
at com.intellij.idea.StartupUtil.lambda$showEuaIfNeeded$25(StartupUtil.java:607)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:779)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:749)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:393)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
----- Your JRE: 17.0.3+7-b469.32 amd64 (JetBrains s.r.o.) C:\Program Files\Jetbrains\IntelliJ IDEA\jbr
Has anyone encountered something like this? I've never seen this issue before so completely clueless, any help would be greatly appreciated.
Thanks a lot
When running the IntelliJ IDEA, a dll
C:\Users<user_name>\AppData\Local\JetBrains\IntelliJIdea2022.2\tmp\jnaxxxx.dll is extracted in IDEA's temp dir and executed.
In Windows, some security tools can restrict the folders where binaries (e.g. dll, ...) can be executed.
If you have security tools installed, ensure that all IDE, project, and IDE installation directories are added to the exclusions list.

Problems in IntelliJ since version 2022.1 / java.lang.NoClassDefFoundError

As of today, when I try to run some of my programs in IntelliJ today, this message was shown:
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Running 'before' tasks
Checking sources
Finished, saving caches…
Module 'Listen' production: java.lang.NoClassDefFoundError: com/intellij/DynamicBundle
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories...
13.04.22, 14:54 - Build completed with 1 error and 0 warnings in 4 sec, 39 ms
This line is printed in red: Module 'Listen' production: java.lang.NoClassDefFoundError: com/intellij/DynamicBundle
I don't really have too much of an idea where I should look for the problem.
It seems to not have anything to do with the project itself. I already created a new Project and created a Hello World-program, which resulted in the same error.
Remarkably, yesterday my IntelliJ IDEA version was updated to version 2022.1.
Runtime version: 11.0.14.1+1-b2043.25 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
I have no idea either whether it has anything to do with the new version either.
I maintain another Project, which uses Scala language. That one is messed up even more:
Cannot process toolwindow sbt
java.lang.AbstractMethodError: Missing implementation of resolved method 'abstract com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings getSettings(com.intellij.openapi.project.Project)' of abstract class com.intellij.openapi.externalSystem.service.task.ui.AbstractExternalSystemToolWindowFactory.
at com.intellij.openapi.externalSystem.service.task.ui.AbstractExternalSystemToolWindowFactory.shouldBeAvailable(AbstractExternalSystemToolWindowFactory.java:35)
at com.intellij.toolWindow.ToolWindowSetInitializerKt.beanToTask(ToolWindowSetInitializer.kt:262)
at com.intellij.toolWindow.ToolWindowSetInitializerKt.beanToTask(ToolWindowSetInitializer.kt:248)
at com.intellij.toolWindow.ToolWindowSetInitializerKt.access$beanToTask(ToolWindowSetInitializer.kt:1)
at com.intellij.toolWindow.ToolWindowSetInitializerKt$computeToolWindowBeans$1.accept(ToolWindowSetInitializer.kt:278)
at com.intellij.toolWindow.ToolWindowSetInitializerKt$computeToolWindowBeans$1.accept(ToolWindowSetInitializer.kt)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processWithPluginDescriptor(ExtensionPointImpl.java:301)
at com.intellij.toolWindow.ToolWindowSetInitializerKt.computeToolWindowBeans(ToolWindowSetInitializer.kt:274)
at com.intellij.toolWindow.ToolWindowSetInitializer$1.get(ToolWindowSetInitializer.kt:101)
at com.intellij.toolWindow.ToolWindowSetInitializer$1.get(ToolWindowSetInitializer.kt:83)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:829)
Any advice?
Best
Stapelüberläufer
I had the same problem after upgrading to Intellij 2022.1
For me, the fix came from Gen's answer. I also had an old Scala plugin, and just removed it as I'm not using it anymore.
If you are looking to upgrade it, go to File -> Settings -> Plugins. From there just hit Upgrade for the plugins you want. After that restart the IDE.
I found that Scala plugin was not updated and updating it to at least version 2022.1.13 fixed it for me.
I upgraded to Intellij 2022.1 and encountered this issue when trying to sync the old gradles projects that used to work for me :
Caused by: java.lang.NoClassDefFoundError: org/gradle/internal/impldep/com/google/common/collect/Lists
Cleaning the caches folder's content (Gradle_HOME/caches) resolved this issue for me
Make sure to also check that the SDK is correctly configured for your project (Java 17 by default) and the Gradle home is well specified in the Settings>Gradle section.
For info, I'm using Java 8 and Gradle 5.5.1 (yes I know :))
Just upgrade the Scala Plugin and its done!
visiting
scala plugin's page
and install it from there worked for me on ultimate version 2022.2.3

Kapt not processing micronaut-predator-processor

I am trying to use the new Predator JPA/JDBC library from Micronaut.
I wish to use the JDBC integration rather than JPA.
I am having a couple of issues however, the documentation says to include:
annotationProcessor 'io.micronaut.data:micronaut-predator-processor:1.0.0.BUILD-SNAPSHOT'
Which I have done so, but the kapt section of the build fails with the following error:
Caused by: java.lang.NoSuchMethodError: io.micronaut.core.annotation.AnnotationMetadata.enumValue(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/Class;)Ljava/util/Optional;
I am using micronaut 1.1.4 on JVM 12.0.1
If I replace kapt with annotationProcessor, the build completes fine, however I get a runtime issue:
Caused by: java.lang.ClassNotFoundException: io.micronaut.data.exceptions.DataAccessException
Which is odd as I seem to be able to use kapt/annotationProcessor interchangeable for micronaut security.
I faced the same problem when running tests from Intellij Idea. But they passed when run through gradle.
If you are using Intellij Idea and facing this issue, try following options in the sequence:
Invalidate Idea cache and restart
Enable Annotation Processing
Delegate IDE build/run actions to gradle. This setting had got reset to Idea when I upgraded my Intellij version.
I can get this to work for the micronaut 1.2.0 RC2 by updating the BOM entry:
dependencyManagement {
imports {
mavenBom 'io.micronaut:micronaut-bom:1.2.0.RC2'
}
}
This seems to allow all the annotation processing etc to work correctly.

Play framework 2.3.7 not compiling on intellij 14.1.3

Error:Error while importing SBT project:
(...)
at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency: sbt-run-> support-210#sbt-run-support-210_2.10;0.1-SNAPSHOT: not found
Invalid response.
See complete log in > /Users/HulkHogan/Library/Logs/IntelliJIdea14/sbt.last.log
Does anyone know how to solve this ?
My project is compiling from cli.
I already tried following operations :
upgrading play from 2.3.7 to 2.3.9
running "activator idea"
restarting intellij 14.1.3
according to this, you need to update your project/plugins.sbt file. replace the version of your sbt plugin with 2.3.6 (is it the latest?)
Deleting .idea/modules and restarting Intellij solved the problem

Could not compile project in Intellij Idea 13 EAP/12.1.5 due to Lombok usages

While trying Intellij Idea 13 EAP ( which I'm aware is not stable ) I could not compile/run a working project because of the following warning:
java: lombok.javac.apt.Processor could not be initialized. Lombok will not run during this compilation: java.lang.ClassCastException: com.sun.tools.javac.processing.JavacProcessingEnvironment cannot be cast to com.sun.tools.javac.processing.JavacProcessingEnvironment
at lombok.javac.apt.Processor.init(Processor.java:84)
at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:89)
at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:143)
It's working very well with Intellij Idea 12, but I need to run on 13 because of an another issue fixed only in 13 (IDEA-104616)
This error comes up:
com.sun.tools.javac.processing.JavacProcessingEnvironment cannot be cast to com.sun.tools.javac.processing.JavacProcessingEnvironment
Update:
Created JetBrains issue: IDEA-114130
It is an Intellij IDEA issue: IDEA-114130
Fixed in build 132.474
Note: Reproducible in Intellij IDEA 12.1.5; avoid upgrade (in case of Lombok use) !
UPDATE:
FIxed version is publicly released.