Skip to content

Commit eb23711

Browse files
committed
MethodHandle substitutions refactoring
1 parent 0373c0d commit eb23711

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandle.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -285,29 +285,22 @@ private static SubstrateConstructorAccessor getConstructorAccessor(Constructor<?
285285
}
286286

287287
private static <T extends AccessibleObject & Member> void checkMember(T member, boolean isStatic) {
288-
if (!(Modifier.isStatic(member.getModifiers()) == isStatic)) {
289-
throw checkMemberFailed(isStatic);
288+
if (Modifier.isStatic(member.getModifiers()) != isStatic) {
289+
throw VMError.shouldNotReachHere("Cannot perform " +
290+
(isStatic ? "static" : "non-static") + " operation on a " +
291+
(isStatic ? "non-static" : "static") + " member");
290292
}
291293
}
292294

293-
private static RuntimeException checkMemberFailed(boolean isStatic) {
294-
throw VMError.shouldNotReachHere("Cannot perform " +
295-
(isStatic ? "static" : "non-static") + " operation on a " +
296-
(isStatic ? "non-static" : "static") + " member");
297-
}
298-
299295
private static SubstrateAccessor getAccessor(Target_java_lang_invoke_MemberName memberName) {
300296
VMError.guarantee(memberName.isInvocable(), "Cannot perform invokeSpecial on a field");
301297
return memberName.isMethod() ? getMethodAccessor((Method) memberName.reflectAccess) : getConstructorAccessor((Constructor<?>) memberName.reflectAccess);
302298
}
303299

304300
private static void checkArgs(Object[] args, int expectedLength, String methodName) {
305-
if (!((expectedLength == 0 && args == null) || args.length == expectedLength)) {
306-
throw checkArgsFailed(expectedLength, methodName);
301+
if ((expectedLength == 0 && args == null) || args.length == expectedLength) {
302+
return;
307303
}
308-
}
309-
310-
private static RuntimeException checkArgsFailed(int expectedLength, String methodName) {
311304
throw VMError.shouldNotReachHere(methodName + " requires exactly " + expectedLength + " arguments");
312305
}
313306

0 commit comments

Comments
 (0)