Originally posted by Ravindranath Chowdary:
Hi Friends,
I read as when ever native method is called the C code corresponding to that method is called. I have two doubts on this...
1. How that C/C++ -language code is executed when java program runs with native methods?
2. How the output from the C code is getback to the java program?
Can you please clarify on this.
Thanks,
Ravindra.
1.The problem is solved using JNI, Java native interface, c/c++ code is invoked by the system, it has nothing to do with java, since it is not excuted in JVM, while java code does.JNI just act like a bridge, it connects native code and java code, when java program runs with native methods, the native methods is run by the system, while the result is passed to java code by JNI.
It's just my opinion on this problem, if wrong, i hope anyone to give me a correction.
2.This is done by JNI, simplely by value passing, of course there is a map between java type and the types of other programming languages.But i have no idea on how JNI coordinate this process, maybe you can read Java Native Interface Specification. you can see
http://java.sun.com/j2se/1.3/docs/guide/jni/spec/jniTOC.doc.html or ibm's overview of jni through
http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/index.jsp?topic=/com.ibm.java.doc.diagnostics.50/diag/understanding/jni_spec_impl.html