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:
21 Answers
- On Intellij IDEA Ctrl + Alt + S to open settings.
- Build, Execution, Deployment -> Compiler -> Java Compiler
- choose your java version from Project bytecode version
- Uncheck Use compiler from module target JDK when possible
- click apply and ok.
I solved this issue by increasing the default value(700) of Build process heap size on IntelliJ's compiler settings.
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.
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.
For me the module's target bytecode version was set to 5. I changed it to 8 and the error is gone:
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.
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 .
- Go to Settings [ Ctrl+Alt+S ]
- Select Java Compiler
- Select module in the table
- Change the byte-code version to map what you selected in the previous step for language-level
NOTE : How to check the language-level
- Go to Project Structure [ Ctrl+Alt+Shift+S ]
- Select Modules sub section
- Select each module
- Under sources-section, check Language Level
I met the same problem
I solved it by changing the Target bytecode error from 1.5 to 8
You have to disabled the Javac Options: Use compiler from module target JDK when possible.
Changing the Language Level in the Project Settings (Ctrl + Alt + Shift + S) to Java 8 solved the problem for me
In my case, it was response type in restTemplate:
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
);
I had the same problem. I fixed changing my settings. Target bytecode version for equals Project bytecode version.
What worked for me is to update the Open JDK version
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 (Assert.java:155)
java: at (Assert.java:46)
java: at (DeferredAttr.java:172)
java: at (ArgumentAttr.java:283)
java: at (JCTree.java:2190)
java: at (ArgumentAttr.java:197)
java: at (Attr.java:653)
java: at (Attr.java:751)
java: at (Attr.java:1997)
java: at (JCTree.java:1634)
java: at (Attr.java:655)
java: at (Attr.java:3573)
java: at (JCTree.java:2110)
java: at (Attr.java:2006)
java: at (Attr.java:1866)
java: at (JCTree.java:1546)
java: at (Attr.java:724)
java: at (Attr.java:743)
java: at (Attr.java:1294)
java: at (JCTree.java:1020)
java: at (DeferredAttr.java:498)
java: at (DeferredAttr.java:481)
java: at (DeferredAttr.java:456)
java: at (DeferredAttr.java:900)
java: at (DeferredAttr.java:878)
java: at (JCTree.java:1807)
java: at (DeferredAttr.java:832)
java: at (DeferredAttr.java:335)
java: at (DeferredAttr.java:779)
java: at (DeferredAttr.java:626)
java: at (Infer.java:214)
java: at (Resolve.java:605)
java: at (Resolve.java:1563)
java: at (Resolve.java:1733)
java: at (Resolve.java:1802)
java: at (Resolve.java:1776)
java: at (Resolve.java:2654)
java: at (Resolve.java:3293)
java: at (Resolve.java:3543)
java: at (Resolve.java:2651)
java: at (Resolve.java:2645)
java: at (Attr.java:3721)
java: at (Attr.java:3601)
java: at (Attr.java:2598)
java: at (DeferredAttr.java:374)
java: at (DeferredAttr.java:321)
java: at (Resolve.java:1060)
java: at (Resolve.java:887)
java: at (Resolve.java:775)
java: at (Resolve.java:896)
java: at (Infer.java:181)
java: at (Resolve.java:644)
java: at (Attr.java:4120)
java: at (Attr.java:3913)
java: at (Attr.java:3814)
java: at (Attr.java:3803)
java: at (Attr.java:3696)
java: at (Attr.java:2595)
java: at (DeferredAttr.java:811)
java: at (Attr.java:3553)
java: at (JCTree.java:2243)
java: at (Attr.java:702)
java: at (Attr.java:1773)
java: at (JCTree.java:1452)
java: at (Attr.java:1098)
java: at (JCTree.java:866)
java: at (Attr.java:4683)
java: at (Attr.java:4574)
java: at (Attr.java:4523)
java: at (Attr.java:4503)
java: at (Attr.java:4448)
java: at (JavaCompiler.java:1341)
java: at (JavaCompiler.java:973)
java: at (JavacTaskImpl.java:104)
java: at (JavacTaskImpl.java:147)
java: at (JavacTaskImpl.java:100)
java: at (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 (ThreadPoolExecutor.java:1128)
java: at (ThreadPoolExecutor.java:628)
java: at (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
Updated Java compiler to correct "Target bytecode version" which in my case is 8 :
Setting -> Build -> Compiler -> Java Compiler The Target bytecode version of the module is wrong. I set it to 1.8, then it worked.
one reason may be jdk version donot macth minimal version of your project.
Be aware of JDK-8177068 issue, which leads to internal error like
java.lang.NullPointerException
at (Flow.java:1233)
at (JCTree.java:1628)
at (TreeScanner.java:49)
at (Flow.java:393)
at (TreeScanner.java:213)
...
It was fixed in JDK 11.0.12 and JDK 14 b14, so upgrade helped.
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.
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.
In my case Information:java: java.lang.OutOfMemoryError: GC overhead limit exceeded intellij.
increased compiler -> build process heap size.
Ref: