I'm going to write my own Python-Java interface. It is compiled as a DLL and wrapped using ctypes.
Yet, it is possible to find Java-classes and allocate Java-objects. But what would be an interface to another language without using those objects methods? My aim is to make this as natural as possible. Unfortunately, it isn't just possible to find Java-methods only by name.
My model is the following:
JClass
JObject
JMethod
Represents a method of a Java-object. It contains the name and signature of the desired method. The signature is evaluated dynamically by the classes that are given on initialization.
Example:
mainMethod = JMethod('main', JStringArray)
Note that JStringArray
is an instance of JClass that represents a string-array.
A JMethod can be added to a JClass instance. But can then be called only from an instantiated JObject.
JStaticMethod
Built-In types
I'm doing JInt
, JShort
, JLont
, JChar
, etc.. to be the
built-in wrapper types.
Like:
JInt = JClass('java/lang/Integer')
JShort = JClass('java/lang/Short')
JString = JClass('java/lang/String')
Question(s):
va_list
or something? I just need to find some way to call a method from Python in Java!1. What do I think of this design?
it's not clear what actual problem you're trying to solve.
what about edge cases; error-handling; forward-/backward-compatibility; bugs in Python/Java? Not fun, but essential for robust software.
mixing two languages is hard enough, mixing three is sure to be much much worse. I would expect major maintainability and coupling problems.
there are already solutions to these problems. RPC, for getting programs in different languages to talk to each other. Jython, for Java/Python interoperability. I believe, Jython even allows you to create Python objects in Java and vice versa directly. Clarifying any shortcomings of these existing systems, and how you would address these shortcomings, would be helpful.
Here are a few missing things:
2. I just need to find some way to call a method from Python in Java! What about Jython, RPC, or just calling an executable?