本文介绍了为什么JNI中的GetMethodID函数总是返回0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是C ++代码

below is C++ code

jmethodID mid;
jclass cls = env->FindClass( "test/MyTest");

mid = env->GetMethodID(cls, "append","(Ljava/lang/String;I)Ljava/lang/String;");

mid=env->GetMethodID(cls,"HelloWord","()Ljava/lang/String;");



以下由javap显示



below is display by javap

public test.MyTest(java.lang.String);
  Signature: (Ljava/lang/String;)V
public java.lang.String HelloWord();
  Signature: ()Ljava/lang/String;
public java.lang.String append(java.lang.String, int);
  Signature: (Ljava/lang/String;I)Ljava/lang/String;



下面是Java代码:



below is java code:

public String HelloWord() {
    System.out.println("JAVA-CLASS:MyTest method:HelloWord:" +
helloword);

    return helloword;
}

//test
public String append(String str, int i)
{
    return str + i;
}

推荐答案


这篇关于为什么JNI中的GetMethodID函数总是返回0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 10:21