summaryrefslogtreecommitdiffstats
path: root/jack-tests/tests/com/android
diff options
context:
space:
mode:
authorYohann Roussel <yroussel@google.com>2014-09-04 19:11:23 +0200
committerMikael Peltier <mikaelpeltier@google.com>2014-09-11 12:47:58 +0000
commit0dfc1c33422f575d8e1536ba7c32f3fa982c616e (patch)
treeb0023391018982ef3fe3ae967969131d60988933 /jack-tests/tests/com/android
parentad341e852a71e707a773ad13cf6829fe620351fe (diff)
downloadtoolchain_jack-0dfc1c33422f575d8e1536ba7c32f3fa982c616e.zip
toolchain_jack-0dfc1c33422f575d8e1536ba7c32f3fa982c616e.tar.gz
toolchain_jack-0dfc1c33422f575d8e1536ba7c32f3fa982c616e.tar.bz2
Fix illegal code generation of TryWithResourcesTransformer
- Add a test for try with resources that exhibit illegal code generation. - Add generation of throw instruction to have correct java code at compile time. Bug: 17389106 Change-Id: I451adb03917b5908faf2a7730990c474009706d2
Diffstat (limited to 'jack-tests/tests/com/android')
-rw-r--r--jack-tests/tests/com/android/jack/java7/trywithresources/test002/dx/Tests.java5
-rw-r--r--jack-tests/tests/com/android/jack/java7/trywithresources/test002/jack/TryWithResourcesTest002.java24
2 files changed, 29 insertions, 0 deletions
diff --git a/jack-tests/tests/com/android/jack/java7/trywithresources/test002/dx/Tests.java b/jack-tests/tests/com/android/jack/java7/trywithresources/test002/dx/Tests.java
index aa47320..641274d 100644
--- a/jack-tests/tests/com/android/jack/java7/trywithresources/test002/dx/Tests.java
+++ b/jack-tests/tests/com/android/jack/java7/trywithresources/test002/dx/Tests.java
@@ -91,4 +91,9 @@ import org.junit.Test;
public void test013() {
Assert.assertTrue(TryWithResourcesTest002.m13());
}
+
+ @Test
+ public void test014() throws Exception {
+ Assert.assertTrue(TryWithResourcesTest002.m14(1));
+ }
}
diff --git a/jack-tests/tests/com/android/jack/java7/trywithresources/test002/jack/TryWithResourcesTest002.java b/jack-tests/tests/com/android/jack/java7/trywithresources/test002/jack/TryWithResourcesTest002.java
index 5b9ea0e..6a58bc3 100644
--- a/jack-tests/tests/com/android/jack/java7/trywithresources/test002/jack/TryWithResourcesTest002.java
+++ b/jack-tests/tests/com/android/jack/java7/trywithresources/test002/jack/TryWithResourcesTest002.java
@@ -270,4 +270,28 @@ public class TryWithResourcesTest002 {
return result;
}
+ private static boolean getMaybeThrow(int condition) throws E1 {
+ if (condition < 5) {
+ return true;
+ } else if (condition > 15) {
+ return false;
+ }
+ throw new E1();
+ }
+
+ public static boolean m14(int condition) throws Exception {
+ Observer o1 = new Observer();
+ try (
+ AutoCloseable001 ac1 = new AutoCloseable001(o1);
+ ) {
+ if (condition < 10) {
+ return getMaybeThrow(condition + 2);
+ }
+ return getMaybeThrow(condition);
+ // No exception
+ } catch (E1 e) {
+ return getMaybeThrow(condition - 10);
+ }
+ }
+
}