Avog
Avog

Reputation: 139

How does VM pass JNIEnv variable to a native method?

When we are working with JNI, first we create the native library. That library might have implemented in either C or C++. During runtime, lets say we are calling a native method. Depending on which language we used for native library implementation, VM has to provide JNIEnv variable. But how does VM know in which language (C or C++) we are implementing the code during runtime? Will it check the native library before passing arguments?

Upvotes: 1

Views: 76

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57173

jni.h provides a thin C++ wrapper around the C API; the underlying calls are language-agnostic.

Upvotes: 1

Related Questions