JNI GetMethodID always return zero

K

Kiran

Hi,

What could be the possible reason behind GetMethodID call failure?
What wrong with following code...

jclass resourceClass = env->FindClass( "java/util/ResourceBundle" );
jmethodID mid = env->GetStaticMethodID( resourceClass,
"getBundle",
"(Ljava/lang/String;Ljava/util/Locale;Ljava/lang/ClassLoader;)Ljava/util/ResourceBundle");

FindClass works ok, so I assume VM is initialized well, but I might be
wrong?

Platform: Windows, JDK 1.4.

Thanks,
Kiran
 
K

Kevin McMurtrie

Hi,

What could be the possible reason behind GetMethodID call failure?
What wrong with following code...

jclass resourceClass = env->FindClass( "java/util/ResourceBundle" );
jmethodID mid = env->GetStaticMethodID( resourceClass,
"getBundle",
"(Ljava/lang/String;Ljava/util/Locale;Ljava/lang/ClassLoader;)Ljava/util/Resou
rceBundle");

FindClass works ok, so I assume VM is initialized well, but I might be
wrong?

Platform: Windows, JDK 1.4.

Thanks,
Kiran

Making JNI signatures is a hassle. Try using reflection to get that
Method in Java and then call toString() on it. If I recall correctly,
the signature is the same as used by JNI.
 
C

Chris Uppal

Kevin said:
Try using reflection to get that
Method in Java and then call toString() on it. If I recall correctly,
the signature is the same as used by JNI.

Unfortunately not. At least in 1.4.2, that returns a Java-style declaration.
That feature (or something like, say, getJNIString()) would be very handy,
though.

-- chris
 
K

Kiran

Resolved!

Problem in following code was due to incorrect signature for return value...
 

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

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top