rubicon-java
rubicon-java copied to clipboard
Add support for implementing interfaces with methods that expect `String` or `long` or other return types
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 Object
s, long
, float
, double
, etc. See also #42, which added support for returning int
.
#52 and #42 handle this for Java int and Java boolean, in case anyone is curious.
Same issues. I use it this way:
class PythonBridge(IPythonBridge):
def testFunc(self):
print("running!!!!!")
PythonUtils.setResult("result!!!!")
🤣🤣🤣