我试图在Android中调用以下java方法
public static String getLevelFile(String levelName) { /*body*/}
Run Code Online (Sandbox Code Playgroud)
从c ++使用以下jni代码
JniMethodInfoJavaApi methodInfo;
if (! getStaticMethodInfo(methodInfo, "getLevelFile", "(Ljava/lang/String;)Ljava/lang/String;"))
{
return std::string("");
}
LOGD("calling getLevelFile");
jstring returnString = (jstring) methodInfo.env->CallStaticObjectMethod(methodInfo.classID, methodInfo.methodID, levelName.c_str());
LOGD("returned from getLevelFile");
methodInfo.env->DeleteLocalRef(methodInfo.classID);
const char *js = methodInfo.env->GetStringUTFChars(returnString, NULL);
std::string cs(js);
methodInfo.env->ReleaseStringUTFChars(returnString, js);
LOGD("returning Level data");
Run Code Online (Sandbox Code Playgroud)
应用程序在执行此操作时崩溃CallStaticMethodObject().我通过使用验证了方法签名是正确的javap.而LOGD("calling getLevelFile");打印精细,然后它崩溃.我可以CallStaticVoidMethod()从同一个班级做其他的但不是这个.我有什么想法我做错了吗?
我在Java中有以下类
package com.artifex.mupdf.data;
public class FzTextSpan {
FzRect bbox;
int len, cap;
FzTextChar[] mFzTextChars;
public FzTextSpan(FzRect bbox, int len, int cap, FzTextChar[] mFzTextChars) {
super();
this.bbox = bbox;
this.len = len;
this.cap = cap;
this.mFzTextChars = mFzTextChars;
}
}
Run Code Online (Sandbox Code Playgroud)
我试图使用foll代码从JNI调用构造函数
jclass jFzSpanClass;
jmethodID jFzSpanCtor;
jFzSpanClass = (*env)->FindClass(env, "com/artifex/mupdf/data/FzTextSpan");
if (jFzSpanClass==NULL) return NULL;
jFzSpanCtor = (*env)->GetMethodID(env, jFzSpanClass, "<init>",
"(Lcom/artifex/mupdf/data/FzRect;II;[Lcom/artifex/mupdf/data/FzTextChar;)V");
Run Code Online (Sandbox Code Playgroud)
我正进入(状态
Bogus Method Descriptor: "(Lcom/artifex/mupdf/data/FzRect;II;[Lcom/artifex/mupdf/data/FzTextChar;)V");
Run Code Online (Sandbox Code Playgroud)