Skip to content

Fix Object arrays passed to typed Java varargs - #822

Open
HdShare wants to merge 1 commit into
beanshell:masterfrom
HdShare:fix-object-array-java-varargs
Open

HdShare wants to merge 1 commit into
beanshell:masterfrom
HdShare:fix-object-array-java-varargs

Conversation

@HdShare

@HdShare HdShare commented Sep 12, 2026

Copy link
Copy Markdown

Passing an Object[] as the array argument to typed Java varargs currently treats the entire array as one vararg element. Calls such as Class.getDeclaredMethod(..., (Object[]){...}) then try to cast Object[] to the component type instead of converting its elements to the declared array type.

Recognize a non-null Object[] in the fixed-arity position after member selection, convert its elements with the existing coercion rules, and invoke the member with the declared varargs array type. Already typed arrays, null arrays, and expanded varargs keep their existing behavior, while anonymous subclasses apply the same conversion before forwarding arguments to a typed-varargs superclass constructor. Method overload selection remains unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant