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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42966889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 00:33:17  来源:igfitidea点击:

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

javaintellij-idea

提问by ieatczp

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

当我使用 IntelliJ IDEA 编译 Java 项目时,它给了我以下输出(和错误):

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

在此处输入图片说明

回答by omerhakanbilici

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.

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

intellij java compiler

intellij java编译器

回答by sezerug

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

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

enter image description here

在此处输入图片说明

回答by Chris K.

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

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

回答by Musab Bozkurt

  1. On Intellij IDEA Ctrl + Alt + Sto 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 applyand ok.
  1. Intellij IDEA Ctrl + Alt + S上打开设置。
  2. 构建、执行、部署->编译器-> Java 编译器
  3. 项目字节码版本中选择您的 Java版本
  4. 尽可能取消选中从模块目标 JDK 使用编译器
  5. 单击应用确定

回答by Duc Hiep Hoang

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

您必须禁用 Javac 选项:尽可能使用来自模块目标 JDK 的编译器。 在此处输入图片说明

回答by Tony BenBrahim

In my case, using Java 11, I had:

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

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

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

和 Intellij 建议我应该使用<>而不是GenericType<List<String>>,因此:

 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.

我在四个函数中做到了这一点,项目停止编译并出现内部编译器错误,恢复并再次编译。看起来像类型推断的错误。

回答by Filomat

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

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

According to this IDEA bugafter workaround idea works again:

根据此 IDEA 错误,解决方法的想法再次起作用:

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

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

enter image description here

在此处输入图片说明

回答by velocity

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

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

module's bytecode version setting

模块的字节码版本设置

回答by dev_in_progress

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

就我而言,它是响应类型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
);