Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin varargs functional interfaces cannot be called #1197

Open
mhsmith opened this issue Jul 5, 2024 · 0 comments
Open

Kotlin varargs functional interfaces cannot be called #1197

mhsmith opened this issue Jul 5, 2024 · 0 comments
Labels

Comments

@mhsmith
Copy link
Member

mhsmith commented Jul 5, 2024

This issue was discovered with Kotlin 1.3.41; maybe it's been fixed in a newer version.

In Electron Cash, I passed Python a reference to a Kotlin function with arguments (String, vararg PyObject). As expected, this was represented as an object with a method invoke(String, PyObject[]).

However, the method isn't marked as varargs in the Java reflection interface, so it can only be called with exactly one array-compatible argument. Passing anything else will invoke the base interface method Function2(Object, Object), which gives the error "is abstract and cannot be called".

I can't find any references to anyone else seeing this in the reflection API, but here's someone who says that a vararg Kotlin method decompiled into a vararg Java method.

The first step would be to look at the generated class file and see whether the method is marked as vararg there.

@mhsmith mhsmith added the bug label Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant