Skip to content

Commit

Permalink
varargs does not matter for effective fix-arity
Browse files Browse the repository at this point in the history
  • Loading branch information
liach committed Dec 2, 2024
1 parent c6d7061 commit 7f77d92
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,11 @@ private static boolean useNativeAccessor(Executable member) {
if (member instanceof Method method && isSignaturePolymorphicMethod(method))
return true;

// Lookup always calls MethodHandle::setVarargs on a member with ACC_VARARGS
// bit set, which verifies that the last parameter of the member must be
// an array type. Such restriction does not exist in core reflection
// and the JVM. Fall back to use the native implementation instead.
// For members with ACC_VARARGS bit set, MethodHandles produced by lookup
// always have variable arity set and hence the last parameter of the member
// must be an array type. Such restriction does not exist in core reflection
// and the JVM, which always use fixed-arity invocations. Fall back to use
// the native implementation instead.
int paramCount = member.getParameterCount();
if (member.isVarArgs() &&
(paramCount == 0 || !(reflectionFactory.getExecutableSharedParameterTypes(member)[paramCount-1].isArray()))) {
Expand Down

0 comments on commit 7f77d92

Please sign in to comment.