mirror of
https://github.com/corda/corda.git
synced 2025-01-22 12:28:11 +00:00
specify classloader when calling Class.forCanonicalName in Field and Method; tolerate null argument array in Method.invoke
This commit is contained in:
parent
5c72746d2c
commit
58c3a37277
@ -53,7 +53,8 @@ public class Field<T> extends AccessibleObject {
|
||||
}
|
||||
|
||||
public Class getType() {
|
||||
return Class.forCanonicalName(new String(spec, 0, spec.length - 1, false));
|
||||
return Class.forCanonicalName(class_.getClassLoader(),
|
||||
new String(spec, 0, spec.length - 1, false));
|
||||
}
|
||||
|
||||
public Object get(Object instance) throws IllegalAccessException {
|
||||
|
@ -85,11 +85,13 @@ public class Method<T> extends AccessibleObject
|
||||
types[index++] = Class.forName(name);
|
||||
} else {
|
||||
String name = spec.substring(start, i + 1);
|
||||
types[index++] = Class.forCanonicalName(name);
|
||||
types[index++] = Class.forCanonicalName
|
||||
(class_.getClassLoader(), name);
|
||||
}
|
||||
} else {
|
||||
String name = spec.substring(i, i + 1);
|
||||
types[index++] = Class.forCanonicalName(name);
|
||||
types[index++] = Class.forCanonicalName
|
||||
(class_.getClassLoader(), name);
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
@ -107,6 +109,13 @@ public class Method<T> extends AccessibleObject
|
||||
instance = null;
|
||||
}
|
||||
|
||||
if (arguments == null) {
|
||||
if (parameterCount > 0) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
arguments = new Object[0];
|
||||
}
|
||||
|
||||
if (arguments.length == parameterCount) {
|
||||
return invoke(this, instance, arguments);
|
||||
} else {
|
||||
@ -125,7 +134,8 @@ public class Method<T> extends AccessibleObject
|
||||
for (int i = 0; i < spec.length - 1; ++i) {
|
||||
if (spec[i] == ')') {
|
||||
return Class.forCanonicalName
|
||||
(new String(spec, i + 1, spec.length - i - 2, false));
|
||||
(class_.getClassLoader(),
|
||||
new String(spec, i + 1, spec.length - i - 2, false));
|
||||
}
|
||||
}
|
||||
throw new RuntimeException();
|
||||
|
Loading…
Reference in New Issue
Block a user