我尝试用cpp代码调用java方法:
在cpp代码中:
jclass m_cls = env->FindClass("icm/bdroid/jni/Element");
jmethodID m_mid_addElement = env->GetMethodID(m_cls,"AddElement","(icm/bdroid/jni/Element:)V");
Java代码:
public void AddElement(Element e) {
获取以下例外:
12-07 04:21:00.051:W / dalvikvm(31880):Bogus方法描述符: (ICM / bdroid / JNI /元素:)V
12-07 04:21:00.051:W / dalvikvm(31880):Bogus方法描述符: (ICM / bdroid / JNI /元素:)V
12-07 04:21:00.051:D / dalvikvm(31880):GetMethodID:找不到方法: Licm / bdroid / JNI /元素; .AddElement:(ICM / bdroid / JNI /元素:)V
12-07 04:21:00.051:W / dalvikvm(31880):JNI警告:调用JNI方法 提出异常
12-07 04:21:00.051:W / dalvikvm(31880):in Licm / bdroid / jni / Jni; .parseScore(J)Licm / bdroid / jni / Element; (NewObjectV的)
答案 0 :(得分:3)
我认为应该是:
env->GetMethodID(m_cls,"AddElement","(Licm/bdroid/jni/Element;)V");
答案 1 :(得分:0)
检查"类型签名" https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html
的部分L完全合格的班级;完全合格的类
答案 2 :(得分:0)
获取方法签名的一种简单方法是javap实用程序:
javap -cp your.jar -s fully.qualified.class.Name