小心ReleaseByteArrayElements 中的参数问题

在Sun的官方文档中,关于该函数的用法如下

The array is returned to the calling Java language method, which in turn, garbage collects the reference to the array when it is no longer used. The array can be explicitly freed with the following call.

  (*env)-> ReleaseByteArrayElements(env, jb, 
                                        (jbyte *)m, 0);

The last argument to the ReleaseByteArrayElements function above can have the following values:

  • 0: Updates to the array from within the C code are reflected in the Java language copy.

     

  • JNI_COMMIT: The Java language copy is updated, but the local jbyteArray is not freed.

     

  • JNI_ABORT: Changes are not copied back, but the jbyteArray is freed. The value is used only if

你可能感兴趣的:(jni,exception,java,reference,function,sun)