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 9205635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:59:44+00:00 2026-06-17T23:59:44+00:00

I am having a hard time finding an answer to this. But, what is

  • 0

I am having a hard time finding an answer to this. But, what is “jboject thiz” used for in JNI function calls? For example:

jobjectArray Java_com_gnychis_awmon_Test( JNIEnv* env, jobject thiz ) {

I use env to allocate objects often, but I’ve never used thiz and I’m not sure what it is for. Just for knowledge purposes.

  • 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-06-17T23:59:45+00:00Added an answer on June 17, 2026 at 11:59 pm

    The following is a JNI wrapper function which has two parameters, and returns a primitive array of objects:

    jobjectArray Java_com_gnychis_awmon_Test( JNIEnv* env, jobject thiz );
    

    From the function name you have given I don’t think it is complete, that is, you haven’t respected the obligatory function name convention which is:

    1. Start the function with Java_

    2. Append the package name separated by _ (undescores) i.e. com_company_awesomeapp. So far the function name is composed of: Java_com_company_awesomeapp

    3. Append the Java class name where the native method has been defined,
      followed by the actual function name. So at this point we should have the following function name: Java_com_company_awesomeapp_MainActivity_Test

    The first parameter is a pointer to a structure storing all JNI function pointers, i.e. all the predefined functions you have available after you #include <jni.h>.

    The second parameter is a reference to the Java object inside which this native method has been declared in. You can use it to call the other methods of the Java object from the current JNI function, i.e. Call Java instance methods from JNI code written in C or C++.

    If for example you have the following Java class inside the MainActivity.java file:

    public class MainActivity extends Activity
    {
        static
        {
            try
            {
                System.loadLibrary("mynativelib");
            }
            catch (UnsatisfiedLinkError ule)
            {
                Log.e(TAG, "WARNING: Could not load native library: " + ule.getMessage());
            }
        }
    
        public static native Object[] Test();
    }
    

    Then, the jobject thiz parameter of the JNI function would be a reference to an object of type MainActivity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a hard time finding this answer so I'm hoping you guy can
This is a simple question yet I'm having a hard time finding an answer.
I'm having a really hard time finding an answer for this, with such generic
This seems like such a simple task, but I'm having a hard time finding
I'm having a hard time finding an updated answer for this. So far I've
I'm having a hard time finding and answer to this. If I had to
I'm very new to PHP and having a hard time finding this answer as
Sorry for the simple question, but I'm having a hard time finding the answer.
I know this is simple but am having a hard time finding the right
I am working through the AHK docs but am having a hard time finding

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.