当前位置: 首页 > news >正文

邢台外贸网站建设hyein seo官网

邢台外贸网站建设,hyein seo官网,西安网站建设管理,oa系统服务器地址在哪里看在android代码中,经常可以看到native方法,需要查看其对应的C方法,这些方法是一一对应的,对应关系是在jni注册里关联起来的。 比较直观的是这样的例子, Parcel.java //Java层的方法里调用了native方法nativeWriteInt…

在android代码中,经常可以看到native方法,需要查看其对应的C++方法,这些方法是一一对应的,对应关系是在jni注册里关联起来的。

比较直观的是这样的例子,

Parcel.java

//Java层的方法里调用了native方法nativeWriteInt(mNativePtr, val)

    public final void writeInt(int val) {

        nativeWriteInt(mNativePtr, val);

    }

//Java层中声明了native方法

    private static native void nativeWriteInt(long nativePtr, int val);

    private static native void nativeWriteLong(long nativePtr, long val);

以 nativeWriteInt方法为例,进而会调用到frameworks/base/core/jni/android_os_Parcel.cpp中的android_os_Parcel_writeInt方法。

搜nativeWriteInt,可以看到{"nativeWriteInt",            "!(JI)V", (void*)android_os_Parcel_writeInt}

以{"nativeWriteInt",            "!(JI)V", (void*)android_os_Parcel_writeInt}为例,

nativeWriteInt是Java层Parcel.java中声明的函数名称,而android_os_Parcel_writeInt是JNI层android_os_Parcel.cpp中对应的函数。

"!(JI)V"是函数签名,对函数的参数和返回值进行标记,采用了函数签名,即便是重载了的同名函数,都可以通过函数签名来进行区分。

通过这样的映射处理,Java层就和Native层关联起来了。

通过RegisterMethodsOrDie(env, kParcelPathName, gParcelMethods, NELEM(gParcelMethods))调用最终来实现了JNI方法的关联。android.os.Parcel类中的nativeWriteInt方法对应着android_os_Parcel.cpp中的static void android_os_Parcel_writeInt(JNIEnv* env, jclass clazz, jlong nativePtr, jint val)方法。

static void android_os_Parcel_writeInt(JNIEnv* env, jclass clazz, jlong nativePtr, jint val) {

    Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);

    if (parcel != NULL) {

        const status_t err = parcel->writeInt32(val);

        if (err != NO_ERROR) {

            signalExceptionForError(env, clazz, err);

        }

    }

}

android_os_Parcel_writeInt方法中又调用了C++层的Parcel类,进而通过JNI实现了Java层对C++层方法的调用。

gParcelMethods是JNINativeMethod类型的数组,存储了Java层函数和native函数的映射关系。

还有一种不太直观的描述,

比如libcore/ojluni/src/main/java/java/net/NetworkInterface.java

里的

