(original) Do not understand JNI pointer invocation order

Source: Internet
Author: User

It's not clear what the order of the Pointers in JNI is (it might not be appropriate to describe them).

The following code, which follows the order of incoming pointers, crashes as soon as it runs. As follows:

1 jniexport jint jnicall java_com_example_x_xx_xxx2(JNIENV *env, Jclass, Jbytearray databuf, jint width, jint height, jstring path, Jintarray x1)3 {4jboolean* Parraydata = (jboolean*) env->getprimitivearraycritical (Databuf,0);5     Char* Papath=env->getstringutfchars (PATH,0);6jint* pAx1 = (jint*) env->getprimitivearraycritical (x1,0);7 8     //Code;9 TenEnv->releaseprimitivearraycritical (Databuf, Parraydata,0); OneEnv->releasestringutfchars (path, papath); AEnv->releaseprimitivearraycritical (x1, pAx1,0); -  -     returneyedist; the}

The order of the pointers is then changed slightly, and then you can run past them. As follows:

1 jniexport jint jnicall java_com_example_x_xx_xxx2(JNIENV *env, Jclass, Jbytearray databuf, jint width, jint height, jstring path, Jintarray x1)3 {4jboolean* Parraydata = (jboolean*) env->getprimitivearraycritical (Databuf,0);5jint* pAx1 = (jint*) env->getprimitivearraycritical (x1,0);6     Char* Papath=env->getstringutfchars (PATH,0);7 8     //Code;9 TenEnv->releaseprimitivearraycritical (Databuf, Parraydata,0); OneEnv->releaseprimitivearraycritical (x1, pAx1,0); AEnv->releasestringutfchars (path, papath); -  -     returneyedist; the}

(original) Do not understand JNI pointer invocation order

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.