Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

JNI error with JDK1.5

Thread view: 
jobs239@hotmail.com - 11 Aug 2006 18:22 GMT
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);
Gordon Beaton - 11 Aug 2006 18:41 GMT
> 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

Signature

[ don't email me support questions or followups ]
g o r d o n  +  n e w s  @  b a l d e r 1 3 . s e



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.