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

[Bug]: Inconsistent behaviors in specifying parameter types for interop functions #42456

Open
gabilang opened this issue Apr 1, 2024 · 1 comment · May be fixed by #42674
Open

[Bug]: Inconsistent behaviors in specifying parameter types for interop functions #42456

gabilang opened this issue Apr 1, 2024 · 1 comment · May be fixed by #42674
Assignees
Labels
Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug

Comments

@gabilang
Copy link
Contributor

gabilang commented Apr 1, 2024

Description

Following interop case with the parameter type specified gives the parameter count mismatch error which may cause confusions.

public isolated client class Client {
    isolated function getResourceMethod(service object {} serviceObject, string[] path) returns any = @java:Method {
         'class: "myapp.app.App",
         paramTypes: ["io.ballerina.runtime.api.values.BObject", "io.ballerina.runtime.api.values.BArray"]
     } external;
}

Interop java method:

public static Object getResourceMethod(BObject service, BArray path) {
    return 1000;
}

error:

{ballerina/jballerina.java}METHOD_SIGNATURE_DOES_NOT_MATCH 'Parameter count does not match with Java method 'getResourceMethod' found in class 'myapp.app.App''

Anyway it works fine if the parameterType field is specified as

paramTypes: ["io.ballerina.runtime.api.values.BArray"]

Steps to Reproduce

No response

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@gabilang gabilang added Type/Bug Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime labels Apr 1, 2024
@gabilang gabilang self-assigned this Apr 9, 2024
@gabilang
Copy link
Contributor Author

gabilang commented Apr 25, 2024

It also works as expected when we specify the parameter types as

paramTypes: ["io.ballerina.runtime.api.values.BObject", "io.ballerina.runtime.api.values.BObject", "io.ballerina.runtime.api.values.BArray"]

and the matching Java method as

public static Object getResourceMethod(BObject receiver, BObject service, BArray path) {
    return 1000;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Projects
Status: PR Sent
Development

Successfully merging a pull request may close this issue.

1 participant