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]: Type cast error when bundling BObject type parameter into BArray in interop methods #42504

Closed
gabilang opened this issue Apr 8, 2024 · 1 comment · Fixed by #42505
Closed
Assignees
Labels
Area/JavaInterop Java interoperability in Ballerina Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug

Comments

@gabilang
Copy link
Contributor

gabilang commented Apr 8, 2024

Description

$title

Steps to Reproduce

public isolated client class ClientObj {
    resource isolated function get albums/[int id](string s, Request req, typedesc<any> targetType = <>) returns 
                targetType|error = @java:Method {
        'class: "myapp.app.App",
        name: "invokeResourceWithoutPath"
    } external;
}

public class Request {
    public int port = 9090;
    public function init(int port) {
        self.port = port;
    }
}

public function main() returns error? {
    ClientObj res = new;
    any res = check res->/albums/[1001]("abc", new Request(8080));
    io:println(res);
}

Interop Java method:

public static Object invokeResourceWithoutPath(Environment env, BObject client, BArray path, BArray params) {
     return 1001;
 }

output:

error: {ballerina}TypeCastError {"message":"incompatible types: 'bal_project:Request' cannot be cast to 'anydata'"}

Affected Version(s)

master, 2201.9.0

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

Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/JavaInterop Java interoperability in Ballerina Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime Type/Bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants