Properly returning a hardcoded byte[] from JNI to Java

前端 未结 1 826
自闭症患者
自闭症患者 2020-12-22 13:49

I want to hardcode a 16 byte array in JNI and return it with a method.

This isn\'t working

static jbyteArray JNICALL getKeyBytes(JNIEnv *env, jobject t         


        
相关标签:
1条回答
  • 2020-12-22 14:35

    The error base operand of '->' has non-pointer type indicates that you should be using . instead of ->.

    So whether you use (*env).NewByteArray(env, 16); or env->NewByteArray(env, 16);. This is the same for line 216.

    You also have another error at the following line (215) saying cannot convert "brace-enclosed initializer list>" to 'jbyte*' in assignment, because the brace syntax for assignment is only valid where you declare the array/pointer (and I think it depends on the compiler too, but I'm not that sure).

    You should try with:

    jbyte resultType[16] = {52, 14, 25, 32, 75, 83, 35, 89, 40, 69, 35, 73, 84, 82, 35, 30};
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题