Skip to content

Multiple Functional Interface SAM Types Not Automatically Resolved Like Nashorn (When using as callable function in JS) #911

@vkbkrishna

Description

@vkbkrishna

When a Java class implements multiple functional interfaces with different arities, and used as callable function in Javascript,

GraalJS doesn't automatically resolve the appropriate method based on the number of arguments passed from JavaScript, unlike Nashorn.

It always resolves to the first implemented interface in the source code regardless of number of method args.

This creates migration challenges for existing Nashorn applications and reduces the ease of Java-JavaScript interoperability.

This functionality worked seamlessly in Nashorn, and while we understand GraalJS might have different design goals regarding JavaScript compliance, this automatic resolution of multiple functional interfaces was a useful feature for Java-JavaScript interoperability. The current behavior requires explicit handling which adds complexity to the codebase

GraalJS.version => 23.1.2
JDK version - 21

Sample code below.

multiple_functional_intreface_issue_code.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions