android – Jni 介面函數表

來源:互聯網
上載者:User

typedef const struct JNINativeInterface *JNIEnv;

const struct JNINativeInterface ... = {

    NULL, 
    NULL, 
    NULL, 
    NULL, 
    GetVersion,             //擷取JNI版本號碼

    DefineClass,             //通過指定ClassLoader對象載入類
    FindClass,             //擷取指定的Class類對象

    FromReflectedMethod,    //通過指定的java.lang.reflect.Method對象擷取方法ID
    FromReflectedField,    //通過指定的java.lang.reflect.Field對象擷取欄位ID
    ToReflectedMethod,    //通過指定的方法ID擷取java.lang.reflect.Method對象

    GetSuperclass,         //擷取指定類的父類
    IsAssignableFrom,         //判斷指定類是否繼承自某類或實現了某個介面

    ToReflectedField,         //通過指定的欄位ID擷取java.lang.reflect.Field對象

    Throw,                 //拋出指定的Throwable對象
    ThrowNew,             //拋出指定的Throwable對象,並制定訊息
    ExceptionOccurred,     //擷取未被清空或捕獲的異常
    ExceptionDescribe,     //同printStackTrace()
    ExceptionClear,         //清除已被拋出的異常
    FatalError,             //拋出致命錯誤

    PushLocalFrame,   //Push/PopLocalFrame函數提供了本地引用管理的簡便方法,在該函數對之間的程式碼片段,所有建立的顯式本地引用無需手動調用DeleteLocalReference函數釋放,PopLocalFrame函數會自動釋放這些本地引用
    PopLocalFrame, 

    NewGlobalRef,         //建立全域引用,必須被顯式清除
    DeleteGlobalRef,         //清除全域引用
    DeleteLocalRef,         //清除本地引用,通常本地引用在原生代碼返回時會自動清除,但是對於大資料,比如在迴圈中頻繁建立Java對象,而該對象的只在一次迴圈中有效,這種情況下有必要顯式調用DeleteLocalRef以通知VM儘快釋放該對象。
    IsSameObject,         //判斷是否為同一對象,可通過該方法判斷弱引用是否已被釋放(NULL)
    NewLocalRef,             //建立本地引用
    EnsureLocalCapacity,     //確保當前線程可以建立指定數量的本地引用

    AllocObject,             //建立一個新的對象,只分配記憶體,不調用任何構造方法(cdwang:應該是為了方便通過CallNonvirtual<Type>Method方法調用父類的建構函式初始化對象)
    NewObject,             //通過指定的建構函式建立對象,變長參數形式
    NewObjectV,             //同上,va_list形式
    NewObjectA,             //同上,數組形式

    GetObjectClass,         //擷取對象的Class類對象
    IsInstanceOf,             //同instanceOf

    GetMethodID,         //擷取執行個體(非靜態)方法的ID

    CallObjectMethod,     //調用執行個體方法,object表示傳回值類型
    CallObjectMethodV, 
    CallObjectMethodA, 
    CallBooleanMethod, 
    CallBooleanMethodV, 
    CallBooleanMethodA, 
    CallByteMethod, 
    CallByteMethodV, 
    CallByteMethodA, 
    CallCharMethod, 
    CallCharMethodV, 
    CallCharMethodA, 
    CallShortMethod, 
    CallShortMethodV, 
    CallShortMethodA, 
    CallIntMethod, 
    CallIntMethodV, 
    CallIntMethodA, 
    CallLongMethod, 
    CallLongMethodV, 
    CallLongMethodA, 
    CallFloatMethod, 
    CallFloatMethodV, 
    CallFloatMethodA, 
    CallDoubleMethod, 
    CallDoubleMethodV, 
    CallDoubleMethodA, 
    CallVoidMethod, 
    CallVoidMethodV, 
    CallVoidMethodA, 

    CallNonvirtualObjectMethod, //調用非虛執行個體方法,通過class對象指定調用哪個類的非虛函數(cdwang:應該是某對象不調用自己的構造類的方法實現,而是調用父類的方法實現,這個方法節省了子類對象向父類對象的強制轉換)
    CallNonvirtualObjectMethodV, 
    CallNonvirtualObjectMethodA, 
    CallNonvirtualBooleanMethod, 
    CallNonvirtualBooleanMethodV, 
    CallNonvirtualBooleanMethodA, 
    CallNonvirtualByteMethod, 
    CallNonvirtualByteMethodV, 
    CallNonvirtualByteMethodA, 
    CallNonvirtualCharMethod, 
    CallNonvirtualCharMethodV, 
    CallNonvirtualCharMethodA, 
    CallNonvirtualShortMethod, 
    CallNonvirtualShortMethodV, 
    CallNonvirtualShortMethodA, 
    CallNonvirtualIntMethod, 
    CallNonvirtualIntMethodV, 
    CallNonvirtualIntMethodA, 
    CallNonvirtualLongMethod, 
    CallNonvirtualLongMethodV, 
    CallNonvirtualLongMethodA, 
    CallNonvirtualFloatMethod, 
    CallNonvirtualFloatMethodV, 
    CallNonvirtualFloatMethodA, 
    CallNonvirtualDoubleMethod, 
    CallNonvirtualDoubleMethodV, 
    CallNonvirtualDoubleMethodA, 
    CallNonvirtualVoidMethod, 
    CallNonvirtualVoidMethodV, 
    CallNonvirtualVoidMethodA, 

    GetFieldID,             //擷取成員欄位ID

    GetObjectField,         //擷取欄位值
    GetBooleanField, 
    GetByteField, 
    GetCharField, 
    GetShortField, 
    GetIntField, 
    GetLongField, 
    GetFloatField, 
    GetDoubleField, 
    SetObjectField,         //設定欄位值
    SetBooleanField, 
    SetByteField, 
    SetCharField, 
    SetShortField, 
    SetIntField, 
    SetLongField, 
    SetFloatField, 
    SetDoubleField, 

    GetStaticMethodID,     //擷取靜態方法ID

    CallStaticObjectMethod, //調用靜態方法
    CallStaticObjectMethodV, 
    CallStaticObjectMethodA, 
    CallStaticBooleanMethod, 
    CallStaticBooleanMethodV, 
    CallStaticBooleanMethodA, 
    CallStaticByteMethod, 
    CallStaticByteMethodV, 
    CallStaticByteMethodA, 
    CallStaticCharMethod, 
    CallStaticCharMethodV, 
    CallStaticCharMethodA, 
    CallStaticShortMethod, 
    CallStaticShortMethodV, 
    CallStaticShortMethodA, 
    CallStaticIntMethod, 
    CallStaticIntMethodV, 
    CallStaticIntMethodA, 
    CallStaticLongMethod, 
    CallStaticLongMethodV, 
    CallStaticLongMethodA, 
    CallStaticFloatMethod, 
    CallStaticFloatMethodV, 
    CallStaticFloatMethodA, 
    CallStaticDoubleMethod, 
    CallStaticDoubleMethodV, 
    CallStaticDoubleMethodA, 
    CallStaticVoidMethod, 
    CallStaticVoidMethodV, 
    CallStaticVoidMethodA, 

    GetStaticFieldID,         //擷取靜態欄位ID

    GetStaticObjectField,     //擷取欄位值
    GetStaticBooleanField, 
    GetStaticByteField, 
    GetStaticCharField, 
    GetStaticShortField, 
    GetStaticIntField, 
    GetStaticLongField, 
    GetStaticFloatField, 
    GetStaticDoubleField, 

    SetStaticObjectField,     //設定欄位值
    SetStaticBooleanField, 
    SetStaticByteField, 
    SetStaticCharField, 
    SetStaticShortField, 
    SetStaticIntField, 
    SetStaticLongField, 
    SetStaticFloatField, 
    SetStaticDoubleField, 

    NewString,             //通過指定Unicode格式字元數組構造Java String

    GetStringLength,         //擷取Unicode字元的長度
    GetStringChars,         //擷取字元數組
    ReleaseStringChars,     //通知VM可以釋放String和由GetStringChars擷取的字元數組
 
    NewStringUTF,         //通過指定UTF-8格式字元數組構造Java String
    GetStringUTFLength, 
    GetStringUTFChars, 
    ReleaseStringUTFChars, 
 
    GetArrayLength,         //擷取數組長度
  
    NewObjectArray,         //通過指定的Class類對象和初始元素初始化一個Java對象數組
    GetObjectArrayElement,    //擷取指定索引的對象元素
    SetObjectArrayElement,    //設定指定索引的對象元素
 
    NewBooleanArray,     //構造基本類型的Java數組
    NewByteArray, 
    NewCharArray, 
    NewShortArray, 
    NewIntArray, 
    NewLongArray, 
    NewFloatArray, 
    NewDoubleArray, 
 
    GetBooleanArrayElements,    //擷取基本類型元素的C數組
    GetByteArrayElements, 
    GetCharArrayElements, 
    GetShortArrayElements, 
    GetIntArrayElements, 
    GetLongArrayElements, 
    GetFloatArrayElements, 
    GetDoubleArrayElements, 
 
    ReleaseBooleanArrayElements,    //通知VM可以釋放Java數組和由前述方法族擷取的C數組
    ReleaseByteArrayElements, 
    ReleaseCharArrayElements, 
    ReleaseShortArrayElements, 
    ReleaseIntArrayElements, 
    ReleaseLongArrayElements, 
    ReleaseFloatArrayElements, 
    ReleaseDoubleArrayElements, 
 
    GetBooleanArrayRegion,    //擷取子數組
    GetByteArrayRegion, 
    GetCharArrayRegion, 
    GetShortArrayRegion, 
    GetIntArrayRegion, 
    GetLongArrayRegion, 
    GetFloatArrayRegion, 
    GetDoubleArrayRegion, 
    SetBooleanArrayRegion,    //設定子數組
    SetByteArrayRegion, 
    SetCharArrayRegion, 
    SetShortArrayRegion, 
    SetIntArrayRegion, 
    SetLongArrayRegion, 
    SetFloatArrayRegion, 
    SetDoubleArrayRegion, 
 
    RegisterNatives,         //映射原生代碼
    UnregisterNatives, 
 
    MonitorEnter, 
    MonitorExit, 
 
    GetJavaVM,             //擷取當前線程關聯的VM

    GetStringRegion,        //擷取子串
    GetStringUTFRegion,

    GetPrimitiveArrayCritical,
    ReleasePrimitiveArrayCritical,

    GetStringCritical,        // Get/ReleaseStringCritical必須成對出現,語義和Get/ReleaseStringChars一樣,但程式碼片段中不能阻塞當前線程,也不能調用任何其他的JNI函數
    ReleaseStringCritical,    

    NewWeakGlobalRef,
    DeleteWeakGlobalRef,

    ExceptionCheck,        //判斷是否有掛起的異常

    NewDirectByteBuffer,
    GetDirectBufferAddress,
    GetDirectBufferCapacity
};

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.