IntelliJ IDEA tells me "Error:java: Compilation failed: internal java compiler error idea"

JavaIntellij Idea

Java Problem Overview


When I compile a Java project using IntelliJ IDEA, it gives me the following output (and error):

Information:Eclipse compiler 4.6.2 was used to compile java sources
Information:Module "sinoWeb" was fully rebuilt due to project configuration/dependencies changes
Information:2017/3/23 11:44 - Compilation completed with 1 error and 0 warnings in 5m 32s 949ms
Error:java: Compilation failed: internal java compiler error

I'm quite confused confused by this! Below are my settings:

enter image description

enter image description here

Java Solutions


Solution 1 - Java

  1. On Intellij IDEA Ctrl + Alt + S to open settings.
  2. Build, Execution, Deployment -> Compiler -> Java Compiler
  3. choose your java version from Project bytecode version
  4. Uncheck Use compiler from module target JDK when possible
  5. click apply and ok.

Solution 2 - Java

I solved this issue by increasing the default value(700) of Build process heap size on IntelliJ's compiler settings.

enter image description here

Solution 3 - Java

I changed my compiler to Eclipse and run my project. Afterwards changed back to Javac and problem solved. I don't know exact problem but it can help who is looking for solution.

intellij java compiler

Solution 4 - Java

In my case, using Java 11, I had:

 public List<String> foo() {
   ...
   return response.readEntity(new GenericType<List<String>>() {});

and Intellij suggested I should use <> instead of GenericType<List<String>>, as such:

 public List<String> foo() {
   ...
   return response.readEntity(new GenericType<>() {});

I did that in four functions and the project stopped compiling with an internal compiler error, reverted and it compiled again. Looks like a bug with type inference.

Solution 5 - Java

For me the module's target bytecode version was set to 5. I changed it to 8 and the error is gone:

module's bytecode version setting

Solution 6 - Java

In my case it was because of lombok library with intellij 2019.2 & java11.

According to this IDEA bug after workaround idea works again:

Disable all building from intelliJ and dedicate the build to Maven.

enter image description here

Solution 7 - Java

In JIdea 2020.1.2 and above,

This is may be the language-level set in Project Structure is not compatible with the target byte-code version.

You have to change the target bytecode version .

  1. Go to Settings [ Ctrl+Alt+S ]
  2. Select Java Compiler
  3. Select module in the table
  4. Change the byte-code version to map what you selected in the previous step for language-level

enter image description here

NOTE : How to check the language-level

  1. Go to Project Structure [ Ctrl+Alt+Shift+S ]
  2. Select Modules sub section
  3. Select each module
  4. Under sources-section, check Language Level

enter image description here

Solution 8 - Java

Per-module bytecode version settings

I met the same problem

I solved it by changing the Target bytecode error from 1.5 to 8

Solution 9 - Java

You have to disabled the Javac Options: Use compiler from module target JDK when possible. enter image description here

Solution 10 - Java

Changing the Language Level in the Project Settings (Ctrl + Alt + Shift + S) to Java 8 solved the problem for me

Solution 11 - Java

In my case, it was response type in restTemplate: enter image description here

ResponseEntity<Map<String, Integer>> response = restTemplate.exchange(
		eurl,
		HttpMethod.POST,
		requestEntity,
		new ParameterizedTypeReference<>() { <---- this causes error
		}
);

Should be like this:

ParameterizedTypeReference<Map<String, Integer>> responseType = new ParameterizedTypeReference<>() {};

ResponseEntity<Map<String, Integer>> response = restTemplate.exchange(
		url,
		HttpMethod.POST,
		requestEntity,
		responseType
);

Solution 12 - Java

I had the same problem. I fixed changing my settings. Target bytecode version for equals Project bytecode version.

enter image description here

Solution 13 - Java

What worked for me is to update the Open JDK version

Solution 14 - Java

I got the same error with Community edition 2020.3 on Windows 10 with an older version of the JDK (openjdk version "11" 2018-09-25).

Updating the JDK to javac 11.0.10 fixed the issue.

Here's the stack trace that showed up with the error when using openjdk version "11" 2018-09-25:

java: compiler message file broken: key=compiler.misc.msg.bug arguments=11, {1}, {2}, {3}, {4}, {5}, {6}, {7}
java: java.lang.AssertionError
java: 	at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
java: 	at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$2$1.setOverloadKind(DeferredAttr.java:172)
java: 	at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitReference(ArgumentAttr.java:283)
java: 	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMemberReference.accept(JCTree.java:2190)
java: 	at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
java: 	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3573)
java: 	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2110)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2006)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitReturn(Attr.java:1866)
java: 	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1546)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
java: 	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:498)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:481)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculativeLambda(DeferredAttr.java:456)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.canLambdaBodyCompleteNormally(DeferredAttr.java:900)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.visitLambda(DeferredAttr.java:878)
java: 	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1807)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.complete(DeferredAttr.java:832)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:335)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:779)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:626)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:214)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:605)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1563)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1733)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1802)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1776)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve$10.doLookup(Resolve.java:2654)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3293)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3543)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2651)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2645)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3721)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3601)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2598)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$4.complete(DeferredAttr.java:374)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:321)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1060)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:887)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:775)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:896)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:181)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:644)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:4120)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3913)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3814)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.checkId(Attr.java:3803)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3696)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2595)
java: 	at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:811)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:3553)
java: 	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2243)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:702)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1773)
java: 	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1098)
java: 	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4683)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4574)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4523)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4503)
java: 	at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4448)
java: 	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1341)
java: 	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
java: 	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
java: 	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
java: 	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
java: 	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
java: 	at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:231)
java: 	at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:501)
java: 	at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:353)
java: 	at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:277)
java: 	at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:231)
java: 	at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1441)
java: 	at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1100)
java: 	at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1224)
java: 	at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1066)
java: 	at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:832)
java: 	at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:419)
java: 	at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:183)
java: 	at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:132)
java: 	at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)
java: 	at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:132)
java: 	at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:219)
java: 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java: 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java: 	at java.base/java.lang.Thread.run(Thread.java:834)
java: Compilation failed: internal java compiler error
java: Errors occurred while compiling module 'project'
javac 11 was used to compile java sources
Finished, saving caches...
Compilation failed: errors: 1; warnings: 100

