I'm using py4j to port some java code directly to python. I'm wondering if there are any utilities or tools to automatically write the equivalent py4j code.
An example of the kind of code I'm porting would be as follows, where MyClass and MyOtherClass are java classes I have access to:
JAVA:
import com.mycompany.blah.MyClass;
import com.mycompany.blah.MyOtherClass;
MyClass foo = new MyClass();
MyOtherClass bar = new MyOtherClass(foo);
So the python code I'm looking for would look like:
PYTHON (Py4J):
from py4j.java_gateway import JavaGateway
from py4j.java_gateway import java_import
gateway = JavaGateway()
module = gateway.new_jvm_view()
java_import(module,'com.mycompany.blah.MyClass')
java_import(module,'com.mycompany.blah.MyOtherClass')
foo = module.MyClass()
bar = module.MyOtherClass(foo)
Thanks!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…