java接口函数名,Java本机接口方法和模块名称的命名约定是什么?

I am able to follow a jni tutorial just fine. But when I change the method name, I run into trouble. Is there a naming convention I need to follow? The tutorial used HelloJNI as the module name, and library name. I used "useaaacom".

解决方案

Dynamic linkers resolve entries based on their names. A native method name is concatenated from the following components:

the prefix Java_

a mangled fully-qualified class name

an underscore (_) separator

a mangled method name

for overloaded native methods, two underscores (__) followed by the mangled argument signature

So if you have the following:

package com.foo.bar;

class Baz {

public native void Grill(int i);

}

Then the corresponding C function should be:

JNIEXPORT void JNICALL Java_com_foo_bar_Baz_Grill(JNIEnv *env, jobject thiz, jint i);

If you have an underscore in the Java method name:

public native void A_Grill(int i);

Then the C function would be:

JNIEXPORT void JNICALL Java_com_foo_bar_Baz_A_1Grill(JNIEnv *env, jobject thiz, jint i);

The _1 escape sequence matches the _ in A_Grill.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值