IntelliJ IDEA告诉我"错误:java:编译失败:内部java编译器错误想法"

时间:2017-03-23 03:46:28

标签: java intellij-idea

朋友     首先,谢谢你的帮助。     当我使用IntelliJ IDEA编译一个java项目时,它告诉我"编译失败:内部java编译器错误的想法"。更多细节信息喜欢: 信息:Eclipse编译器4.6.2用于编译java源代码 信息:模块" sinoWeb"由于项目配置/依赖项更改而完全重建 信息:2017/3/23 11:44 - 编译完成,1个错误,0个警告,5分32秒949毫秒 错误:java:编译失败:内部java编译器错误     我很困惑。     以下是我的设置。

enter image description

enter image description here

18 个答案:

答案 0 :(得分:16)

  1. Intellij IDEA Ctrl + Alt + S 上打开设置。
  2. 构建,执行,部署-> 编译器-> Java编译器
  3. 项目字节码版本
  4. 中选择Java版本
  5. 取消选中在可能的情况下从模块目标JDK使用编译器
  6. 点击应用,然后确定

答案 1 :(得分:13)

我将编译器更改为Eclipse并运行我的项目。后来改回Javac,问题解决了。我不知道确切的问题,但它可以帮助谁在寻找解决方案。

intellij java compiler

答案 2 :(得分:11)

我通过在IntelliJ的编译器设置上增加构建进程堆大小的默认值(700)来解决此问题。

enter image description here

答案 3 :(得分:10)

对我来说,模块的目标字节码版本设置为5。我将其更改为8,错误消失了:

module's bytecode version setting

答案 4 :(得分:8)

Per-module bytecode version settings

我遇到了同样的问题

我通过将目标字节码错误从 1.5 更改为 8 来解决此问题

答案 5 :(得分:6)

JIdea 2020.1.2及更高版本中

这可能是项目结构中设置的语言级别与目标字节码版本不兼容。

您必须更改目标字节码版本。

  1. 转到设置 [Ctrl + Alt + S]
  2. 选择 Java编译器
  3. 在表格中选择模块
  4. 更改字节码版本以映射上一步在语言级别选择的内容

enter image description here

注意: 如何检查语言水平

  1. 转到项目结构 [ Ctrl + Alt + Shift + S ]
  2. 选择模块子部分
  3. 选择每个模块
  4. 在“来源”部分下,检查语言级别

enter image description here

答案 6 :(得分:2)

您必须禁用Javac选项:尽可能使用来自模块目标JDK的编译器。 enter image description here

答案 7 :(得分:2)

就我而言,这是因为lombok库具有intellij 2019.2和java11。

根据this IDEA bug,变通办法再次可行后:

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

enter image description here

答案 8 :(得分:2)

就我而言,它是restTemplate中的响应类型: enter image description here

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

应该是这样的:

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

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

答案 9 :(得分:1)

我有同样的问题。我修复了更改设置的问题。目标字节码版本等于项目字节码版本。

enter image description here

答案 10 :(得分:1)

我在使用旧版 JDK(openjdk 版本“11”2018-09-25)的 Windows 10 社区版 2020.3 上遇到了同样的错误。

将 JDK 更新到 javac 11.0.10 修复了该问题。

这是使用 openjdk 版本“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

答案 11 :(得分:1)

对我有用的是更新Open JDK版本

答案 12 :(得分:1)

在项目设置(Ctrl + Alt + Shift + S)中将语言级别更改为Java 8可以解决我的问题

答案 13 :(得分:0)

就我而言,使用Java 11,我有:

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

并且Intellij建议我应该使用<>而不是GenericType<List<String>>,例如:

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

我用四个函数做到了这一点,项目因内部编译器错误而停止编译,还原并重新编译。看起来像是带有类型推断的错误。

答案 14 :(得分:0)

更新了 Java 编译器以更正“目标字节码版本”,在我的情况下为 8 :

enter image description here

答案 15 :(得分:0)

enter image description here

设置->构建->编译器->Java编译器 模块的目标字节码版本错误。我将它设置为 1.8,然后它就起作用了。

答案 16 :(得分:0)

一个原因可能是 jdk 版本不符合您项目的最小版本。

答案 17 :(得分:0)

注意 JDK-8177068 问题,这会导致像

这样的内部错误
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)
        ...

它在 JDK 11.0.12JDK 14 b14 中得到修复,因此升级有所帮助。