Overloading JNI methods

Discussion in 'Java' started by Christian Meier, Oct 21, 2005.

  1. 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
     
    Christian Meier, Oct 21, 2005
    #1
    1. Advertising

  2. On Fri, 21 Oct 2005 17:28:12 +0200, Christian Meier wrote:
    > 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

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
     
    Gordon Beaton, Oct 21, 2005
    #2
    1. Advertising

  3. Christian Meier

    Roedy Green Guest

    On Fri, 21 Oct 2005 17:28:12 +0200, "Christian Meier" <>
    wrote or quoted :

    >jbyte bInByte, jshort sInShort, jstring lsInString)". Now the
    >problem: I can't figure out what the argument descriptor for the
    >parameter-type "jobject" is.



    You don't have to. Just run javah and look at the resulting *.h file.

    Am I misinterpreting your question?

    See http://mindprod.com/jgloss/jni.html

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
     
    Roedy Green, Oct 22, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley

    IBM's JNI fails where Sun's JNI works

    Alex Hunsley, Nov 3, 2003, in forum: Java
    Replies:
    4
    Views:
    851
    Alex Hunsley
    Nov 4, 2003
  2. Pasturel Jean-Louis

    Porting JNI Windows under JNI LINUX + Wine ?

    Pasturel Jean-Louis, Feb 29, 2004, in forum: Java
    Replies:
    5
    Views:
    906
    Pasturel Jean-Louis
    Mar 3, 2004
  3. vasanth
    Replies:
    0
    Views:
    2,702
    vasanth
    Jan 25, 2005
  4. vasanth
    Replies:
    0
    Views:
    623
    vasanth
    Jan 25, 2005
  5. Kenneth McDonald
    Replies:
    5
    Views:
    321
    Kenneth McDonald
    Sep 26, 2008
Loading...

Share This Page