Skip to content

Commit

Permalink
Fix reduced classpath logic on Windows
Browse files Browse the repository at this point in the history
The reduced classpath computation for Java compilation actions with deps on jdeps files that were produced on Windows always resulted in an empty reduced classpath since both JavaBuilder and Turbine emitted backslash-separated paths into the jdeps proto, but Bazel matches them against slash-separated paths.

This is fixed by changing JavaBuilder to always emit slash-separated paths and updating Turbine to a version that does so (google/turbine#363).

Work towards #24876, which will also provide an integration test.

Closes #25435.

PiperOrigin-RevId: 733284003
Change-Id: Ide29965d4676fdd2bda4baaced50f984ee7284f0
  • Loading branch information
fmeum authored and copybara-github committed Mar 4, 2025
1 parent 23d03e1 commit 752f72b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ maven.install(
"com.google.guava:guava:33.2.1-jre",
"com.google.http-client:google-http-client:1.42.0",
"com.google.http-client:google-http-client-gson:1.42.0",
"com.google.turbine:turbine:0.9.0",
"com.google.turbine:turbine:0.10.0",
"com.guardsquare:proguard-base:jar:7.5.0",
"com.ryanharter.auto.value:auto-value-gson-extension:1.3.1",
"com.ryanharter.auto.value:auto-value-gson-factory:1.3.1",
Expand Down
8 changes: 4 additions & 4 deletions maven_install.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": -1286571909,
"__RESOLVED_ARTIFACTS_HASH": -1337990705,
"__INPUT_ARTIFACTS_HASH": 895488469,
"__RESOLVED_ARTIFACTS_HASH": 1286537252,
"conflict_resolution": {
"com.google.api.grpc:proto-google-common-protos:2.29.0": "com.google.api.grpc:proto-google-common-protos:2.41.0",
"com.google.auth:google-auth-library-credentials:1.6.0": "com.google.auth:google-auth-library-credentials:1.23.0",
Expand Down Expand Up @@ -374,9 +374,9 @@
},
"com.google.turbine:turbine": {
"shasums": {
"jar": "ab3c28db3ae19b0de6bcd792da60a9d02abaaaabd24f44bfa5423cf1261bcd6f"
"jar": "da5351307c2fe3fee713b278c0dccd5e9e6301b79bf211fcb6ef28b8440ab1f9"
},
"version": "0.9.0"
"version": "0.10.0"
},
"com.guardsquare:proguard-base": {
"shasums": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.sun.tools.javac.util.Log.WriterKind;
import com.sun.tools.javac.util.Name;
import com.sun.tools.javac.util.Names;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
Expand Down Expand Up @@ -337,13 +338,11 @@ private void collectExplicitDependency(NonPlatformJar jar, JCTree node, Symbol s
// Also update the dependency proto
Dependency dep =
Dependency.newBuilder()
// Path.toString uses the platform separator (`\` on Windows) which may not
// match the format in params files (which currently always use `/`, see
// bazelbuild/bazel#4108). JavaBuilder should always parse Path strings into
// java.nio.file.Paths before comparing them.
// Path.toString uses the platform separator (`\` on Windows), but the proto must
// use the same separator as in the arguments.
//
// An empty path is OK in the cases we produce it. See readJarOwnerFromManifest.
.setPath(jar.pathOrEmpty().toString())
.setPath(jar.pathOrEmpty().toString().replace(File.separatorChar, '/'))
.setKind(Dependency.Kind.EXPLICIT)
.build();
directDependenciesMap.put(jar.pathOrEmpty(), dep);
Expand Down

0 comments on commit 752f72b

Please sign in to comment.