What is the 'correct' way to store a native pointer inside a Java object?

后端 未结 6 1669
南方客
南方客 2020-11-30 06:38

What is the \'correct\' way to store a native pointer inside a Java object?

I could treat the pointer as a Java int, if I happen to know that native poi

6条回答
  •  独厮守ぢ
    2020-11-30 07:16

    I assume that this is a pointer returned from some JNI code and my advice would be just dont do it :)

    Ideally the JNI code should pass you back some sort of logical reference to the resource and not an actual pointer ?

    As to your question there is nothing that comes to mind about a cleaner way to store the pointer - if you know what you have then use either the int or long or byte[] as required.

提交回复
热议问题