rubicon-java icon indicating copy to clipboard operation
rubicon-java copied to clipboard

Add support for implementing interfaces with methods that expect `String` or `long` or other return types

Open paulproteus opened this issue 4 years ago • 2 comments

Currently, rubicon-java cannot be used to implement a Java Interface's methods that return data types other than int and void. This means the following Interface is unimplementable in Python at the moment.

interface StringMaker {
  public String makeString();
}

If a rubicon-java user attempts to implement an interface like that with Python code such as:

StringMaker = JavaInterface("StringMaker")
class MakeString(StringMaker):
    def makeString(self):
        return "I like string"

Java will crash with a NullPointerException.

This is fixable; hence this ticket. :) We can either blindly convert a method's return type to the most relevant Java type, or we can introspect the Java Interface to see what is expected.

Currently non-working return types include String, really all Objects, long, float, double, etc. See also #42, which added support for returning int.

paulproteus avatar Jun 16 '20 00:06 paulproteus

#52 and #42 handle this for Java int and Java boolean, in case anyone is curious.

paulproteus avatar Aug 06 '20 04:08 paulproteus

Same issues. I use it this way:

class PythonBridge(IPythonBridge):
    def testFunc(self):
        print("running!!!!!")
        PythonUtils.setResult("result!!!!")

🤣🤣🤣

gogogoghost avatar Oct 14 '20 14:10 gogogoghost