Option for try-with-resources runtime classes
Add flag to disable output of the runtime classes
necessary to support the try-with-resources feature
on older devices.
RELNOTES: n/a
PiperOrigin-RevId: 154933632
GitOrigin-RevId: fd6c97061906a38a1b4b3500d0cf3829e4d45725
Change-Id: I0f2fcbd4f7dc16b1cd5a1e6b62b0f9f95bec9854
diff --git a/java/com/google/devtools/build/android/desugar/Desugar.java b/java/com/google/devtools/build/android/desugar/Desugar.java
index ca7032e..3877307 100644
--- a/java/com/google/devtools/build/android/desugar/Desugar.java
+++ b/java/com/google/devtools/build/android/desugar/Desugar.java
@@ -171,6 +171,16 @@
public boolean desugarTryWithResourcesIfNeeded;
@Option(
+ name = "desugar_try_with_resources_omit_runtime_classes",
+ defaultValue = "false",
+ category = "misc",
+ help =
+ "Omits the runtime classes necessary to support try-with-resources from the output. "
+ + "This property has effect only if --desugar_try_with_resources_if_needed is used."
+ )
+ public boolean desugarTryWithResourcesOmitRuntimeClasses;
+
+ @Option(
name = "copy_bridges_from_classpath",
defaultValue = "false",
category = "misc",
@@ -306,7 +316,9 @@
}
private void copyThrowableExtensionClass(OutputFileProvider outputFileProvider) {
- if (!outputJava7 || !options.desugarTryWithResourcesIfNeeded) {
+ if (!outputJava7
+ || !options.desugarTryWithResourcesIfNeeded
+ || options.desugarTryWithResourcesOmitRuntimeClasses) {
// try-with-resources statements are okay in the output jar.
return;
}