salesforce / bazel-jdt-java-toolchain

Eclipse Java Compiler (ECJ) for Bazel
Apache License 2.0
9 stars 6 forks source link

`MethodTooLargeException` thrown by Jacoco not surfaced as nice error message #30

Closed guw closed 3 months ago

guw commented 3 months ago

The build fails but the error message is not clear. Running with debugging and then running the command manually in the Bazel sandbox unveils the exception. We should catch it and report a more user friendly way.

 external/bazel_jdt_java_toolchain/compiler/export/JdtJavaBuilder_deploy.jar \
 @bazel-out/k8-fastbuild/bin/....jar-0.params \
 @bazel-out/k8-fastbuild/bin/....jar-1.params)

java.io.IOException: Error while instrumenting bazel-out/k8-fastbuild/bin/....class with JaCoCo 0.8.11.202310140853/f33756c.
 at org.jacoco.core.instr.Instrumenter.instrumentError(Instrumenter.java:161)
 at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:111)
 at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:136)
 at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:156)
 at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor$1.visitFile(JacocoInstrumentationProcessor.java:143)
 at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor$1.visitFile(JacocoInstrumentationProcessor.java:115)
 at java.base/java.nio.file.Files.walkFileTree(Files.java:2786)
 at java.base/java.nio.file.Files.walkFileTree(Files.java:2857)
 at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor.instrumentRecursively(JacocoInstrumentationProcessor.java:113)
 at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor.processRequest(JacocoInstrumentationProcessor.java:87)
 at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.buildJar(SimpleJavaLibraryBuilder.java:159)
 at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:128)
 at com.google.devtools.build.buildjar.BazelEcjJavaBuilder.build(BazelEcjJavaBuilder.java:110)
 at com.google.devtools.build.buildjar.BazelEcjJavaBuilder.parseAndBuild(BazelEcjJavaBuilder.java:82)
 at com.google.devtools.build.buildjar.BazelEcjJavaBuilder.main(BazelEcjJavaBuilder.java:70)

Caused by: org.objectweb.asm.MethodTooLargeException: Method too large: ...
 at org.objectweb.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2088)
 at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:512)
 at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:92)
 at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:109)
 ... 13 more
guw commented 3 months ago

Related: https://github.com/bazelbuild/bazel/pull/21559