Change how desugar finds desugared classes to have it working on Windows
RELNOTES: Change how desugar finds desugared classes to have it working on Windows
--
PiperOrigin-RevId: 149738279
MOS_MIGRATED_REVID=149738279
diff --git a/src/tools/android/java/com/google/devtools/build/android/desugar/LambdaClassMaker.java b/src/tools/android/java/com/google/devtools/build/android/desugar/LambdaClassMaker.java
index ef87407..d8f2e28 100644
--- a/src/tools/android/java/com/google/devtools/build/android/desugar/LambdaClassMaker.java
+++ b/src/tools/android/java/com/google/devtools/build/android/desugar/LambdaClassMaker.java
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
-import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
@@ -64,23 +63,22 @@
return result;
}
- private Path findOnlyUnprocessed(final String pathPrefix) throws IOException {
+ private Path findOnlyUnprocessed(String pathPrefix) throws IOException {
+ // pathPrefix is an internal class name prefix containing '/', but paths obtained on Windows
+ // will not contain '/' and searches will fail. So, construct an absolute path from the given
+ // string and use its string representation to find the file we need regardless of host
+ // system's file system
+ final String rootPathPrefixStr = rootDirectory.resolve(pathPrefix).toString();
+
// TODO(kmb): Investigate making this faster in the case of many lambdas
// TODO(bazel-team): This could be much nicer with lambdas
try (Stream<Path> results =
Files.walk(rootDirectory)
- .map(
- new Function<Path, Path>() {
- @Override
- public Path apply(Path path) {
- return rootDirectory.relativize(path);
- }
- })
.filter(
new Predicate<Path>() {
@Override
public boolean test(Path path) {
- return path.toString().startsWith(pathPrefix)
+ return path.toString().startsWith(rootPathPrefixStr)
&& !generatedClasses.containsKey(path);
}
})) {