How to create an object with JNI?

后端 未结 5 1613
孤独总比滥情好
孤独总比滥情好 2020-12-07 18:37

I need to implement some functions into an Android application using NDK and thus JNI.

Here\'s the C code, with my concerns, that I wrote:

#include &         


        
5条回答
  •  臣服心动
    2020-12-07 19:01

    The specification is correct, but a bit misleading in this case. GetMethodID requires a method name and a method signature. The specification says:

    To obtain the method ID of a constructor, supply as the method name and void (V) as the return type.

    Note that it says return type, not signature. Although void(V) looks superficially similar to a signature, the specification is telling you that the signature must specify a void (that is, V) return type.

    The correct signature for a no-argument constructor is ()V. If the constructor has arguments, they should be described between the parentheses, as other commenters have noted.

提交回复
热议问题