aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2017-05-23 14:56:51 +0200
committerGravatar Irina Iancu <elenairina@google.com>2017-05-23 17:39:55 +0200
commit6bb44ec649fe91dd1a3e33e02edfb3caf6d4b7e8 (patch)
tree36e2c67a5b55df68bd2113e98b471cc4683186b8 /src/tools/android/java/com/google/devtools
parent7f520a8286c39c5145b6d816cd0be5a6b7b18250 (diff)
Make Desugar work for relative dumpDirectory paths.
Before CL 155913466, Desugar was not working when dumpDirectory was a relative path because of an extra/incorrect resolve() that ended up duplicating such a relative path. CL 155913466 fixed this by converting Desugar's dumpDirectory to an absolute path. However, CL 156257767 introduced a check that Desugar's dumpDirectory must match the one in Java's InnerClassLambdaMetafactory, which broke the case of a relative path again. Therefore, this CL undoes the conversion to absolute path again (so that Desugar's path matches that in InnerClassLambdaMetafactory). Instead, to make relative paths work, it drops the unnecessary/incorrect call to resolve(). A regression test is left for a future CL (I don't have a dev environment set up that would allow me to easily write one). RELNOTES: None. PiperOrigin-RevId: 156852882
Diffstat (limited to 'src/tools/android/java/com/google/devtools')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/desugar/Desugar.java7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar.java b/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar.java
index 3d6e6c6dec..43f9aace64 100644
--- a/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar.java
+++ b/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar.java
@@ -203,7 +203,6 @@ class Desugar {
}
private final Options options;
- private final Path dumpDirectory;
private final CoreLibraryRewriter rewriter;
private final LambdaClassMaker lambdas;
private final GeneratedClassStore store;
@@ -219,7 +218,6 @@ class Desugar {
private Desugar(Options options, Path dumpDirectory) {
this.options = options;
- this.dumpDirectory = dumpDirectory;
this.rewriter = new CoreLibraryRewriter(options.coreLibrary ? "__desugar__/" : "");
this.lambdas = new LambdaClassMaker(dumpDirectory);
this.store = new GeneratedClassStore();
@@ -399,8 +397,7 @@ class Desugar {
lambdaClasses.keySet());
for (Map.Entry<Path, LambdaInfo> lambdaClass : lambdaClasses.entrySet()) {
- try (InputStream bytecode =
- Files.newInputStream(dumpDirectory.resolve(lambdaClass.getKey()))) {
+ try (InputStream bytecode = Files.newInputStream(lambdaClass.getKey())) {
ClassReader reader = rewriter.reader(bytecode);
UnprefixingClassWriter writer =
rewriter.writer(ClassWriter.COMPUTE_MAXS /*for invoking bridges*/);
@@ -577,7 +574,7 @@ class Desugar {
static Path createAndRegisterLambdaDumpDirectory() throws IOException {
String propertyValue = System.getProperty(LAMBDA_METAFACTORY_DUMPER_PROPERTY);
if (propertyValue != null) {
- Path path = Paths.get(propertyValue).toAbsolutePath();
+ Path path = Paths.get(propertyValue);
checkState(Files.isDirectory(path), "The path '%s' is not a directory.", path);
// It is not necessary to check whether 'path' is an empty directory. It is possible that
// LambdaMetafactory is loaded before this class, and there are already lambda classes dumped