refactor java server side jni layer