Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7672881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:23:09+00:00 2026-05-31T16:23:09+00:00

I’ve been researching a bit on how to make JNI calls from C++ to

  • 0

I’ve been researching a bit on how to make JNI calls from C++ to Java, and so far I haven’t had any issue, I managed to call almost any type of function.
I say ALMOST, because right now I’m facing this situation:

In Java, I have this function:

public static Object getJObject(int id){
    Object st = null;
    switch (id){
        case 0: st = "hello"; break;
        case 1: st = "bye"; break;
        case 2: st = 1; break;
        case 3: st = 2; break;
        case 4: st = 3; break;
    }
    return st;
}

As you can see, this function returns a different type of value given the ID received as a parameter.

The problem comes when trying to get that object from C++. Here’s the function that makes the JNI call:

bool check(){
    JniMethodInfo methodInfo;
    jobject jobj;

    bool b = getStaticMethodInfo(methodInfo, "org.example.act.activity", "getJObject", "()Ljava/lang/Object;");

    if (!b){
        CCLog("getJObject method not found");
        return false;
    }else{
        jobj = methodInfo.env->CallStaticObjectMethod(methodInfo.classID, methodInfo.methodID, 0);
        return true;
    }
}

NOTE: (Although I think it is obvious) note that the
getStaticMethodInfo method sets the whole process of identifying a method in a Java class. It works with every other function that I
call, except for this one.

That’s the only thing that I want to do…I’m pretty sure it’s something about the signature specifying the type of method it is, but maybe I’m wrong.
So far I’ve found answered questions about getting a class object or strings, but I haven’t found anything on a proper Java Object…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:23:11+00:00Added an answer on May 31, 2026 at 4:23 pm

    The signature that you are providing to getStatiticMethodInfo does not match the method. For a method that takes an int argument and returns an Object, the signature should be: (I)Ljava/lang/Object;

    IIRC, the method signature syntax is described in a couple of places including:

    • the JNI specification, and
    • the JVM specification
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.