Fix memory access exception under jni