summaryrefslogtreecommitdiff
path: root/java/com/google/devtools/build/android/desugar/Desugar.java
diff options
context:
space:
mode:
authorGoogler <noreply@google.com>2017-04-27 19:40:10 +0200
committerColin Cross <ccross@android.com>2017-04-27 18:57:52 -0700
commita672cfbe2bcd1d768a6123a02f65f57ca6ec42f5 (patch)
tree51e65c7bdaf62af540f28121273e4492af328205 /java/com/google/devtools/build/android/desugar/Desugar.java
parentc5e345ca89228abdcff50024d8728a4e5bf87d44 (diff)
downloaddesugar-a672cfbe2bcd1d768a6123a02f65f57ca6ec42f5.tar.gz
Use system property for lambda dir if set
If system property that triggers writing lambda classes is already set, use that value for the lambda dump directory path. Otherwise, generate a temporary dir path, and set it. RELNOTES: n/a PiperOrigin-RevId: 154440327 GitOrigin-RevId: a50a56cf9cd6c0f7c459b265213669b3a2f7ee5e Change-Id: Ia273792f2f7e89758d962a3dfe051074691c0e59
Diffstat (limited to 'java/com/google/devtools/build/android/desugar/Desugar.java')
-rw-r--r--java/com/google/devtools/build/android/desugar/Desugar.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/java/com/google/devtools/build/android/desugar/Desugar.java b/java/com/google/devtools/build/android/desugar/Desugar.java
index c4528ae..cd6b6ab 100644
--- a/java/com/google/devtools/build/android/desugar/Desugar.java
+++ b/java/com/google/devtools/build/android/desugar/Desugar.java
@@ -522,14 +522,20 @@ class Desugar {
* LambdaClassMaker generates lambda classes for us, but it does so by essentially simulating the
* call to LambdaMetafactory that the JVM would make when encountering an invokedynamic.
* LambdaMetafactory is in the JDK and its implementation has a property to write out ("dump")
- * generated classes, which we take advantage of here. Set property before doing anything else
- * since the property is read in the static initializer; if this breaks we can investigate setting
- * the property when calling the tool.
+ * generated classes, which we take advantage of here. This property can be set externally, and in
+ * that case the specified directory is used as a temporary dir. Otherwise, it will be set here,
+ * before doing anything else since the property is read in the static initializer.
*/
private static Path createAndRegisterLambdaDumpDirectory() throws IOException {
- Path dumpDirectory = Files.createTempDirectory("lambdas");
- System.setProperty(
- LambdaClassMaker.LAMBDA_METAFACTORY_DUMPER_PROPERTY, dumpDirectory.toString());
+ String propertyValue = System.getProperty(LambdaClassMaker.LAMBDA_METAFACTORY_DUMPER_PROPERTY);
+ Path dumpDirectory;
+ if (propertyValue != null) {
+ dumpDirectory = Paths.get(propertyValue);
+ } else {
+ dumpDirectory = Files.createTempDirectory("lambdas");
+ System.setProperty(
+ LambdaClassMaker.LAMBDA_METAFACTORY_DUMPER_PROPERTY, dumpDirectory.toString());
+ }
deleteTreeOnExit(dumpDirectory);
return dumpDirectory;