Is it possible to compile a library intended for Java with GCJ, get a dll and call from python ctypes?
I’m interested in toxilibs for now, but if anybody knows a toy example that would be great !
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want Java-Python hooks, you’d be far better off using Jython and then calling across the boundary that way.
However, yes, it’s possible to call an external library from Java; but you don’t need GCJ to do that. Rather, you can just bring up a JVM instance inside your Python runtime and then invoke your method(s) for that.
JNI invocation spec
Basically, you want to create your VM at startup, then invoke your method(s) whenever you want:
You could write some simple C-wrapper code to invoke this for you from ctypes. However, the JavaVM is a structure of a structure with a number of void* pointers, so might ne non-trivial to do it directly.