JNI error with JDK1.5

J

jobs239

I have a C++ program that calls into JAVA through JNI interface.
With jdk1.4.2 it works fine, with JDK 1.5 it hangs and if I put
Xcheck:jni, I get the error
FATAL ERROr in native method : wrong object class or method id passed
to JNI call with both JDKs. Can someone help me debug this problem.

at the line CallObjectMethod

Here's the code snippet:

jclass cls = env->FindClass("myclass");
jmethodID mid = env->GetMethodID(cls, "getdata",
"(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/Object;");
jstring jcon = env->NewStringUTF(iStr);
jstring jwork = env->NewStringUTF(wStr);
jobject jo = env->CallObjectMethod(cls,mid,1,jcon, jwork);
 
G

Gordon Beaton

jclass cls = env->FindClass("myclass");
jmethodID mid = env->GetMethodID(cls, "getdata",
"(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/Object;");
jstring jcon = env->NewStringUTF(iStr);
jstring jwork = env->NewStringUTF(wStr);
jobject jo = env->CallObjectMethod(cls,mid,1,jcon, jwork);

You're attempting to calling the method on the class (as though it
were static), but you need an object instance instead.

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top