I was following the below link as reference for the connectivity of ballerina to java
https://github.com/ballerina-platform/module-ballerinax-kafka/blob/master/native/src/main/java/io/ballerina/stdlib/kafka/nativeimpl/consumer/BrokerConnection.java
I was able to access the java method which was not returing anything from java side to ballerina .
But when i wanted to access the java method which return some Object to ballerina i am doing this
function readString(handle arg1, handle arg2) returns handle = @java:Method {
`class: "com.exm.Student"
}external
Student s1 = <Student> readString(obj, "hello"));
getting below error :{balerina}TypeCastError {incompetible type 'handle' cannot be cast to package_path:Student}
In java side
public Object readString(string obj) {return new Student("name", 2)}