From 073278cd7129ff07dbcd6ccfabd2c34f47ec92ad Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Wed, 19 Feb 2014 15:21:21 -0800 Subject: Do not FixupStaticTrampolines of uninitialized classes Bug: 13027732 Change-Id: I5966d63afd8fbcd091801297290f117f3c9cb44c --- test/084-class-init/expected.txt | 2 ++ test/084-class-init/src/Main.java | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'test/084-class-init') diff --git a/test/084-class-init/expected.txt b/test/084-class-init/expected.txt index 1389214..d7a80bf 100644 --- a/test/084-class-init/expected.txt +++ b/test/084-class-init/expected.txt @@ -8,3 +8,5 @@ SlowInit static block post-sleep MethodThread message Fields (child thread): 111222333444 Fields (main thread): 111222333444 +checkStaticMethodInvokeAfterFailedClinit START +checkStaticMethodInvokeAfterFailedClinit PASSED diff --git a/test/084-class-init/src/Main.java b/test/084-class-init/src/Main.java index cf69570..28eb3e9 100644 --- a/test/084-class-init/src/Main.java +++ b/test/084-class-init/src/Main.java @@ -37,6 +37,7 @@ public class Main { public static void main(String[] args) { checkExceptions(); checkTiming(); + checkStaticMethodInvokeAfterFailedClinit(); } public static void sleep(int msec) { @@ -128,4 +129,33 @@ public class Main { SlowInit.printMsg("MethodThread message"); } } + + static void checkStaticMethodInvokeAfterFailedClinit() { + System.out.println("checkStaticMethodInvokeAfterFailedClinit START"); + + // Call static method to cause implicit clinit. + try { + ClassWithThrowingClinit.staticMethod(); + System.out.println("checkStaticMethodInvokeAfterFailedClinit FAILED" + + " due to missing ExceptionInInitializerError"); + } catch (ExceptionInInitializerError expected) { + } + + // Call again to make sure we still get the expected error. + try { + ClassWithThrowingClinit.staticMethod(); + System.out.println("checkStaticMethodInvokeAfterFailedClinit FAILED" + + " due to missing NoClassDefFoundError"); + } catch (NoClassDefFoundError expected) { + } + System.out.println("checkStaticMethodInvokeAfterFailedClinit PASSED"); + } + + static class ClassWithThrowingClinit { + static { + throwDuringClinit(); + } + static void staticMethod() { + } + } } -- cgit v1.1