using method 2 for JNI calls