publicclass Main { static {
staticMethodCalledByClinit();
}
privatestaticvoid staticMethodCalledByClinit() { // Test that DeliverException works when we need to unwind to a handler -- this method -- // that is currently a resolution stub because it's running on behalf of <clinit>. try {
throwDuringClinit();
System.out.println("didn't throw!");
} catch (NullPointerException ex) {
System.out.println("caught exception thrown during clinit");
}
}
// 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");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.