JNIpp 1.0
JNI meets C++
Home

Introduction

Welcome to JNIpp library which uses the power of C++ to give you better Java native interface.

JNIpp key features:

Start exploring JNIpp by looking at the examples.

See android/samples/HelloJNIpp for Android-specific example that features native Activity, native custom draw View and natively handled Button.

Installation

JNIpp has the following dependencies:

Currently JNIpp supports Android platform only. It can be build on other platforms too (in fact it was developed on MacOS), however, no library projects are provided so you have to manually arrange and add source files to your app project.

On Android platform both JNIpp and dropins projects are installed as NDK modules (supported in NDK r5+). Steps to install:

  • Checkout both libraries to your NDK_MODULE_PATH directory. If you don't want to bother with NDK_MODULE_PATH you can checkout directly to the NDK_ROOT/sources directory. Checkout commands:
  • Add the following to your Android.mk:
        LOCAL_STATIC_LIBRARIES := itoa-jnipp
        $(call import-module,itoa-jnipp/android) 
    
    See android/samples/HelloJNIpp/jni/Android.mk for example.
  • Add the following to your Application.mk:
         APP_CPPFLAGS := -fexceptions
         APP_STL := gnustl_static
    
    See android/samples/HelloJNIpp/jni/Application.mk for example.
  • #include <JNIpp.h> in your header and source files.

Issues

Currently library has the following issues:

  • No support for MonitorEnter/MonitorExit. That will definitely be fixed in the next release. For now you have to use raw functions from JNIEnv: jni::GetEnv()->MonitorEnter(obj.GetJObject()). Wrap calls in RAII object!
  • No support for GetElements/SetElements in java::PrimitiveArray. Use Get/ReleaseXXXArrayElements from jni namespace (e.g. jni::GetIntArrayElements).
  • Other issues, see numerous TODOs in the source files.