JNI optimization