mirror of
https://github.com/corda/corda.git
synced 2025-01-04 04:04:27 +00:00
Merge pull request #288 from dicej/eiie-errors
only wrap Exceptions in ExceptionInInitializerErrors, not Errors
This commit is contained in:
commit
d4d232db89
@ -4660,7 +4660,8 @@ postInitClass(Thread* t, object c)
|
||||
PROTECT(t, c);
|
||||
ACQUIRE(t, t->m->classLock);
|
||||
|
||||
if (t->exception) {
|
||||
if (t->exception
|
||||
and instanceOf(t, type(t, Machine::ExceptionType), t->exception)) {
|
||||
classVmFlags(t, c) |= NeedInitFlag | InitErrorFlag;
|
||||
classVmFlags(t, c) &= ~InitFlag;
|
||||
|
||||
|
@ -1,4 +1,19 @@
|
||||
public class Exceptions {
|
||||
static class ThrowError {
|
||||
static {
|
||||
if (true) throw new AssertionError();
|
||||
}
|
||||
|
||||
static void foo() { }
|
||||
}
|
||||
|
||||
static class ThrowException {
|
||||
static {
|
||||
if (true) throw new RuntimeException();
|
||||
}
|
||||
|
||||
static void foo() { }
|
||||
}
|
||||
|
||||
private static void evenMoreDangerous() {
|
||||
throw new RuntimeException("chaos! panic! overwhelming anxiety!");
|
||||
@ -12,12 +27,37 @@ public class Exceptions {
|
||||
moreDangerous();
|
||||
}
|
||||
|
||||
private static void expect(boolean v) {
|
||||
if (! v) throw new RuntimeException();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
boolean threw = false;
|
||||
try {
|
||||
dangerous();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
threw = true;
|
||||
}
|
||||
expect(threw);
|
||||
threw = false;
|
||||
|
||||
try {
|
||||
ThrowError.foo();
|
||||
} catch (AssertionError e) {
|
||||
e.printStackTrace();
|
||||
threw = true;
|
||||
}
|
||||
expect(threw);
|
||||
threw = false;
|
||||
|
||||
try {
|
||||
ThrowException.foo();
|
||||
} catch (ExceptionInInitializerError e) {
|
||||
e.printStackTrace();
|
||||
threw = true;
|
||||
}
|
||||
expect(threw);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user