[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: Interface gcj-compiled library with Java programs in a runtime (other than gij)? Yi Lin Tue Feb 14 04:00:24 2012

Thank you all for the answers. I think I have some clue about CNI/JNI on the interface.

But I still have doubt about how a shared library compiled from Java can be used by a) c/c++, b) Java code running on other JVM (not libgcj interpreter). I think b) is straightforwad if a) is possible.

So for a), is calling a shared library of compiled java code any different than calling a shared library from normal c/c++ code? I have been spending two days exploring this and trying different approaches. My expectation is to load the compiled Java lib and use its method via dlopen, dlsym, etc. I guess another possibility is to use JvCreateVM(), and do everything in Java fashion. I don't have any success in either yet. Any hint would be very helpful so I could stop wasting time on a wrong track.


On 2012/2/14 21:31, Bryce McKinlay wrote:
On Tue, Feb 14, 2012 at 9:47 AM, Andrew Haley<[EMAIL PROTECTED]>  wrote:
On 02/13/2012 06:32 PM, David Daney wrote:
I am just going from memory here, but I think that the interpreter can
only call native code via JNI.
Ahh, if that were really true, interpreted code couldn't call
Object.<init>() ...

David is saying that "native" methods in interpreted classes can't be
implemented with CNI. Which is true, I think.

Obviously, the interpreter can call native CNI methods in other
(non-interpreted) classes, like Object. Hence the trampoline example.