What's “Method Signature” parameter when calling a Java method using JNI?

ぃ、小莉子 提交于 2019-12-31 05:43:05

问题


I want to call an Android Java method using JNI in Qt. There is a weird "Method Signature" parameter that I cannot understand. What's this and how should I set it?

In examples it's something like (II)I or (I)I. What does it mean?

For example:

jint max = QAndroidJniObject::callStaticMethod<jint>("java/lang/Math", "max", "(II)I", a, b);

回答1:


It is all explained in the docs. http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html

Type Signature   Java Type
Z                boolean
B                byte
C                char
S                short
I                int
J                long
F                float
D                double
L fully-qualified-class ;   fully-qualified-class
[ type           type[]
( arg-types ) ret-type method type

Your (II)I is a method taking two integers as arguments and returning an int. E.g. int m(int i, int j).

A method void print(String message) would be (Ljava/lang/String;)



来源:https://stackoverflow.com/questions/30815284/whats-method-signature-parameter-when-calling-a-java-method-using-jni

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!