📄 jni_pas.html
字号:
<b>end</b>;
<font color="#003399"><i>{$EXTERNALSYM JDK1_1InitArgs}</i></font>
JDK1_1AttachArgs = <b>packed</b> <b>record</b>
__padding: Pointer;
<b>end</b>;
<font color="#003399"><i>{$EXTERNALSYM JDK1_1AttachArgs}</i></font>
<font color="#003399"><i>// End VM-specific.</i></font>
JNIInvokeInterface_ = <b>packed</b> <b>record</b>
reserved0: Pointer;
reserved1: Pointer;
reserved2: Pointer;
DestroyJavaVM: <b>function</b>(PVM: PJavaVM): JInt; <b>stdcall</b>;
AttachCurrentThread: <b>function</b>(PVM: PJavaVM; PEnv: PPJNIEnv; Args: Pointer): JInt; <b>stdcall</b>;
DetachCurrentThread: <b>function</b>(PVM: PJavaVM): JInt; <b>stdcall</b>;
GetEnv: <b>function</b>(PVM: PJavaVM; PEnv: PPointer; Version: JInt): JInt; <b>stdcall</b>;
<b>end</b>;
<font color="#003399"><i>{$EXTERNALSYM JNIInvokeInterface_}</i></font>
<font color="#003399"><i>// Defined by native libraries.</i></font>
TJNI_OnLoad = <b>function</b>(PVM: PJavaVM; Reserved: Pointer): JInt; <b>stdcall</b>;
TJNI_OnUnload = <b>procedure</b>(PVM: PJavaVM; Reserved: Pointer); <b>stdcall</b>;
<font color="#003399"><i>{$IFDEF DYNAMIC_LINKING}</i></font>
<b>function</b> JNI_GetDefaultJavaVMInitArgs(Args: PJDK1_1InitArgs; <b>const</b> JVMDLLFile: <b>string</b>): JInt;
<font color="#003399"><i>{$EXTERNALSYM JNI_GetDefaultJavaVMInitArgs}</i></font>
<b>function</b> JNI_CreateJavaVM(PJVM: PJavaVM; PEnv: PPointer; Args: Pointer; <b>const</b> JVMDLLFile: <b>string</b>): JInt;
<font color="#003399"><i>{$EXTERNALSYM JNI_CreateJavaVM}</i></font>
<b>function</b> JNI_GetCreatedJavaVMs(PJVM: PJavaVM; JSize1: JSize; <b>var</b> JSize2: JSize; <b>const</b> JVMDLLFile: <b>string</b>): JInt;
<font color="#003399"><i>{$EXTERNALSYM JNI_GetCreatedJavaVMs}</i></font>
<font color="#003399"><i>{$ELSE}</i></font>
<b>function</b> JNI_GetDefaultJavaVMInitArgs(Args: Pointer): JInt; <b>stdcall</b>;
<font color="#003399"><i>{$EXTERNALSYM JNI_GetDefaultJavaVMInitArgs}</i></font>
<b>function</b> JNI_CreateJavaVM(PJVM: PJavaVM; PEnv: PPointer; Args: Pointer): JInt; <b>stdcall</b>;
<font color="#003399"><i>{$EXTERNALSYM JNI_CreateJavaVM}</i></font>
<b>function</b> JNI_GetCreatedJavaVMs(PJVM: PJavaVM; JSize1: JSize; <b>var</b> JSize2: JSize): JInt; <b>stdcall</b>;
<font color="#003399"><i>{$EXTERNALSYM JNI_GetCreatedJavaVMs}</i></font>
<font color="#003399"><i>{$ENDIF}</i></font>
<font color="#003399"><i>// Wrapper stuff</i></font>
<b>type</b>
TJValueArray = <b>array</b> <b>of</b> JValue;
EJVMError = <b>class</b>(Exception);
EJNIError = <b>class</b>(Exception);
EJNIUnsupportedMethodError = <b>class</b>(EJNIError);
TJNI_GetDefaultJavaVMInitArgs = <b>function</b>(Args: Pointer): JInt; <b>stdcall</b>;
TJNI_CreateJavaVM = <b>function</b>(PJVM: PJavaVM; PEnv: PPointer; Args: Pointer): JInt; <b>stdcall</b>;
TJNI_GetCreatedJavaVMs = <b>function</b>(PJVM: PJavaVM; JSize1: JSize; <b>var</b> JSize2: JSize): JInt; <b>stdcall</b>;
TJavaVM = <b>class</b>(TObject)
<b>private</b>
FJavaVM: PJavaVM;
FEnv: PJNIEnv;
FJavaVMInitArgs: JavaVMInitArgs;
FJDK1_1InitArgs: JDK1_1InitArgs;
FJVMDLLFile: <b>string</b>;
FVersion: JInt;
FDLLHandle: THandle;
FIsInitialized: Boolean;
<font color="#003399"><i>// DLL functions</i></font>
FJNI_GetDefaultJavaVMInitArgs: TJNI_GetDefaultJavaVMInitArgs;
FJNI_CreateJavaVM: TJNI_CreateJavaVM;
FJNI_GetCreatedJavaVMs: TJNI_GetCreatedJavaVMs;
<b>procedure</b> SetVersion(<b>const</b> Value: JInt);
<b>public</b>
<b>property</b> JavaVM: PJavaVM <b>read</b> FJavaVM;
<b>property</b> Env: PJNIEnv <b>read</b> FEnv;
<b>property</b> JDK1_1InitArgs: JDK1_1InitArgs <b>read</b> FJDK1_1InitArgs;
<b>property</b> JDK1_2InitArgs: JavaVMInitArgs <b>read</b> FJavaVMInitArgs;
<b>property</b> Version: JInt <b>read</b> FVersion <b>write</b> SetVersion;
<font color="#003399"><i>// Constructors</i></font>
<b>constructor</b> Create; overload;
<b>constructor</b> Create(JDKVersion: Integer); overload;
<b>constructor</b> Create(JDKVersion: Integer; <b>const</b> JVMDLLFilename: <b>string</b>); overload;
<b>destructor</b> Destroy; override;
<b>function</b> LoadVM(<b>const</b> Options: JDK1_1InitArgs): JInt; overload;
<b>function</b> LoadVM(<b>const</b> Options: JavaVMInitArgs): JInt; overload;
<b>function</b> GetDefaultJavaVMInitArgs(Args: PJDK1_1InitArgs): JInt;
<b>function</b> GetCreatedJavaVMs(PJVM: PJavaVM; JSize1: JSize; <b>var</b> JSize2: JSize): JInt;
<b>end</b>;
TJNIEnv = <b>class</b>(TObject)
<b>private</b>
FEnv: PJNIEnv;
FMajorVersion: JInt;
FMinorVersion: JInt;
FVersion: JInt;
FConvertedArgs: TJValueArray;
<b>function</b> GetMajorVersion: JInt;
<b>function</b> GetMinorVersion: JInt;
<b>procedure</b> VersionCheck(<b>const</b> FuncName: <b>string</b>; RequiredVersion: JInt);
<b>public</b>
<font color="#003399"><i>// Properties</i></font>
<b>property</b> Env: PJNIEnv <b>read</b> FEnv;
<b>property</b> MajorVersion: JInt <b>read</b> FMajorVersion;
<b>property</b> MinorVersion: JInt <b>read</b> FMinorVersion;
<b>property</b> Version: JInt <b>read</b> FVersion;
<font color="#003399"><i>// Constructors</i></font>
<b>constructor</b> Create(AEnv: PJNIEnv);
<font color="#003399"><i>// Support methods</i></font>
<b>function</b> ArgsToJValues(<b>const</b> Args: <b>array</b> <b>of</b> <b>const</b>): PJValue;
<b>function</b> JStringToString(JStr: JString): <b>string</b>;
<b>function</b> StringToJString(<b>const</b> AString: PAnsiChar): JString;
<b>function</b> UnicodeJStringToString(JStr: JString): <b>string</b>;
<b>function</b> StringToUnicodeJString(<b>const</b> AString: PAnsiChar): JString;
<font color="#003399"><i>// JNIEnv methods</i></font>
<b>function</b> GetVersion: JInt;
<b>function</b> DefineClass(<b>const</b> Name: PAnsiChar; Loader: JObject; <b>const</b> Buf: PJByte; Len: JSize): JClass;
<b>function</b> FindClass(<b>const</b> Name: PAnsiChar): JClass;
<font color="#003399"><i>// Reflection Support</i></font>
<b>function</b> FromReflectedMethod(Method: JObject): JMethodID;
<b>function</b> FromReflectedField(Field: JObject): JFieldID;
<b>function</b> ToReflectedMethod(AClass: JClass; MethodID: JMethodID; IsStatic: JBoolean): JObject;
<b>function</b> GetSuperclass(Sub: JClass): JClass;
<b>function</b> IsAssignableFrom(Sub: JClass; Sup: JClass): JBoolean;
<font color="#003399"><i>// Reflection Support</i></font>
<b>function</b> ToReflectedField(AClass: JClass; FieldID: JFieldID; IsStatic: JBoolean): JObject;
<b>function</b> Throw(Obj: JThrowable): JInt;
<b>function</b> ThrowNew(AClass: JClass; <b>const</b> Msg: PAnsiChar): JInt;
<b>function</b> ExceptionOccurred: JThrowable;
<b>procedure</b> ExceptionDescribe;
<b>procedure</b> ExceptionClear;
<b>procedure</b> FatalError(<b>const</b> Msg: PAnsiChar);
<font color="#003399"><i>// Local Reference Management</i></font>
<b>function</b> PushLocalFrame(Capacity: JInt): JInt;
<b>function</b> PopLocalFrame(AResult: JObject): JObject;
<b>function</b> NewGlobalRef(LObj: JObject): JObject;
<b>procedure</b> DeleteGlobalRef(GRef: JObject);
<b>procedure</b> DeleteLocalRef(Obj: JObject);
<b>function</b> IsSameObject(Obj1: JObject; Obj2: JObject): JBoolean;
<font color="#003399"><i>// Local Reference Management</i></font>
<b>function</b> NewLocalRef(Ref: JObject): JObject;
<b>function</b> EnsureLocalCapacity(Capacity: JInt): JObject;
<b>function</b> AllocObject(AClass: JClass): JObject;
<b>function</b> NewObject(AClass: JClass; MethodID: JMethodID; <b>const</b> Args: <b>array</b> <b>of</b> <b>const</b>): JObject;
<b>function</b> NewObjectV(AClass: JClass; MethodID: JMethodID; Args: va_list): JObject;
<b>function</b> NewObjectA(AClass: JClass; MethodID: JMethodID; Args: PJValue): JObject;
<b>function</b> GetObjectClass(Obj: JObject): JClass;
<b>function</b> IsInstanceOf(Obj: JObject; AClass: JClass): JBoolean;
<b>function</b> GetMethodID(AClass: JClass; <b>const</b> Name: PAnsiChar; <b>const</b> Sig: PAnsiChar): JMethodID;
<b>function</b> CallObjectMethod(Obj: JObject; MethodID: JMethodID; <b>const</b> Args: <b>array</b> <b>of</b> <b>const</b>): JObject;
<b>function</b> CallObjectMethodV(Obj: JObject; MethodID: JMethodID; Args: va_list): JObject;
<b>function</b> CallObjectMethodA(Obj: JObject; MethodID: JMethodID; Args: PJValue): JObject;
<b>function</b> CallBooleanMethod(Obj: JObject; MethodID: JMethodID; <b>const</b> Args: <b>array</b> <b>of</b> <b>const</b>): JBoolean;
<b>function</b> CallBooleanMethodV(Obj: JObject; MethodID: JMethodID; Args: va_list): JBoolean;
<b>function</b> CallBooleanMethodA(Obj: JObject; MethodID: JMethodID; Args: PJValue): JBoolean;
<b>function</b> CallByteMethod(Obj: JObject; MethodID: JMethodID; <b>const</b> Args: <b>array</b> <b>of</b> <b>const</b>): JByte;
<b>function</b> CallByteMethodV(Obj: JObject; MethodID: JMethodID; Args: va_list): JByte;
<b>function</b> CallByteMethodA(Obj: JObject; MethodID: JMethodID; Args: PJValue): JByte;
<b>function</b> CallCharMethod(Obj: JObject; MethodID: JMethodID; <b>const</b> Args: <b>array</b> <b>of</b> <b>const</b>): JChar;
<b>function</b> CallCharMethodV(Obj: JObject; MethodID: JMethodID; Args: va_list): JChar;
<b>function</b> CallCharMethodA(Obj: JObject; MethodID: JMethodID; Args: PJValue): JChar;
<b>function</b> CallShortMethod(Obj: JObject; MethodID: JMethodID; <b>const</b> Args: <b>array</b> <b>of</b> <b>const</b>): JShort;
<b>function</b> CallShortMethodV(Obj: JObject; MethodID: JMethodID; Args: va_list): JShort;
<b>function</b> CallShortMethodA(Obj: JObject; MethodID: JMethodID; Args: PJValue): JShort;
<b>function</b> CallIntMethod(Obj: JObject; MethodID: JMethodID; <b>const</b> Args: <b>array</b> <b>of</b> <b>const</b>): JInt;
<b>function</b> CallIntMethodV(Obj: JObject; MethodID: JMethodID; Args: va_list): JInt;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -