Undocumented Jython — Java callable Jython class idiom
You have to do
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from java import lang | |
class Backplane(lang.Object): | |
def performSetup(self, arg): | |
"@sig public void performSetup(java.lang.String arg)" | |
... |
and not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java | |
import java.lang | |
class Backplane(java.lang.Object): | |
def performSetup(self, arg): | |
"@sig public void performSetup(java.lang.String arg)" | |
... |
in order to make jythonc
generate the function calls you want in the intermediate Java code.
And as I'm in a “Jython calls Java calls Jython” state, doing some transcoding/refactoring, I have still not managed to get Jython at the front to call nicely into the Jython at the back.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import myPackage | |
obj = myPackage.Backplane() | |
print obj.getArg0 | |
print obj.getArg0() |
causes
method myPackage.Backplane.performSetup of myPackage.Backplane instance 1 Traceback (innermost last): ... AttributeError: abstract method "performSetup" not implemented
despite it being there quite plain as day:-
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void performSetup(java.lang.String arg) { | |
... | |
} |
and despite Java code calling it quite happily.
*sigh*
2 comments :
“Jython calls Java calls Jython”
Why? Stick to one language unless you are going for modern version of the obfuscated C competition!
Why -- to port some existing code from Java into Python, with the Jython environment as a medium for doing testable, stepwise replacement, and replacing one module at a time; rather than launching into a big-bang, recoding everything and then testing at the end.
There is usually method in some apparent madness.
Post a Comment