From bdf23de8eae428e6321c025de22f262110248bce Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Thu, 26 Jan 2023 18:24:44 +0100 Subject: [PATCH] Fix Java coverage collection with Java 8 runtime `JacocoRunner` is run with the target runtime, not the exec runtime, and thus needs to be compatible with a Java 8 runtime. --- .../java/com/google/testing/coverage/JacocoLCOVFormatter.java | 2 +- .../google/devtools/build/lib/rules/java/JavaToolchainRule.java | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/java_tools/junitrunner/java/com/google/testing/coverage/JacocoLCOVFormatter.java b/src/java_tools/junitrunner/java/com/google/testing/coverage/JacocoLCOVFormatter.java index b2c2bc58c31de6..53e62cdf3fe7f7 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/coverage/JacocoLCOVFormatter.java +++ b/src/java_tools/junitrunner/java/com/google/testing/coverage/JacocoLCOVFormatter.java @@ -70,7 +70,7 @@ public IReportVisitor createVisitor( private Map sourceToFileCoverage = new TreeMap<>(); private String getExecPathForEntryName(String classPath) { - if (execPathsOfUninstrumentedFiles.isEmpty()) { + if (!execPathsOfUninstrumentedFiles.isPresent()) { return classPath; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java index 0647eb38da2694..67962dfc001ddb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaToolchainRule.java @@ -281,8 +281,6 @@ The Java target version (e.g., '6' or '7'). It specifies for which Java runtime */ .add( attr("jacocorunner", LABEL) - // This needs to be in the execution configuration. - .cfg(ExecutionTransitionFactory.create()) .allowedFileTypes(FileTypeSet.ANY_FILE) .exec()) /*