From c26665102d0d524bb42be8cd205c7b31a22a75c9 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Sun, 12 Feb 2023 21:43:22 -0800 Subject: [PATCH] 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 #17165 Closes #17338. PiperOrigin-RevId: 509123073 Change-Id: I41d7255e1f3c3dd3864082899d5dc9ab2cc82027 --- .../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()) /*