This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Calling a Java function from C++ using CNI
Shaun Jackman wrote:
Yes, but the function is called JvCreateJavaVM, which is clearly
misleading. I have no intention of creating a VM. I therefore believed
the link did not apply to me. May I suggest JvCreateJavaRuntime? That
I would have believed.
JvCreateJavaVM is analgous to JNI's JNI_CreateJavaVM. Perhaps
CreateJavaRuntime would have been better, but the pain of changing it
now is not worth it. In any case, it doesn't make any difference to your
C++ code whether the Java code you are calling is bytecode or native, so
the distinction between "VM" and "Runtime" here isn't really relevant.
I've read that object creation and static function calls check to see
that the class has been initialized first. Perhaps at this same point
the system could check that the runtime has been initialized.
This is a possibility, and I agree it could make CNI simpler to use.
However, we need to consider how it will interract with upcoming changes
to the way CNI is implemented internally as part of the BC-ABI. Under
the BC-ABI, the java.lang.Class object for the code you're calling might
not even be created until you call JvCreateJavaVM.
Regards
Bryce