mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
fix exception wrapping for Method.invoke and static initializers
Method.invoke should initialize its class before invoking the method, throwing an ExceptionInInitializerError if it fails, without wrapping said error in an InvocationTargetException. Also, we must initialize ExceptionInInitializerError.exception when throwing instances from the VM, since OpenJDK's ExceptionInInitializerError.getCause uses the exception field, not the cause field.
This commit is contained in:
@ -11,11 +11,11 @@
|
||||
package java.lang;
|
||||
|
||||
public class ExceptionInInitializerError extends Error {
|
||||
private final Throwable cause2;
|
||||
private final Throwable exception;
|
||||
|
||||
public ExceptionInInitializerError(String message) {
|
||||
super(message);
|
||||
cause2 = null;
|
||||
exception = null;
|
||||
}
|
||||
|
||||
public ExceptionInInitializerError() {
|
||||
|
@ -84,6 +84,8 @@ public class Field<T> extends AccessibleObject {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
Classes.initialize(vmField.class_);
|
||||
|
||||
switch (vmField.code) {
|
||||
case ByteField:
|
||||
return Byte.valueOf
|
||||
@ -171,6 +173,8 @@ public class Field<T> extends AccessibleObject {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
Classes.initialize(vmField.class_);
|
||||
|
||||
switch (vmField.code) {
|
||||
case ByteField:
|
||||
setPrimitive(target, vmField.code, vmField.offset, (Byte) value);
|
||||
@ -235,6 +239,8 @@ public class Field<T> extends AccessibleObject {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
Classes.initialize(vmField.class_);
|
||||
|
||||
switch (vmField.code) {
|
||||
case ByteField:
|
||||
case BooleanField:
|
||||
|
@ -81,6 +81,8 @@ public class Method<T> extends AccessibleObject implements Member {
|
||||
}
|
||||
|
||||
if (arguments.length == vmMethod.parameterCount) {
|
||||
Classes.initialize(vmMethod.class_);
|
||||
|
||||
return invoke(vmMethod, instance, arguments);
|
||||
} else {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
|
Reference in New Issue
Block a user