google-java-format icon indicating copy to clipboard operation
google-java-format copied to clipboard

IntelliJ fails to build GJF due to ErrorProne+Java8

Open cgrushko opened this issue 6 years ago • 6 comments

Repro:

  1. Load the pom.xml file in IntelliJ
  2. Attempt to run tests inside IntelliJ

Observe:

Information:java: An exception has occurred in the compiler (1.8.0_181). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
Information:java:   at com.sun.tools.javac.main.Main.compile(Main.java:473)
Information:java:   at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
Information:java:   at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
Information:java:   at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:190)
Information:java:   at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:459)
Information:java:   at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:329)
Information:java:   at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:254)
Information:java:   at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:212)
Information:java:   at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1328)
Information:java:   at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1008)
Information:java:   at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1075)
Information:java:   at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:969)
Information:java:   at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:798)
Information:java:   at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:380)
Information:java:   at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:178)
Information:java:   at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:139)
Information:java:   at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)
Information:java:   at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:135)
Information:java:   at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:228)
Information:java:   at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
Information:java:   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
Information:java:   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
Information:java:   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
Information:java:   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
Information:java:   at java.lang.Thread.run(Thread.java:748)
Information:java:   at com.sun.tools.javac.main.Main.compile(Main.java:470)
Information:java:   ... 24 more
Information:java: Errors occurred while compiling module 'google-java-format'
Information:javac 1.8.0_181 was used to compile java sources
Information:2019-11-12 12:08 - Build completed with 4 errors and 1 warning in 2 s 838 ms
Error:java: java.lang.RuntimeException: java.lang.NoSuchMethodError: com.sun.tools.javac.util.JavacMessages.add(Lcom/sun/tools/javac/util/JavacMessages$ResourceBundleHelper;)V
Error:java: Caused by: java.lang.NoSuchMethodError: com.sun.tools.javac.util.JavacMessages.add(Lcom/sun/tools/javac/util/JavacMessages$ResourceBundleHelper;)V
Error:java:     at com.google.errorprone.BaseErrorProneJavaCompiler.setupMessageBundle(BaseErrorProneJavaCompiler.java:202)
Error:java:     at com.google.errorprone.ErrorProneJavacPlugin.init(ErrorProneJavacPlugin.java:40)

System information:

image

Things to note -

  1. mvn install succeeds in building GJF.
  2. The IntelliJ project was created from pom.xml

Workaround -

  1. The problem goes away if I remove the compiler parameters in IntelliJ (bottom of Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler)

cgrushko avatar Nov 12 '19 10:11 cgrushko

It looks like this configuration isn't getting pick up: https://github.com/google/google-java-format/blob/bd176704e73771d1dd582d2cd0ae2f8859ae9ca6/pom.xml#L267

The easiest work-around might be to run on JDK 11.

cushon avatar Nov 14 '19 00:11 cushon

Would it work with IntelliJ's ErrorProne plugin?

tbroyer avatar Nov 14 '19 07:11 tbroyer

I think it might; I think I had it installed at some point and then the problem went away. Still, that's another complication, especially if I want to use GJF as a library.

On Wed, Nov 13, 2019 at 11:01 PM Thomas Broyer [email protected] wrote:

Would it work with IntelliJ's ErrorProne plugin?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/google/google-java-format/issues/417?email_source=notifications&email_token=AAPH6YK5NGBZN3322DPKJKDQTTZWLA5CNFSM4JMBKC22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEAZ5HQ#issuecomment-553754270, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPH6YITQQBCBRZS5BE6CTDQTTZWLANCNFSM4JMBKC2Q .

cgrushko avatar Nov 14 '19 08:11 cgrushko

You could also try manually activating the jdk8 maven profile in IntelliJ (https://www.jetbrains.com/help/idea/work-with-maven-profiles.html#activate_maven_profiles).

cushon avatar Nov 20 '19 22:11 cushon

Did enabling the jdk8 profile make a difference?

cushon avatar Dec 19 '19 01:12 cushon

Enabling the jdk8 profile didn't help, the error remains (the profile was enabled by default for me) (Sorry for the delay)

cgrushko avatar Dec 23 '19 14:12 cgrushko