Overloading JNI methods

C

Christian Meier

Hi

I hope this post is not off-topic here but I couldn't find a more
appropriate newsgroup.

I want to overload methods in the JNI and have a problem with the method
name which has to be extended with two underscores and the encoded argument
descriptors. Everything works fine when I use parameter like byte, short or
string. With all these parameters my method would be
"Java_jni_MyTestClass_overloadedFunction__BSLjava_lang_String_2(JNIEnv* env,
jobject jObj, jbyte bInByte, jshort sInShort, jstring lsInString)". Now the
problem: I can't figure out what the argument descriptor for the
parameter-type "jobject" is. I tried "Ljava_lang_Object_2" but this didn't
work. I couldn't find samples using jobject parameter in overloaded methods
on the internet and usenet. Can you tell me the argument descriptor for
"jobject"?

Greetings Chris
 
G

Gordon Beaton

I want to overload methods in the JNI and have a problem with the
method name which has to be extended with two underscores and the
encoded argument descriptors. Everything works fine when I use
parameter like byte, short or string. With all these parameters my
method would be
"Java_jni_MyTestClass_overloadedFunction__BSLjava_lang_String_2(JNIEnv*
env, jobject jObj, jbyte bInByte, jshort sInShort, jstring
lsInString)". Now the problem: I can't figure out what the argument
descriptor for the parameter-type "jobject" is. I tried
"Ljava_lang_Object_2" but this didn't work. I couldn't find samples
using jobject parameter in overloaded methods on the internet and
usenet. Can you tell me the argument descriptor for "jobject"?

I'm not sure I understand exactly what you're asking, but don't see
why you can't just declare the various overloaded methods in a Java
class, compile it and run javah to see what names it generates.

Note that you don't actually need to use the names javah suggests if
you use RegisterNatives() to associate your native methods with the
class. RegisterNatives() lets you associate the method signature with
a pointer to a native function, so the actual symbol name becomes
unimportant.

/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

JNI and GetFieldID 12
JNI return jobjectArray 7
JNI generic type of jobject 6
JNI Error in passing array 0
Problem with JNI 7
Trouble with JNI wrapper functions 1
JNI: C vs C++ 2
JNI Invocation API example 4

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top