Solution 15 - Java

Updated Java compiler to correct "Target bytecode version" which in my case is 8 :

enter image description here

Solution 16 - Java

enter image description here

Setting -> Build -> Compiler -> Java Compiler The Target bytecode version of the module is wrong. I set it to 1.8, then it worked.

Solution 17 - Java

one reason may be jdk version donot macth minimal version of your project.

Solution 18 - Java

Be aware of JDK-8177068 issue, which leads to internal error like

java.lang.NullPointerException
        at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitApply(Flow.java:1233)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1628)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:393)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitExec(TreeScanner.java:213)
        ...

It was fixed in JDK 11.0.12 and JDK 14 b14, so upgrade helped.

Solution 19 - Java

In my case I had to go to help > show logs in files which opens up the idea.log and build-log folders something like

/home/user/.cache/JetBrains/IntelliJIdea2021.2/log/build-log/ where I set the log level to DEBUG in the log4j.rootLogger=debug, file in build-log.properties

I then ran build again and saw

2021-11-27 19:59:39,808 [ 133595]  DEBUG - s.incremental.java.JavaBuilder - Compiling chunk [module] with options: "-g -deprecation -encoding UTF-8 -source 11 -target 11 -s /home/user/project/target/generated-test-sources/test-annotations", mode=in-process
2021-11-27 19:59:41,082 [ 134869]  DEBUG - s.incremental.java.JavaBuilder - java:ERROR:Compilation failed: internal java compiler error

which lead me to see that this might me related to junit test compilation failing. It turns out I had an older/mismatching of the vintage engine and the jupiter engine which are likely to have different java versions relating in the error above. Changing them to be the same ${version.junit} removed the error.

  <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>1.6.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-commons</artifactId>
            <version>1.7.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>

In short some of your dependency jars may have mismatching java versions.

Solution 20 - Java

It May is not be relevant to this case, but:

I got this error when I change the Explicit type argument List of:

new ParameterizedTypeReference<List<SomeDtoObject>>()

to <> :

new ParameterizedTypeReference<>()

in restTemplate call after Intellij gave the warning to use <> instead.

It got fixed when I undo my changes back into the Explicit type argument.

Solution 21 - Java

In my case Information:java: java.lang.OutOfMemoryError: GC overhead limit exceeded intellij.

increased compiler -> build process heap size.

enter image description here

Ref: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003315120-GC-overhead-limit-exceeded

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionieatczpView Question on Stackoverflow
Solution 1 - JavaMusab BozkurtView Answer on Stackoverflow
Solution 2 - JavasezerugView Answer on Stackoverflow
Solution 3 - JavaomerhakanbiliciView Answer on Stackoverflow
Solution 4 - JavaTony BenBrahimView Answer on Stackoverflow
Solution 5 - JavavelocityView Answer on Stackoverflow
Solution 6 - JavaFilomatView Answer on Stackoverflow
Solution 7 - JavaprimeView Answer on Stackoverflow
Solution 8 - Javakl wView Answer on Stackoverflow
Solution 9 - JavaDuc Hiep HoangView Answer on Stackoverflow
Solution 10 - JavaChris K.View Answer on Stackoverflow
Solution 11 - Javadev_in_progressView Answer on Stackoverflow
Solution 12 - JavaThiago de Melo FontanaView Answer on Stackoverflow
Solution 13 - JavaNobuhleMView Answer on Stackoverflow
Solution 14 - JavaPradyumna RevurView Answer on Stackoverflow
Solution 15 - Javablue-skyView Answer on Stackoverflow
Solution 16 - JavarosaView Answer on Stackoverflow
Solution 17 - Javauser13243683View Answer on Stackoverflow
Solution 18 - JavaNikita BosikView Answer on Stackoverflow
Solution 19 - JavaGridcell CoderView Answer on Stackoverflow
Solution 20 - JavaJayView Answer on Stackoverflow
Solution 21 - JavaSureshkumar NatarajanView Answer on Stackoverflow