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

Re: Interface gcj-compiled library with Java programs in a runtime (other than gij)? Yi Lin Sun Feb 12 21:00:12 2012

Thank you. I think I may have missed a keyword here: CNI. I avoid using JNI for performance degradation.

The detailed scenario is like:
There are two parts of code.

-SomeJavaCode.java: containing a method call to NativeJavaLib.a().
This part of code remains in bytecode

-NativeJavaLib.java: declaring 'native void a()'
-NativeJavaLib.cpp: implementing a() via CNI
This part is compiled to libJavaLib.so

Now SomeJavaCode can be executed correctly with 'gij' interpreter; I think there is no JNI involved. But it cannot run on HotSpot or other VM. If I have to use JNI to do this, then the approach is much less attractive.


On 13/02/12 15:00 , Brian Jones wrote:
I suggest you try jni to get to whatever native code you are interested in.


On Feb 12, 2012, at 10:01 PM, Yi Lin<[EMAIL PROTECTED]>  wrote:


I am wondering if we can use methods from a gcj-compiled library in uncompiled 
Java program(bytecode) executed on a VM.

According to gcj FAQ 1.7, there is no problem to do this with 'gij' 
interpreter/runtime. You can compile some Java code into library (native code), 
and run bytecode with 'gij' to invoke library methods. But this seems only 
capable for 'gij', and other runtimes like HotSpot cannot load and link the 
library properly.

I want to know if there is a general solution to allow you interface uncompiled 
Java program with gcj-compiled library. Any information or reference about this 
will be appreciated.

Many Thanks,