Skip to content

Commit c266651

Browse files
fmeumcopybara-github
authored andcommitted
Fix Java coverage collection with Java 8 runtime
`JacocoCoverageRunner` is run with the target runtime, not the exec runtime, and thus needs to be compatible with a Java 8 runtime. Fixes bazelbuild#17165 Closes bazelbuild#17338. PiperOrigin-RevId: 509123073 Change-Id: I41d7255e1f3c3dd3864082899d5dc9ab2cc82027
1 parent 7227fd4 commit c266651

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

src/java_tools/junitrunner/java/com/google/testing/coverage/JacocoLCOVFormatter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public IReportVisitor createVisitor(
7070
private Map<String, ISourceFileCoverage> sourceToFileCoverage = new TreeMap<>();
7171

7272
private String getExecPathForEntryName(String classPath) {
73-
if (execPathsOfUninstrumentedFiles.isEmpty()) {
73+
if (!execPathsOfUninstrumentedFiles.isPresent()) {
7474
return classPath;
7575
}
7676

src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java

-2
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,6 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime
281281
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
282282
.add(
283283
attr("jacocorunner", LABEL)
284-
// This needs to be in the execution configuration.
285-
.cfg(ExecutionTransitionFactory.create())
286284
.allowedFileTypes(FileTypeSet.ANY_FILE)
287285
.exec())
288286
/* <!-- #BLAZE_RULE(java_toolchain).ATTRIBUTE(proguard_allowlister) -->

0 commit comments

Comments
 (0)