I have a jython script in which I need to call a java method for processing some logic.
And here is my jython script:
from sets import Set
....
names = Set(["Alice","Bob","Charles"])
// call a java method
Test.removeNames(names)
The removeNames in the Test class takes java.util.Set as parameter. And after running the script, I got a TypeError:
TypeError: removeNames(): 1st arg can't be coerced to java.util.Set
I tried to use java.util.Set in my jython script and it worked. However, I just wonder is there a way for the java method to recognize jython object??
Thanks!!!
Jython documentation says that automatic type conversion (coercion) happens wherever needed. But only some Jython types (refer the list given in Jython documentation) can be converted to Java type and viceversa.
For other types, I guess the Java type objects have to be used to pass as a param to a Java method.