Skip to content

Commit

Permalink
[Coverage] Fix coverage for large targets
Browse files Browse the repository at this point in the history
When a classpath is very large, Bazel will create a manifest jar with
the classpath as an entry in the manifest.

To get the sources for coverage, Bazel checks whether it needs to
reverse the process to find the classpath. However, part of this logic
checks whether the manfiest jar is the only jar on the classpath
(urls.length == 1). This is not true in our case - there are two jars on
the classpath, with the first being the manifest jar.

In this commit, we update the logic to check whether the first jar on
the classpath is a manfiest jar by looking for the suffix on the jar.
This allows Bazel to properly reverse the process when the classpath is
large, meaning sources are found, and coverage is properly found again.
  • Loading branch information
ckilian867 committed Feb 8, 2024
1 parent d891f4b commit 701f15e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private static URL[] getUrls(ClassLoader classLoader, boolean wasWrappedJar) {
// If the classpath was too long then a temporary top-level jar is created containing nothing
// but a manifest with
// the original classpath. Those are the URLs we are looking for.
if (wasWrappedJar && urls != null && urls.length == 1) {
if (wasWrappedJar && urls != null && (urls.length == 1 || urls[0].toString().endsWith("-classpath.jar"))) {
try {
String jarClassPath =
new JarInputStream(urls[0].openStream())
Expand Down

0 comments on commit 701f15e

Please sign in to comment.