Skip to content

Function invocation invokes with wrong arguments #456

Open
@brentco

Description

@brentco

Problem:
When passing a function from JS to Java and then later invoking that function from Java (with type java.util.Function) it seems that calling apply() on that function with an array as argument, the function on the JS side gets invoked with incorrect types. Seemingly, despite the one arg requirement of java.util.Function, an array type arg will result in the contents of said arg being expanded as varargs in the actual (reflection?) invocation.

This changes the underlying object when using the arg in the JS function and results in wrong behavior.

Steps to reproduce:
I have created a minimal reproduction project: https://github.com/brentco/graal-invocation-bug-reproducer

Expected:
The array should be passed on as-is to the JS function.

Workaround:
Wrapping the input arg in Value.asValue(...) before invoking the Function will work fine and the array will be passed on as-is.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions