h-gen Overview

h-gen can make implementing JNI methods much simpler. It generates a C++ header file that declares a C++ class with the same name as the Java class. It uses C++ namespaces to mirror Java package names. For each method or field in the Java class, h-gen generates static C++ member functions that can be used from C++ to call the corresponding java method or access the corresponding java field. Additionally, native methods cause h-gen to generate a <name>_thunk member function and a <name>_impl member function declartion.

The thunk will be registered with Java as the native method implementation. The thunk simply sets up a try/catch frame to convert the C++ exception ::java::lang::Throwable * into a Java exception and then simply calls the <name>_impl member function. To implement the JNI method you need to code the <name>_impl C++ member function.

h-gen will pass pointers to other h-gen generated classes instead of just passing jobject. This allows your JNI method to easily access Java fields or call Java methods.

h-gen Usage (command line and ant)

Common Tasks


$Id: index.html 3769 2007-06-08 19:06:43Z hastings $