summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoogler <noreply@google.com>2017-03-10 09:42:49 +0000
committerColin Cross <ccross@android.com>2017-03-13 17:21:01 -0700
commit3aa5e88028c7d2cc5fe3cc916d356eafd0cb3482 (patch)
treea69da7e4fc2da3965d2f21016aae45a6ff1af59a
parent035127d06ffbb1df5f888cc7014440b705e5b9a6 (diff)
downloaddesugar-3aa5e88028c7d2cc5fe3cc916d356eafd0cb3482.tar.gz
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 GitOrigin-RevId: 25df9e962012eb6ac8bf01a031ddf2c257f5cce5 Change-Id: Icf920cf348843403b167a9adfc1fe2f10ac35c57
-rw-r--r--java/com/google/devtools/build/android/desugar/LambdaClassMaker.java18
1 files changed, 8 insertions, 10 deletions
diff --git a/java/com/google/devtools/build/android/desugar/LambdaClassMaker.java b/java/com/google/devtools/build/android/desugar/LambdaClassMaker.java
index ef87407..d8f2e28 100644
--- a/java/com/google/devtools/build/android/desugar/LambdaClassMaker.java
+++ b/java/com/google/devtools/build/android/desugar/LambdaClassMaker.java
@@ -24,7 +24,6 @@ import java.nio.file.Path;
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 @@ class LambdaClassMaker {
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);
}
})) {