summaryrefslogtreecommitdiff
path: root/test/java/com/google/devtools/build/android/desugar/testdata/ClassUsingTryWithResources.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/java/com/google/devtools/build/android/desugar/testdata/ClassUsingTryWithResources.java')
-rw-r--r--test/java/com/google/devtools/build/android/desugar/testdata/ClassUsingTryWithResources.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/java/com/google/devtools/build/android/desugar/testdata/ClassUsingTryWithResources.java b/test/java/com/google/devtools/build/android/desugar/testdata/ClassUsingTryWithResources.java
index c340c84..e4f7f18 100644
--- a/test/java/com/google/devtools/build/android/desugar/testdata/ClassUsingTryWithResources.java
+++ b/test/java/com/google/devtools/build/android/desugar/testdata/ClassUsingTryWithResources.java
@@ -49,6 +49,9 @@ public class ClassUsingTryWithResources {
}
}
+ /** A resource inheriting the close() method from its parent. */
+ public static class InheritanceResource extends SimpleResource {}
+
/** This method will always throw {@link java.lang.Exception}. */
public static void simpleTryWithResources() throws Exception {
// Throwable.addSuppressed(Throwable) should be called in the following block.
@@ -57,6 +60,17 @@ public class ClassUsingTryWithResources {
}
}
+ /**
+ * This method useds {@link InheritanceResource}, which inherits all methods from {@link
+ * SimpleResource}.
+ */
+ public static void inheritanceTryWithResources() throws Exception {
+ // Throwable.addSuppressed(Throwable) should be called in the following block.
+ try (InheritanceResource resource = new InheritanceResource()) {
+ resource.call(true);
+ }
+ }
+
public static Throwable[] checkSuppressedExceptions(boolean throwException) {
// Throwable.addSuppressed(Throwable) should be called in the following block.
try (SimpleResource resource = new SimpleResource()) {