diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/008-exceptions/expected.txt | 17 | ||||
| -rw-r--r-- | test/008-exceptions/src/Main.java | 51 | ||||
| -rw-r--r-- | test/Android.run-test.mk | 2 |
3 files changed, 58 insertions, 12 deletions
diff --git a/test/008-exceptions/expected.txt b/test/008-exceptions/expected.txt index 92c79dc2a0..ea59a49677 100644 --- a/test/008-exceptions/expected.txt +++ b/test/008-exceptions/expected.txt @@ -1,12 +1,15 @@ Got an NPE: second throw java.lang.NullPointerException: second throw - at Main.catchAndRethrow(Main.java:58) - at Main.exceptions_007(Main.java:41) - at Main.main(Main.java:49) + at Main.catchAndRethrow(Main.java:77) + at Main.exceptions_007(Main.java:59) + at Main.main(Main.java:67) Caused by: java.lang.NullPointerException: first throw - at Main.throwNullPointerException(Main.java:65) - at Main.catchAndRethrow(Main.java:55) + at Main.throwNullPointerException(Main.java:84) + at Main.catchAndRethrow(Main.java:74) ... 2 more Static Init -BadError: This is bad by convention -BadError: This is bad by convention +BadError: This is bad by convention: BadInit +BadError: This is bad by convention: BadInit +Static BadInitNoStringInit +BadErrorNoStringInit: This is bad by convention +BadErrorNoStringInit: This is bad by convention diff --git a/test/008-exceptions/src/Main.java b/test/008-exceptions/src/Main.java index 7f6d0c5956..c0502047d0 100644 --- a/test/008-exceptions/src/Main.java +++ b/test/008-exceptions/src/Main.java @@ -14,20 +14,38 @@ * limitations under the License. */ -// An exception that doesn't have a <init>(String) method. +// An error class. class BadError extends Error { - public BadError() { - super("This is bad by convention"); + public BadError(String s) { + super("This is bad by convention: " + s); } } -// A class that throws BadException during static initialization. +// A class that throws BadError during static initialization. class BadInit { static int dummy; static { System.out.println("Static Init"); if (true) { - throw new BadError(); + throw new BadError("BadInit"); + } + } +} + +// An error that doesn't have a <init>(String) method. +class BadErrorNoStringInit extends Error { + public BadErrorNoStringInit() { + super("This is bad by convention"); + } +} + +// A class that throws BadErrorNoStringInit during static initialization. +class BadInitNoStringInit { + static int dummy; + static { + System.out.println("Static BadInitNoStringInit"); + if (true) { + throw new BadErrorNoStringInit(); } } } @@ -48,6 +66,7 @@ public class Main { public static void main (String args[]) { exceptions_007(); exceptionsRethrowClassInitFailure(); + exceptionsRethrowClassInitFailureNoStringInit(); } private static void catchAndRethrow() { @@ -86,4 +105,26 @@ public class Main { error.printStackTrace(); } } + + private static void exceptionsRethrowClassInitFailureNoStringInit() { + try { + try { + BadInitNoStringInit.dummy = 1; + throw new IllegalStateException("Should not reach here."); + } catch (BadErrorNoStringInit e) { + System.out.println(e); + } + + // Check if it works a second time. + + try { + BadInitNoStringInit.dummy = 1; + throw new IllegalStateException("Should not reach here."); + } catch (BadErrorNoStringInit e) { + System.out.println(e); + } + } catch (Exception error) { + error.printStackTrace(); + } + } } diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk index 8744674a30..ab1e34e34c 100644 --- a/test/Android.run-test.mk +++ b/test/Android.run-test.mk @@ -71,6 +71,7 @@ $$(dmart_target): $(TEST_ART_RUN_TEST_DEPENDENCIES) $(TARGET_JACK_CLASSPATH_DEPE JACK=$(abspath $(JACK)) \ JACK_CLASSPATH=$(TARGET_JACK_CLASSPATH) \ JILL_JAR=$(abspath $(JILL_JAR)) \ + JACK_VERSION=$(JACK_LANG_DEV_VERSION) \ $(LOCAL_PATH)/run-test $$(PRIVATE_RUN_TEST_OPTIONS) --output-path $$(abspath $$(dir $$@)) $(1) $(hide) touch $$@ @@ -875,6 +876,7 @@ $$(run_test_rule_name): $(TEST_ART_RUN_TEST_DEPENDENCIES) $(HOST_OUT_EXECUTABLES JACK=$(abspath $(JACK)) \ JACK_CLASSPATH=$$(PRIVATE_JACK_CLASSPATH) \ JILL_JAR=$(abspath $(JILL_JAR)) \ + JACK_VERSION=$(JACK_LANG_DEV_VERSION) \ art/test/run-test $$(PRIVATE_RUN_TEST_OPTIONS) $(12) \ && $$(call ART_TEST_PASSED,$$@) || $$(call ART_TEST_FAILED,$$@) $$(hide) (echo $(MAKECMDGOALS) | grep -q $$@ && \ |