Skip to content

Fix original method invocation argument spreading (#701)#10

Merged
superturtlee merged 1 commit intosuperturtlee:masterfrom
JingMatrix:master
Apr 30, 2026
Merged

Fix original method invocation argument spreading (#701)#10
superturtlee merged 1 commit intosuperturtlee:masterfrom
JingMatrix:master

Conversation

@superturtlee
Copy link
Copy Markdown
Owner

In the proceedInvocation method of BaseInvoker.kt, specifically within the Invoker.Type.Origin block, the arguments array was being passed to the JNI bridge as a single object instead of being expanded into individual parameters.

In Kotlin, when a function accepts a variable number of arguments (vararg), passing an existing array variable requires the spread operator (*). Without this operator, the compiler treats the entire array as the first and only element of the vararg parameter. This mismatch causes the JNI bridge to receive a parameter count of 1 (the array itself) regardless of the actual number of elements, resulting in IllegalArgumentExceptions.

Documentation References:
Kotlin (Variable number of arguments):
https://kotlinlang.org/docs/functions.html#variable-number-of-arguments-varargs

If you already have an array and want to pass its contents to a function as a vararg parameter or as a part of it, use the spread operator by prefixing the array name with *.

Java (Varargs):
https://docs.oracle.com/javase/8/docs/technotes/guides/language/varargs.html

multiple arguments must be passed in an array

In the proceedInvocation method of `BaseInvoker.kt`, specifically within the Invoker.Type.Origin block, the arguments array was being passed to the JNI bridge as a single object instead of being expanded into individual parameters.

In Kotlin, when a function accepts a variable number of arguments (vararg), passing an existing array variable requires the spread operator (*). Without this operator, the compiler treats the entire array as the first and only element of the vararg parameter. This mismatch causes the JNI bridge to receive a parameter count of 1 (the array itself) regardless of the actual number of elements, resulting in IllegalArgumentExceptions.

Documentation References:
Kotlin (Variable number of arguments):
https://kotlinlang.org/docs/functions.html#variable-number-of-arguments-varargs
> If you already have an array and want to pass its contents to a function as a vararg parameter or as a part of it, use the spread operator by prefixing the array name with *.

Java (Varargs):
https://docs.oracle.com/javase/8/docs/technotes/guides/language/varargs.html
>  multiple arguments must be passed in an array
@superturtlee superturtlee merged commit ae7e887 into superturtlee:master Apr 30, 2026
2 checks passed
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.

2 participants