Repository: bazelbuild/bazel
Issue: bazel coverage crashes, likely due to old jacoco
Labels: P1
team-Rules-Java

### Description of the problem / feature request:
### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

`bazel coverage //projects/batfish-common-protocol/...` crashes in https://github.com/batfish/batfish/

The stack trace includes the following

```
91) testGetPartialMatchesSpecifierComplete(org.batfish.specifier.parboiled.ParserUtilsTest)
java.lang.IllegalAccessError: tried to access method org.batfish.specifier.parboiled.CommonParser.$jacocoInit()[Z from class org.batfish.specifier.parboiled.TestParser$$parboiled
	at org.batfish.specifier.parboiled.TestParser$$parboiled.input(Unknown Source)
	at org.batfish.specifier.parboiled.ParserUtilsTest.getRunner(ParserUtilsTest.java:25)
	at org.batfish.specifier.parboiled.ParserUtilsTest.testGetPartialMatchesSpecifierComplete(ParserUtilsTest.java:132)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
```

which it looks like has been fixed by jacoco 0.7.8.

### What operating system are you running Bazel on?

macOS 10.14.3

### What's the output of `bazel info release`?

development version

### If `bazel info release` returns "development version" or "(@non-git)", tell us how you built Bazel.

built from bazel head using `bazel build //src:bazel && cp -f bazel-bin/src/bazel`

### What's the output of `git remote get-url origin ; git rev-parse master ; git rev-parse HEAD` ?

```
git@github.com:bazelbuild/bazel.git
2a1d99076eb46510484bd0bcbee0c607c03d4943
2a1d99076eb46510484bd0bcbee0c607c03d4943
```

###  Have you found anything relevant by searching the web?

Yes.

* JaCoCo reports having fixed this issue in the 0.7.8 release notes. https://github.com/jacoco/jacoco/releases/tag/v0.7.8

* I also came across this related Bazel issue filed by Android team:  https://github.com/bazelbuild/bazel/issues/3471

    But that issue was apparently triaged in such a way that it was decided coverage/bazel were unimplicated and instead Android team should apply a workaround. I saw no discussion of whether Bazel can upgrade or why/why not, so I'm hoping there will be new discussion here.

    As it's a third-party library causing the issue in our case, we're not able to apply the same workaround.

cc: @iirina 

Issue comments:
I notice that Bazel already uses ASM 7.0, which is the main dep of jacoco. Maybe upgrading wouldn't be a huge yak shave?
I've tried modifying Bazel to upgrade the jar myself, locally, but there's one jar I can't figure out how it was created: https://github.com/bazelbuild/bazel/tree/master/third_party/java/jacoco , `jacocoagent.jar`. It was checked in with the rest, but does not seem to correspond to any of the rest.
Any update? I'd like to get coverage working, its one of the key blockers to switching.
Thanks for the report, @dhalperi. I'm running into the same problem. I believe this completely breaks `bazel coverage` when used with jdk9+ due to https://github.com/jacoco/jacoco/pull/434.
I'll try to update tomorrow to jacoco 0.8.3.
Thank you @iirina !

Is this still a recommended command to look at the code coverage output?

```
bazel coverage //... \
--combined_report=lcov --test_keep_going \
--coverage_report_generator=@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main \
&& genhtml -o coverage bazel-out/_coverage/_coverage_report.dat && open coverage/index.html
```

(Still getting a ton of crashes, but elsewhere.)
@dhalperi Yes, that's right. Can you please open new issues for the other crashes? Thanks!
@iirina - will open other issues, if they are in Bazel. May well be in other libraries not working with java11 now. Just making sure I'm on good footing. Thanks again!

Pull request review comments:

Patch that resolved the issue:
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/BUILD b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/BUILD
index 2abd4be4544179..c1c859445a04d6 100644
--- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/BUILD
+++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/BUILD
@@ -86,7 +86,7 @@ java_library(
         "//src/main/protobuf:worker_protocol_java_proto",
         "//third_party:guava",
         "//third_party:jsr305",
-        "//third_party/java/jacoco:core",
+        "//third_party/java/jacoco:core-0.8.3",
         "//third_party/java/jdk/langtools:javac",
     ],
 )
@@ -158,7 +158,7 @@ bootstrap_java_library(
         "//third_party:bootstrap_guava_and_error_prone-jars",
         "//third_party:jsr305-jars",
         "//third_party/protobuf:protobuf-jars",
-        "//third_party/java/jacoco:core-jars",
+        "//third_party/java/jacoco:core-jars-0.8.3",
         "//third_party/grpc:bootstrap-grpc-jars",
         "//third_party:tomcat_annotations_api-jars",
     ],


Test patch:
diff --git a/src/java_tools/junitrunner/java/com/google/testing/coverage/BUILD b/src/java_tools/junitrunner/java/com/google/testing/coverage/BUILD
index 3be31af97b56e0..1a39e31d735ac1 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/coverage/BUILD
+++ b/src/java_tools/junitrunner/java/com/google/testing/coverage/BUILD
@@ -29,9 +29,9 @@ java_binary(
     deps = [
         ":bitfield",
         "//third_party:guava",
-        "//third_party/java/jacoco:blaze-agent",
-        "//third_party/java/jacoco:core",
-        "//third_party/java/jacoco:report",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
+        "//third_party/java/jacoco:core-0.8.3",
+        "//third_party/java/jacoco:report-0.8.3",
     ],
 )
 
diff --git a/src/java_tools/junitrunner/java/com/google/testing/coverage/BranchDetailAnalyzer.java b/src/java_tools/junitrunner/java/com/google/testing/coverage/BranchDetailAnalyzer.java
index 7ccd843d3ce96e..6ffb874987c31d 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/coverage/BranchDetailAnalyzer.java
+++ b/src/java_tools/junitrunner/java/com/google/testing/coverage/BranchDetailAnalyzer.java
@@ -52,7 +52,7 @@ public void visitCoverage(IClassCoverage coverage) {
   public void analyzeClass(final ClassReader reader) {
     final Map<Integer, BranchExp> lineToBranchExp = mapProbes(reader);
 
-    long classid = CRC64.checksum(reader.b);
+    long classid = CRC64.classId(reader.b);
     ExecutionData classData = executionData.get(classid);
     if (classData == null) {
       return;
diff --git a/src/java_tools/junitrunner/java/com/google/testing/coverage/MethodProbesMapper.java b/src/java_tools/junitrunner/java/com/google/testing/coverage/MethodProbesMapper.java
index 6900a37f71e416..f025ed127f09f2 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/coverage/MethodProbesMapper.java
+++ b/src/java_tools/junitrunner/java/com/google/testing/coverage/MethodProbesMapper.java
@@ -19,8 +19,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+import org.jacoco.core.internal.analysis.Instruction;
 import org.jacoco.core.internal.flow.IFrame;
-import org.jacoco.core.internal.flow.Instruction;
 import org.jacoco.core.internal.flow.LabelInfo;
 import org.jacoco.core.internal.flow.MethodProbesVisitor;
 import org.objectweb.asm.Handle;
@@ -60,7 +60,6 @@ public class MethodProbesMapper extends MethodProbesVisitor {
 
   // Result
   private Map<Integer, BranchExp> lineToBranchExp = new TreeMap();
-
   public Map<Integer, BranchExp> result() {
     return lineToBranchExp;
   }
@@ -93,7 +92,7 @@ private void visitInsn() {
     Instruction instruction = new Instruction(currentLine);
     instructions.add(instruction);
     if (lastInstruction != null) {
-      instruction.setPredecessor(lastInstruction); // Update branch of lastInstruction
+      lastInstruction.addBranch(instruction, 0); // the first branch from last instruction
       predecessors.put(instruction, lastInstruction); // Update local cache
     }
 
@@ -131,12 +130,14 @@ public void visitFieldInsn(int opcode, String owner, String name, String desc) {
   }
 
   @Override
-  public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
+  public void visitMethodInsn(int opcode, String owner, String name,
+      String desc, boolean itf) {
     visitInsn();
   }
 
   @Override
-  public void visitInvokeDynamicInsn(String name, String desc, Handle handle, Object... args) {
+  public void visitInvokeDynamicInsn(String name, String desc, Handle handle,
+      Object... args) {
     visitInsn();
   }
 
@@ -155,11 +156,12 @@ public void visitMultiANewArrayInsn(String desc, int dims) {
     visitInsn();
   }
 
+
   // Methods that need to update the states
   @Override
   public void visitJumpInsn(int opcode, Label label) {
     visitInsn();
-    jumps.add(new Jump(lastInstruction, label));
+    jumps.add(new Jump(lastInstruction, label, 1));
   }
 
   @Override
@@ -181,14 +183,15 @@ private void visitSwitchInsn(Label dflt, Label[] labels) {
 
     // Handle default transition
     LabelInfo.resetDone(dflt);
-    jumps.add(new Jump(lastInstruction, dflt));
+    int branch = 0;
+    jumps.add(new Jump(lastInstruction, dflt, branch));
     LabelInfo.setDone(dflt);
 
     // Handle other transitions
     LabelInfo.resetDone(labels);
     for (Label label : labels) {
       if (!LabelInfo.isDone(label)) {
-        jumps.add(new Jump(lastInstruction, label));
+        jumps.add(new Jump(lastInstruction, label, branch));
         LabelInfo.setDone(label);
       }
     }
@@ -207,7 +210,7 @@ public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
   private void addProbe(int probeId) {
     // We do not add probes to the flow graph, but we need to update
     // the branch count of the predecessor of the probe
-    lastInstruction.addBranch();
+    lastInstruction.addBranch(false, 0);
     probeToInsn.put(probeId, lastInstruction);
   }
 
@@ -217,7 +220,7 @@ public void visitProbe(int probeId) {
     // This function is only called when visiting a merge node which
     // is a successor.
     // It adds an probe point to the last instruction
-    assert (lastInstruction != null);
+    assert(lastInstruction != null);
 
     addProbe(probeId);
     lastInstruction = null; // Merge point should have no predecessor.
@@ -236,14 +239,14 @@ public void visitInsnWithProbe(int opcode, int probeId) {
   }
 
   @Override
-  public void visitTableSwitchInsnWithProbes(
-      int min, int max, Label dflt, Label[] labels, IFrame frame) {
+  public void visitTableSwitchInsnWithProbes(int min, int max,
+      Label dflt, Label[] labels, IFrame frame) {
     visitSwitchInsnWithProbes(dflt, labels);
   }
 
   @Override
-  public void visitLookupSwitchInsnWithProbes(
-      Label dflt, int[] keys, Label[] labels, IFrame frame) {
+  public void visitLookupSwitchInsnWithProbes(Label dflt,
+      int[] keys, Label[] labels, IFrame frame) {
     visitSwitchInsnWithProbes(dflt, labels);
   }
 
@@ -251,18 +254,18 @@ private void visitSwitchInsnWithProbes(Label dflt, Label[] labels) {
     visitInsn();
     LabelInfo.resetDone(dflt);
     LabelInfo.resetDone(labels);
-
-    visitTargetWithProbe(dflt);
+    int branch = 0;
+    visitTargetWithProbe(dflt, branch);
     for (Label l : labels) {
-      visitTargetWithProbe(l);
+      visitTargetWithProbe(l, branch);
     }
   }
 
-  private void visitTargetWithProbe(Label label) {
+  private void visitTargetWithProbe(Label label, int branch) {
     if (!LabelInfo.isDone(label)) {
       int id = LabelInfo.getProbeId(label);
       if (id == LabelInfo.NO_PROBE) {
-        jumps.add(new Jump(lastInstruction, label));
+        jumps.add(new Jump(lastInstruction, label, branch));
       } else {
         // Note, in this case the instrumenter should insert intermediate labels
         // for the probes. These probes will be added for the switch instruction.
@@ -276,7 +279,7 @@ private void visitTargetWithProbe(Label label) {
 
   // If a CovExp of pred is ProbeExp, create a single-branch BranchExp and put it in the map.
   // Also update the index of insn.
-  private BranchExp getPredBranchExp(Instruction predecessor, Instruction insn) {
+  private BranchExp getPredBranchExp(Instruction predecessor) {
     BranchExp result = null;
     CovExp exp = insnToCovExp.get(predecessor);
     if (exp instanceof ProbeExp) {
@@ -292,7 +295,8 @@ private BranchExp getPredBranchExp(Instruction predecessor, Instruction insn) {
   }
 
   // Update a branch predecessor and returns whether the BranchExp of the predecessor is new.
-  private boolean updateBranchPredecessor(Instruction predecessor, Instruction insn, CovExp exp) {
+  private boolean updateBranchPredecessor(Instruction predecessor, Instruction insn,
+      CovExp exp) {
     CovExp predExp = insnToCovExp.get(predecessor);
     if (predExp == null) {
       BranchExp branchExp = new BranchExp(exp);
@@ -301,7 +305,7 @@ private boolean updateBranchPredecessor(Instruction predecessor, Instruction ins
       return true;
     }
 
-    BranchExp branchExp = getPredBranchExp(predecessor, insn);
+    BranchExp branchExp = getPredBranchExp(predecessor);
     Integer branchIdx = insnToIdx.get(insn);
     if (branchIdx == null) {
       // Keep track of the instructions in the branches that are already added
@@ -319,7 +323,7 @@ public void visitEnd() {
 
     for (Jump jump : jumps) {
       Instruction insn = labelToInsn.get(jump.target);
-      insn.setPredecessor(jump.source);
+      jump.source.addBranch(insn, jump.branch);
       predecessors.put(insn, jump.source);
     }
 
@@ -345,7 +349,7 @@ public void visitEnd() {
           // has a probe, but the branch count is not > 1.
         }
       } else {
-        if (insn.getBranches() > 1) {
+        if (insn.getBranchCounter().getTotalCount() > 1) {
           exp = new BranchExp(exp);
         }
         insnToCovExp.put(insn, exp);
@@ -353,7 +357,7 @@ public void visitEnd() {
 
       Instruction predecessor = predecessors.get(insn);
       while (predecessor != null) {
-        if (predecessor.getBranches() > 1) {
+        if (predecessor.getBranchCounter().getTotalCount() > 1) {
           boolean isNewBranch = updateBranchPredecessor(predecessor, insn, exp);
           if (!isNewBranch) {
             // If the branch already exists, no need to visit predecessors any more.
@@ -371,7 +375,7 @@ public void visitEnd() {
 
     // Merge branches in the instructions on the same line
     for (Instruction insn : instructions) {
-      if (insn.getBranches() > 1) {
+      if (insn.getBranchCounter().getTotalCount() > 1) {
         CovExp insnExp = insnToCovExp.get(insn);
         if (insnExp != null && (insnExp instanceof BranchExp)) {
           BranchExp exp = (BranchExp) insnExp;
@@ -390,14 +394,18 @@ public void visitEnd() {
     }
   }
 
-  /** Jumps between instructions and labels */
+  /**
+   * Jumps between instructions and labels
+   */
   class Jump {
     public final Instruction source;
     public final Label target;
+    public final int branch;
 
-    public Jump(Instruction i, Label l) {
+    public Jump(Instruction i, Label l, int b) {
       source = i;
       target = l;
+      branch = b;
     }
   }
-}
+}
\ No newline at end of file
diff --git a/src/test/java/com/google/devtools/build/android/desugar/BUILD b/src/test/java/com/google/devtools/build/android/desugar/BUILD
index 4780ad39155499..1812ef52748abe 100644
--- a/src/test/java/com/google/devtools/build/android/desugar/BUILD
+++ b/src/test/java/com/google/devtools/build/android/desugar/BUILD
@@ -329,7 +329,7 @@ java_test(
     jvm_flags = [
         # TODO (b/72181101): -Xbootclasspath/p is removed in JDK 9.
         "-XX:+IgnoreUnrecognizedVMOptions",
-        "-Xbootclasspath/a:$(location :testdata_desugared_core_library):$(location //third_party/java/jacoco:blaze-agent)",
+        "-Xbootclasspath/a:$(location :testdata_desugared_core_library):$(location //third_party/java/jacoco:blaze-agent-0.8.3)",
         "--patch-module=java.base=$(location :testdata_desugared_core_library)",
     ],
     tags = ["no_windows"],
@@ -341,7 +341,7 @@ java_test(
         "//third_party:truth",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
     ],
 )
 
@@ -351,7 +351,7 @@ java_test(
     srcs = [
         "StackMapBugTest.java",
     ],
-    jvm_flags = ["-Xbootclasspath/a:$(location //third_party/java/jacoco:blaze-agent)"],
+    jvm_flags = ["-Xbootclasspath/a:$(location //third_party/java/jacoco:blaze-agent-0.8.3)"],
     tags = ["no_windows"],
     deps = [
         ":testdata_desugared_core_library",  # Make tests run against desugared library
@@ -360,7 +360,7 @@ java_test(
         "//third_party:truth",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
     ],
 )
 
@@ -376,7 +376,7 @@ java_test(
     ],
     jvm_flags = [
         "-DDefaultMethodClassFixerTest.bootclasspath=$(location :android_jar_for_testing)",
-        "-DDefaultMethodClassFixerTest.classpath=$(location :separate):$(location //third_party:guava-jars):$(location //third_party/java/jacoco:blaze-agent)",
+        "-DDefaultMethodClassFixerTest.classpath=$(location :separate):$(location //third_party:guava-jars):$(location //third_party/java/jacoco:blaze-agent-0.8.3)",
         "-DDefaultMethodClassFixerTest.input=$(location :testdata_java8)",
     ],
     tags = ["no_windows"],
@@ -389,7 +389,7 @@ java_test(
         "//third_party:guava",
         "//third_party:junit4",
         "//third_party:truth",
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
     ],
 )
 
@@ -821,7 +821,7 @@ genrule(
         ":testdata",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared.jar"],
@@ -829,7 +829,7 @@ genrule(
           "--nodesugar_interface_method_bodies_if_needed -i $(location :testdata) -o $@ " +
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -850,13 +850,13 @@ genrule(
     srcs = [
         ":generate_lambda_with_constant_arguments_in_test_data",
         # Depend on Jacoco runtime in case testdata was built with coverage instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugar_generate_lambda_with_constant_arguments.jar"],
     cmd = "$(location //src/tools/android/java/com/google/devtools/build/android/desugar:Desugar) " +
           "-i $(location :generate_lambda_with_constant_arguments_in_test_data) -o $@ " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -889,7 +889,7 @@ genrule(
         ":separate",
         ":generate_synthetic_methods_with_lambda_names_in_test_data",
         # Depend on Jacoco runtime in case testdata was built with coverage instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_with_synthetic_methods_with_lambda_names.jar"],
@@ -897,7 +897,7 @@ genrule(
           "--nodesugar_interface_method_bodies_if_needed -i $(location :generate_synthetic_methods_with_lambda_names_in_test_data) -o $@ " +
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -911,7 +911,7 @@ genrule(
         ":testdata_desugared.jar",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_twice.jar"],
@@ -919,7 +919,7 @@ genrule(
           "--nodesugar_interface_method_bodies_if_needed -i $(location :testdata_desugared.jar) -o $@ " +
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -936,7 +936,7 @@ genrule(
         ":testdata",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_without_lambda_desugared.jar"],
@@ -945,7 +945,7 @@ genrule(
           "--nodesugar_try_with_resources_if_needed " +
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar) " +
           "--only_desugar_javac9_for_lint",
     tags = ["no_windows"],
@@ -1112,7 +1112,7 @@ genrule(
         ":testdata_java8",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_java8.jar"],
@@ -1122,7 +1122,7 @@ genrule(
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location :separate_java8) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1137,7 +1137,7 @@ genrule(
         ":testdata_java8_like_in_android_studio",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_java8_like_in_android_studio.jar"],
@@ -1149,7 +1149,7 @@ genrule(
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location :separate_java8) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1164,7 +1164,7 @@ genrule(
         ":testdata_java8",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_default_methods.jar"],
@@ -1174,7 +1174,7 @@ genrule(
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location :separate_java8) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1186,14 +1186,14 @@ genrule(
         ":separate_java8",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["separate_java8_desugared_default_methods.jar"],
     cmd = "$(location //src/tools/android/java/com/google/devtools/build/android/desugar:Desugar) " +
           "-i $(location :separate_java8) -o $@ " +
           "--emit_dependency_metadata_as_needed " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1208,7 +1208,7 @@ genrule(
         ":testdata_java8",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_default_methods.output.txt"],
@@ -1218,7 +1218,7 @@ genrule(
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location :separate_java8) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar) " +
           " &> $@",
     tags = ["no_windows"],
@@ -1234,7 +1234,7 @@ genrule(
         ":testdata_desugared_default_methods.jar",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_default_methods_twice.jar"],
@@ -1243,7 +1243,7 @@ genrule(
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location :separate_java8) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1255,13 +1255,13 @@ genrule(
         ":testdata_core_library",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_core_library.jar"],
     cmd = "$(location //src/tools/android/java/com/google/devtools/build/android/desugar:Desugar) " +
           "--core_library -i $(location :testdata_core_library) -o $@ " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1275,7 +1275,7 @@ genrule(
         ":testdata_like_in_android_studio",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_like_in_android_studio.jar"],
@@ -1287,7 +1287,7 @@ genrule(
           "--copy_bridges_from_classpath " +
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1301,7 +1301,7 @@ genrule(
         ":testdata_like_in_android_studio",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = [
@@ -1315,7 +1315,7 @@ genrule(
           "--copy_bridges_from_classpath " +
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1329,7 +1329,7 @@ genrule(
         ":testdata_like_in_android_studio",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = [
@@ -1346,7 +1346,7 @@ genrule(
           --copy_bridges_from_classpath \
           --classpath_entry $(location :separate) \
           --classpath_entry $(location //third_party:guava-jars) \
-          --classpath_entry $(location //third_party/java/jacoco:blaze-agent) \
+          --classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) \
           --bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)
      rm -rf $$tmpdir
     """,
@@ -1365,7 +1365,7 @@ genrule(
         ":testdata_like_in_android_studio",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = [
@@ -1383,7 +1383,7 @@ genrule(
           --copy_bridges_from_classpath \
           --classpath_entry $(location :separate) \
           --classpath_entry $(location //third_party:guava-jars) \
-          --classpath_entry $(location //third_party/java/jacoco:blaze-agent) \
+          --classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) \
           --bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)
      pushd $$tmpdirOut
      $$pwddir/$(location //tools/zip:zipper) c $$pwddir/$(location testdata_desugared_from_directory_to_directory.jar) $$(find *)
@@ -1406,7 +1406,7 @@ genrule(
         ":testdata_like_in_android_studio",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = [
@@ -1423,7 +1423,7 @@ genrule(
           --copy_bridges_from_classpath \
           --classpath_entry $$tmpdir \
           --classpath_entry $(location //third_party:guava-jars) \
-          --classpath_entry $(location //third_party/java/jacoco:blaze-agent) \
+          --classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) \
           --bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)
      rm -rf $$tmpdir
     """,
@@ -1444,7 +1444,7 @@ genrule(
         ":testdata",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_for_try_with_resources.jar"],
@@ -1453,7 +1453,7 @@ genrule(
           "--min_sdk_version 17 --desugar_try_with_resources_if_needed " +
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1466,7 +1466,7 @@ genrule(
     name = "desugar_default_method_with_legacy_coverage",
     srcs = [
         "jacoco_0_7_5_default_method.jar",
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["jacoco_0_7_5_default_method_desugared.jar"],
@@ -1475,7 +1475,7 @@ genrule(
           "--legacy_jacoco_fix " +
           "--min_sdk_version 19 " +
           "-i $(location :jacoco_0_7_5_default_method.jar) -o $@ " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1490,7 +1490,7 @@ genrule(
         ":testdata",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_for_NO_desugaring_try_with_resources.jar"],
@@ -1499,7 +1499,7 @@ genrule(
           "--min_sdk_version 19 --desugar_try_with_resources_if_needed " +
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1513,7 +1513,7 @@ genrule(
         ":desugar_testdata_by_desugaring_try_with_resources",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_for_try_with_resources_twice.jar"],
@@ -1522,7 +1522,7 @@ genrule(
           "--min_sdk_version 17 --desugar_try_with_resources_if_needed " +
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1821,13 +1821,13 @@ genrule(
         ":capture_lambda",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["capture_lambda_desugared.jar"],
     cmd = "$(location //src/tools/android/java/com/google/devtools/build/android/desugar:Desugar) " +
           "-i $(location :capture_lambda) -o $@ " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -1839,13 +1839,13 @@ genrule(
         ":capture_lambda_desugared.jar",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["capture_lambda_desugared_twice.jar"],
     cmd = "$(location //src/tools/android/java/com/google/devtools/build/android/desugar:Desugar) " +
           "-i $(location :capture_lambda_desugared.jar) -o $@ " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tags = ["no_windows"],
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
@@ -2008,7 +2008,7 @@ genrule(
         ":separate",
         ":testdata_java8",
         "//third_party:guava-jars",
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["testdata_desugared_with_missing_dep.jar"],
@@ -2017,7 +2017,7 @@ genrule(
           "--emit_dependency_metadata_as_needed " +
           "--classpath_entry $(location :separate) " +
           "--classpath_entry $(location //third_party:guava-jars) " +
-          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent) " +
+          "--classpath_entry $(location //third_party/java/jacoco:blaze-agent-0.8.3) " +
           "--bootclasspath_entry $(location @bazel_tools//tools/android:android_jar)",
     tools = ["//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar"],
 )
@@ -2027,7 +2027,7 @@ genrule(
     srcs = [
         ":b68049457_caller",
         ":b68049457_interface",
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["b68049457_caller_desugared.jar"],
@@ -2096,7 +2096,7 @@ genrule(
         "//third_party:guava-jars",
         # Depend on Jacoco runtime in case testdata was built with coverage
         # instrumentation
-        "//third_party/java/jacoco:blaze-agent",
+        "//third_party/java/jacoco:blaze-agent-0.8.3",
         "@bazel_tools//tools/android:android_jar",
     ],
     outs = ["guava_at_head_desugared.jar"],