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

  • SEARCH
  • Home
  • 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 8079901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:15:30+00:00 2026-06-05T16:15:30+00:00

I have a problem with something that otherwise seems to be an easy task.

  • 0

I have a problem with something that otherwise seems to be an easy task.
I have a native method which returns a jobjectArray of instances of a Java class (custom).
What I do is get the jclass for my class I want to instantiate and return and then get the jmethodID for it’s constructor.

The native method’s signature is:

JNIEXPORT jobjectArray JNICALL
Java_com_mn_rootscape_utils_NativeMethods_getFilesPermissions( JNIEnv* env, jobject thizz, jobjectArray filePathsArray ) 

The namespace and constructor signature are defined as follows:

const char* kFilePermissionInfoPath = "com/mn/rootscape/utils/FilePermissionInfo";
const char* kFilePermInfoConstructorSig = "(IIIIIJJJLjava/lang/String;Ljava/lang/String;ZLjava/lang/String;)V";

For the jclass and jmethodID I’m following the instructions posted here. So I’m getting their global references so I can use them later.
Please note that I do not have an oninit in my lib yet, the code is just for testing for now.

The problem is that I get a segmentation fault when I try to retrieve the global reference for the jmethodID.

The code that does this is:

jclass filePermInfoCls = (*env)->FindClass(env, kFilePermissionInfoPath);
if(!filePermInfoCls)
{
    LOGE("getFilesPermissions: failed to get class reference.");
    return NULL;
}

gFilePermInfoClass = (jclass)(*env)->NewGlobalRef(env, filePermInfoCls);
LOGI("got gFilePermInfoClass");

jmethodID filePermInfoClsConstructor = (*env)->GetMethodID(env, gFilePermInfoClass, "<init>", kFilePermInfoConstructorSig1);
if(!filePermInfoClsConstructor)
{
    LOGE("getFilesPermissions: failed to get method reference.");
    return NULL;
}

gFilePermInfoClsConstructor = (jmethodID)(*env)->NewGlobalRef(env, filePermInfoClsConstructor);
LOGI("got gFilePermInfoClsConstructor");

The actual error is:

06-14 09:17:26.648: W/dalvikvm(26012): Invalid indirect reference
0x4c0bdc40 in decodeIndirectRef 06-14 09:17:26.648: E/dalvikvm(26012):
VM aborting

gFilePermInfoClass and gFilePermInfoClsConstructor are global jclass and jmethodID objects, to hold the global refs.

Any help in this would be appreciated.

Thanks

  • 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-05T16:15:32+00:00Added an answer on June 5, 2026 at 4:15 pm

    A jmethodID is not an object. You don’t need to convert it to a GlobalRef. Ditto jfieldID.

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

Sidebar

Related Questions

I have a problem that seems so senseless that I'm sure I'm missing something
I have found that I have no problem using require to load something like
I need to use something like get_or_create() but the problem is that I have
My maze generator seems to have a problem. I am trying to generate something
I am somewhat new to jQuery and I have a problem with something I
Problem -- I have something like the following entries, 1000 of them: args1=msg args2=flow
So i have a problem with mysqls match against. I need to do something
Probably something simple, but heres my problem, I have implememnted a simple captcha into
I've run into a problem which seems troubling to me. It seems I've found
I have a simple search form that looks something like: app/views/search/index.html.erb <%= form_for @search,

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.