JNI: Passing multiple parameters in the function signature for GetMethodID

本文解答了如何在JNI中正确地定义包含多个整型参数的Java方法签名的问题。通过具体的例子,解释了正确的方法签名应该为(III)V,并澄清了在不同情况下的参数分隔符使用方法。

http://stackoverflow.com/questions/7940484/jni-passing-multiple-parameters-in-the-function-signature-for-getmethodid

ASK :

I am trying to execute a function in Java (from C) that has the following signature:

public void execute(int x, int y, int action);
My problem is to define the function signature in GetMethodID:

env->GetMethodID(hostClass, "execute", "(I;I;I;)V");
The problem I ma getting is:

W/dalvikvm( 1849): Bogus method descriptor: (I;I;I;)V
W/dalvikvm( 1849): Bogus method descriptor: (I;I;I;)V
D/dalvikvm( 1849): GetMethodID: method not found: Lcom/device/client/HostConnection;.execute:(I;I;I;)V

I am not sure how to specify the method signature in GetMethodID (for 3 integers as parameters). I saw people use the ";" to separate parameters in other posts for the String and File class, but nothing with primitives like integer.
What would be the correct way to do this please? Thank you.

ANSWER:

According to this file you should use (III)V signature. Only when you need to specify fully qualified class you should use ';', like Ljava/lang/String;.

 

http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/types.html#wp276

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值