Description of the Android JNI Getfieldid and Getmethodid functions

Source: Internet
Author: User

description of the Android JNI Getfieldid and Getmethodid functions

Getfieldid is to get the parameters in the Java class Id,getmethodid get the IDs of the methods in the Java class, which can only invoke parameters or methods declared as public in the class. Use the following:Jfieldid Topicfieldid= env->getfieldid(ObjectClass,"Name","Ljava/lang/string;");
Jmethodid Getcname=env (Objectclass "Getcatname" , "() ljava/lang/string;" ;

< BR style= "Line-height:normal; Word-wrap:break-word; " >

The first parameter is a Java class object. The second parameter is the parameter (or method name), and the third parameter is the signature of the parameter (or method). The third parameter is obtained by the following method.

For example:

Class

Public class Cat{

Private intCatnumber;
String CatName;

PublicCat(intIString Name)
{Catnumber=i; catname=name;}
PublicString Getcatname()
{return This.CatName;}
PublicvoidSetcatname(String CatName)
{ This.=catname}
}

For example, view The Cat class enters the cat's directory with Javac Cat.java to compile and then enter the command:
javap–s cat
The signature of the Cat Method Getcatname is () the parameter in the Ljava/lang/string,cat class is private so it has no signature.

Description of the Android JNI Getfieldid and Getmethodid functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.