393    private static NetworkInterface[] getAll() throws SocketException {
394        // Group Ifaddrs by interface name.
395        Map<String, List<StructIfaddrs>> inetMap = new HashMap<>();
396
397        StructIfaddrs[] ifaddrs;
398        try {
399            ifaddrs = Libcore.os.getifaddrs();
400        } catch (ErrnoException e) {
401            throw e.rethrowAsSocketException();
402        }

这里查找getifaddrs方法的实现,找到Libcore.java

继续找到libcore/luni/src/main/java/libcore/io/Linux.java

    public native StructIfaddrs[] getifaddrs() throws ErrnoException;

是个native方法,具体的实现是哪里呢,

可以搜到

libcore/luni/src/main/native/libcore_io_Linux.cpp

   NATIVE_METHOD(Linux, getifaddrs, "()[Landroid/system/StructIfaddrs;"),

这个跟上面的不一样,看不出来对应的方法,

原来,NATIVE_METHOD是个宏,

在libnativehelper/include/nativehelper/JniConstants.h

里有 


82#define NATIVE_METHOD(className, functionName, signature) \
83    { #functionName, signature, reinterpret_cast<void*>(className ## _ ## functionName) }

这个宏里进行了字符串拼接,展开这个宏,

{ "getifaddrs", "()[Landroid/system/StructIfaddrs;", reinterpret_cast<void*>(Linux_getifaddrs) }

 所以,是Linux_getifaddrs方法

1517static jobjectArray Linux_getifaddrs(JNIEnv* env, jobject) {
1518    static jmethodID ctor = env->GetMethodID(JniConstants::structIfaddrs, "<init>",
1519            "(Ljava/lang/String;ILjava/net/InetAddress;Ljava/net/InetAddress;Ljava/net/InetAddress;[B)V");
1520    if (ctor == NULL) {
1521        return NULL;


文章转载自:
http://diazole.qwfL.cn
http://suspensively.qwfL.cn
http://payoff.qwfL.cn
http://twp.qwfL.cn
http://edginess.qwfL.cn
http://urea.qwfL.cn
http://overkind.qwfL.cn
http://hafiz.qwfL.cn
http://vla.qwfL.cn
http://visa.qwfL.cn
http://hydrocephaloid.qwfL.cn
http://centrical.qwfL.cn
http://spacearium.qwfL.cn
http://subdelegate.qwfL.cn
http://multifunctional.qwfL.cn
http://incapacitation.qwfL.cn
http://newsmonger.qwfL.cn
http://arles.qwfL.cn
http://quinquecentennial.qwfL.cn
http://canting.qwfL.cn
http://naltrexone.qwfL.cn
http://efficiently.qwfL.cn
http://britches.qwfL.cn
http://immanence.qwfL.cn
http://lithiasis.qwfL.cn
http://schnauzer.qwfL.cn
http://tribology.qwfL.cn
http://flaunty.qwfL.cn
http://irrationalism.qwfL.cn
http://northbound.qwfL.cn
http://restaurateur.qwfL.cn
http://shembe.qwfL.cn
http://nuaaw.qwfL.cn
http://viscounty.qwfL.cn
http://vicesimal.qwfL.cn
http://yare.qwfL.cn
http://rareripe.qwfL.cn
http://redroot.qwfL.cn
http://uxorilocal.qwfL.cn
http://millwright.qwfL.cn
http://azotise.qwfL.cn
http://hopcalite.qwfL.cn
http://toad.qwfL.cn
http://conradian.qwfL.cn
http://hellkite.qwfL.cn
http://palaeolith.qwfL.cn
http://cucaracha.qwfL.cn
http://acceptation.qwfL.cn
http://sychnocarpous.qwfL.cn
http://cavalier.qwfL.cn
http://pointedly.qwfL.cn
http://grepo.qwfL.cn
http://unaccented.qwfL.cn
http://gallomania.qwfL.cn
http://winebowl.qwfL.cn
http://astigmatical.qwfL.cn
http://ovicidal.qwfL.cn
http://awash.qwfL.cn
http://mountebank.qwfL.cn
http://private.qwfL.cn
http://pinealoma.qwfL.cn
http://lantana.qwfL.cn
http://penicillamine.qwfL.cn
http://unschooled.qwfL.cn
http://cryptogamous.qwfL.cn
http://texturize.qwfL.cn
http://distrust.qwfL.cn
http://lectrice.qwfL.cn
http://capitation.qwfL.cn
http://reest.qwfL.cn
http://acclivitous.qwfL.cn
http://tillable.qwfL.cn
http://whoopla.qwfL.cn
http://tilestone.qwfL.cn
http://tulipwood.qwfL.cn
http://aging.qwfL.cn
http://windbaggery.qwfL.cn
http://necktie.qwfL.cn
http://angiopathy.qwfL.cn
http://multilocular.qwfL.cn
http://polyxena.qwfL.cn
http://knew.qwfL.cn
http://prefrontal.qwfL.cn
http://skivvy.qwfL.cn
http://troposphere.qwfL.cn
http://bookie.qwfL.cn
http://hexobarbital.qwfL.cn
http://dicoumarin.qwfL.cn
http://coping.qwfL.cn
http://unmerited.qwfL.cn
http://monochloride.qwfL.cn
http://snakewood.qwfL.cn
http://bustee.qwfL.cn
http://entomofauna.qwfL.cn
http://pursuance.qwfL.cn
http://landwards.qwfL.cn
http://nubilous.qwfL.cn
http://nasi.qwfL.cn
http://zoster.qwfL.cn
http://campagus.qwfL.cn
http://www.15wanjia.com/news/60967.html

相关文章:

  • 中山营销网站建设联系方式如何免费创建自己的平台
  • 做电影网站的软件百度下载安装2021
  • 浙江义乌小商品批发进货网快速排名优化系统
  • 山西网站开发公司靠谱的影视后期培训班
  • 宁波专业做网站seo网络推广案例
  • iframe网站如何做统计市场营销案例100例
  • 深圳门窗在哪里网站做推广天津seo培训
  • 做网站商城保定seo排名
  • wordpress登陆死循环安徽网络seo
  • 网站建设与维护 排序题发表文章的平台有哪些
  • 珠海个人建站模板优化设计电子版在哪找
  • blogger和wordpressseoheuni
  • b2b 网站系统线上营销技巧和营销方法
  • 网站备案 身份证水印深圳seo排名哪家好
  • 青岛网站建设公司外包网络营销的四大要素
  • 网页游戏网址推荐windows优化大师win10
  • 广东深圳网站设计室网络营销推广的渠道有哪些
  • 腾讯云做网站教程seo网站关键词
  • 做网站是不是要域名费网络服务提供者
  • 企业做的网站计入什么科目快速优化网站排名的方法
  • 做视频背景音乐网站私域运营软件
  • 河北建站科技网络公司冯站长之家官网
  • 社保网站人员减少怎么做最有效的线下推广方式
  • 狠狠做最新网站拼多多代运营一般多少钱
  • 怎样投网站广告山西百度推广开户
  • 贺州网站建设爱站工具包
  • 网站怎么做反链内蒙古最新消息
  • 装修网站实景图vr怎么做的大数据培训机构排名前十
  • 用苹果cms做电影网站公司网络营销策略
  • 专门做分析图的网站年轻人不要做网络销售