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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:18:35+00:00 2026-05-25T15:18:35+00:00

My JAVA class code snippet .I want to access getReg_chal() method from my C

  • 0

My JAVA class code snippet .I want to access getReg_chal() method from my C file using JNI:

public char[] getReg_chal() {
        return reg_chal;
    }

My C file doing some jni operation:

mid = (*env)->GetMethodID(env, info, "getReg_chal()", "()I");

mid = (*env)->GetMethodID(env, info, "getReg_chal()", ***);

I want to know the method descriptor for my char[]. Writing “()I” gives me bogus method descriptor error since ()I is used for Int. What would i fill in *.
Please Help me. Thanks in advance.

  • 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-25T15:18:36+00:00Added an answer on May 25, 2026 at 3:18 pm

    The method signature would be “()[C” .

    You can read about the details here and here.

    To call the method using the method id, you’d just write something like

    jobject obj = ... // This is the object you want to call the method on
    jcharArray arr = (jcharArray) (*env)->CallObjectMethod(env, obj, mid);
    int count = (*env)->GetArrayLength(env, arr);
    jchar* chars = (*env)->GetCharArrayElements(env, arr, 0);
    // Here, "chars" is a C pointer to an array of "count" characters. It's NOT
    // going to be 0-terminated, so be careful! Here's where you would do your
    // logging or whatever. One possible way to do this is by turning the `jchar`
    // array into a proper 0-terminated character string:
    char * message = malloc(count + 1);
    memcpy(message, chars, count);
    message[count] = 0;
    LOGD("NDK:LC: [%s]", message);
    
    // When you're done you must call this!
    (*env)->ReleaseCharArrayElements(env, arr, chars, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My JAVA class code snippet. I want to access getReg_chal() method from my C
Using Eclipse I want to view the source code for a core Java class
Let's say I have some Java code: public class SomeClass { static { private
Let's assume we've got the following Java code: public class Maintainer { private Map<Enum,
When the Java compiler autoboxes a primitive to the wrapper class, what code does
On a question for Java at the university, there was this snippet of code:
I've got the following code for a file upload with Apache's HTTP-Client (org.apache.http.client): public
I am executing scala code snippets using scala.tools.nsc.Interpreter When the code snippet is correct,
Java .class files can be decompiled fairly easily. How can I protect my database
The RFC for a Java class is set of all methods that can be

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.