Winsoft JavaBridge v3.0 Full Source for Delphi 5 - 11 and Lazarus
Winsoft JavaBridge v3.0 Full Source for Delphi 5 - 11 and Lazarus
Delphi library for interoperability with Java using Java Native Interface (JNI) and .class files.
Uses standard Java Native Interface
Available for Delphi 5 - 11 and Lazarus 2.0.12
Supports Windows 32, Windows 64, macOS and Linux
Source code included in registered version
Royalty free distribution with applications
type
EJavaBridgeError = class(Exception);
TJValueDynArray = array of JValue;
TJavaBridge = class
constructor Create;
constructor Create(Environment: PJNIEnv);
function CreateJArguments(const Arguments: array of const): TJValueDynArray;
function CreateJString(const Text: AnsiString): JString;
function CreateJString(const Text: WideString): JString;
procedure DefaultJavaVmArguments;
function GetVersion: JInt;
function DefineClass(const Name: PAnsiChar; Loader: JObject; const Buf: PJByte; Len: JSize): JClass;
function FindClass(const Name: PAnsiChar): JClass;
function FromReflectedMethod(Method: JObject): JMethodID;
function FromReflectedField(Field: JObject): JFieldID;
function ToReflectedMethod(Cls: JClass; MethodID: JMethodID; IsStatic: JBoolean): JObject;
function GetSuperclass(Sub: JClass): JClass;
function IsAssignableFrom(Sub, Sup: JClass): JBoolean;
function ToReflectedField(Cls: JClass; FieldID: JFieldID; IsStatic: JBoolean): JObject;
function Throw(Obj: JThrowable): JInt;
function ThrowNew(Clazz: JClass; const Msg: PAnsiChar): JInt;
function ExceptionOccurred: JThrowable;
procedure ExceptionDescribe;
procedure ExceptionClear;
procedure FatalError(const Msg: PAnsiChar);
function PushLocalFrame(Capacity: JInt): JInt;
function PopLocalFrame(Result_: JObject): JObject;
function NewGlobalRef(LObj: JObject): JObject;
procedure DeleteGlobalRef(GRef: JObject);
procedure DeleteLocalRef(Obj: JObject);
function IsSameObject(Obj1, Obj2: JObject): JBoolean;
function NewLocalRef(Ref: JObject): JObject;
function EnsureLocalCapacity(Capacity: JInt): JInt;
function AllocObject(Clazz: JClass): JObject;
function NewObject(Clazz: JClass; MethodID: JMethodID { ... } ): JObject;
function NewObjectV(Clazz: JClass; MethodID: JMethodID; Args: VaList): JObject;
function NewObjectA(Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JObject;
function GetObjectClass(Obj: JObject): JClass;
function IsInstanceOf(Obj: JObject; Clazz: JClass): JBoolean;
function GetMethodID(Clazz: JClass; const Name, Sig: PAnsiChar): JMethodID;
function CallObjectMethod(Obj: JObject; MethodID: JMethodID { ... } ): JObject;
function CallObjectMethodV(Obj: JObject; MethodID: JMethodID; Args: VaList): JObject;
function CallObjectMethodA(Obj: JObject; MethodID: JMethodID; const Args: PJValue): JObject;
function CallBooleanMethod(Obj: JObject; MethodID: JMethodID { ... } ): JBoolean;
function CallBooleanMethodV(Obj: JObject; MethodID: JMethodID; Args: VaList): JBoolean;
function CallBooleanMethodA(Obj: JObject; MethodID: JMethodID; const Args: PJValue): JBoolean;
function CallByteMethod(Obj: JObject; MethodID: JMethodID { ... } ): JByte;
function CallByteMethodV(Obj: JObject; MethodID: JMethodID; Args: VaList): JByte;
function CallByteMethodA(Obj: JObject; MethodID: JMethodID; const Args: PJValue): JByte;
function CallCharMethod(Obj: JObject; MethodID: JMethodID { ... } ): JChar;
function CallCharMethodV(Obj: JObject; MethodID: JMethodID; Args: VaList): JChar;
function CallCharMethodA(Obj: JObject; MethodID: JMethodID; const Args: PJValue): JChar;
function CallShortMethod(Obj: JObject; MethodID: JMethodID { ... } ): JShort;
function CallShortMethodV(Obj: JObject; MethodID: JMethodID; Args: VaList): JShort;
function CallShortMethodA(Obj: JObject; MethodID: JMethodID; const Args: PJValue): JShort;
function CallIntMethod(Obj: JObject; MethodID: JMethodID { ... } ): JInt;
function CallIntMethodV(Obj: JObject; MethodID: JMethodID; Args: VaList): JInt;
function CallIntMethodA(Obj: JObject; MethodID: JMethodID; const Args: PJValue): JInt;
function CallLongMethod(Obj: JObject; MethodID: JMethodID { ... } ): JLong;
function CallLongMethodV(Obj: JObject; MethodID: JMethodID; Args: VaList): JLong;
function CallLongMethodA(Obj: JObject; MethodID: JMethodID; const Args: PJValue): JLong;
function CallFloatMethod(Obj: JObject; MethodID: JMethodID { ... } ): JFloat;
function CallFloatMethodV(Obj: JObject; MethodID: JMethodID; Args: VaList): JFloat;
function CallFloatMethodA(Obj: JObject; MethodID: JMethodID; const Args: PJValue): JFloat;
function CallDoubleMethod(Obj: JObject; MethodID: JMethodID { ... } ): JDouble;
function CallDoubleMethodV(Obj: JObject; MethodID: JMethodID; Args: VaList): JDouble;
function CallDoubleMethodA(Obj: JObject; MethodID: JMethodID; const Args: PJValue): JDouble;
procedure CallVoidMethod(Obj: JObject; MethodID: JMethodID { ... } );
procedure CallVoidMethodV(Obj: JObject; MethodID: JMethodID; Args: VaList);
procedure CallVoidMethodA(Obj: JObject; MethodID: JMethodID; const Args: PJValue);
function CallNonvirtualObjectMethod(Obj: JObject; Clazz: JClass; MethodID: JMethodID { ... } ): JObject;
function CallNonvirtualObjectMethodV(Obj: JObject; Clazz: JClass; MethodID: JMethodID; Args: VaList): JObject;
function CallNonvirtualObjectMethodA(Obj: JObject; Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JObject;
function CallNonvirtualBooleanMethod(Obj: JObject; Clazz: JClass; MethodID: JMethodID { ... } ): JBoolean;
function CallNonvirtualBooleanMethodV(Obj: JObject; Clazz: JClass; MethodID: JMethodID; Args: VaList): JBoolean;
function CallNonvirtualBooleanMethodA(Obj: JObject; Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JBoolean;
function CallNonvirtualByteMethod(Obj: JObject; Clazz: JClass; MethodID: JMethodID { ... } ): JByte;
function CallNonvirtualByteMethodV(Obj: JObject; Clazz: JClass; MethodID: JMethodID; Args: VaList): JByte;
function CallNonvirtualByteMethodA(Obj: JObject; Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JByte;
function CallNonvirtualCharMethod(Obj: JObject; Clazz: JClass; MethodID: JMethodID { ... } ): JChar;
function CallNonvirtualCharMethodV(Obj: JObject; Clazz: JClass; MethodID: JMethodID; Args: VaList): JChar;
function CallNonvirtualCharMethodA(Obj: JObject; Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JChar;
function CallNonvirtualShortMethod(Obj: JObject; Clazz: JClass; MethodID: JMethodID { ... } ): JShort;
function CallNonvirtualShortMethodV(Obj: JObject; Clazz: JClass; MethodID: JMethodID; Args: VaList): JShort;
function CallNonvirtualShortMethodA(Obj: JObject; Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JShort;
function CallNonvirtualIntMethod(Obj: JObject; Clazz: JClass; MethodID: JMethodID { ... } ): JInt;
function CallNonvirtualIntMethodV(Obj: JObject; Clazz: JClass; MethodID: JMethodID; Args: VaList): JInt;
function CallNonvirtualIntMethodA(Obj: JObject; Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JInt;
function CallNonvirtualLongMethod(Obj: JObject; Clazz: JClass; MethodID: JMethodID { ... } ): JLong;
function CallNonvirtualLongMethodV(Obj: JObject; Clazz: JClass; MethodID: JMethodID; Args: VaList): JLong;
function CallNonvirtualLongMethodA(Obj: JObject; Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JLong;
function CallNonvirtualFloatMethod(Obj: JObject; Clazz: JClass; MethodID: JMethodID { ... } ): JFloat;
function CallNonvirtualFloatMethodV(Obj: JObject; Clazz: JClass; MethodID: JMethodID; Args: VaList): JFloat;
function CallNonvirtualFloatMethodA(Obj: JObject; Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JFloat;
function CallNonvirtualDoubleMethod(Obj: JObject; Clazz: JClass; MethodID: JMethodID { ... } ): JDouble;
function CallNonvirtualDoubleMethodV(Obj: JObject; Clazz: JClass; MethodID: JMethodID; Args: VaList): JDouble;
function CallNonvirtualDoubleMethodA(Obj: JObject; Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JDouble;
procedure CallNonvirtualVoidMethod(Obj: JObject; Clazz: JClass; MethodID: JMethodID { ... } );
procedure CallNonvirtualVoidMethodV(Obj: JObject; Clazz: JClass; MethodID: JMethodID; Args: VaList);
procedure CallNonvirtualVoidMethodA(Obj: JObject; Clazz: JClass; MethodID: JMethodID; const Args: PJValue);
function GetFieldID(Clazz: JClass; const Name, Sig: PAnsiChar): JFieldID;
function GetObjectField(Obj: JObject; FieldID: JFieldID): JObject;
function GetBooleanField(Obj: JObject; FieldID: JFieldID): JBoolean;
function GetByteField(Obj: JObject; FieldID: JFieldID): JByte;
function GetCharField(Obj: JObject; FieldID: JFieldID): JChar;
function GetShortField(Obj: JObject; FieldID: JFieldID): JShort;
function GetIntField(Obj: JObject; FieldID: JFieldID): JInt;
function GetLongField(Obj: JObject; FieldID: JFieldID): JLong;
function GetFloatField(Obj: JObject; FieldID: JFieldID): JFloat;
function GetDoubleField(Obj: JObject; FieldID: JFieldID): JDouble;
procedure SetObjectField(Obj: JObject; FieldID: JFieldID; Val: JObject);
procedure SetBooleanField(Obj: JObject; FieldID: JFieldID; Val: JBoolean);
procedure SetByteField(Obj: JObject; FieldID: JFieldID; Val: JByte);
procedure SetCharField(Obj: JObject; FieldID: JFieldID; Val: JChar);
procedure SetShortField(Obj: JObject; FieldID: JFieldID; Val: JShort);
procedure SetIntField(Obj: JObject; FieldID: JFieldID; Val: JInt);
procedure SetLongField(Obj: JObject; FieldID: JFieldID; Val: JLong);
procedure SetFloatField(Obj: JObject; FieldID: JFieldID; Val: JFloat);
procedure SetDoubleField(Obj: JObject; FieldID: JFieldID; Val: JDouble);
function GetStaticMethodID(Clazz: JClass; const Name, Sig: PAnsiChar): JMethodID;
function CallStaticObjectMethod(Clazz: JClass; MethodID: JMethodID { ... } ): JObject;
function CallStaticObjectMethodV(Clazz: JClass; MethodID: JMethodID; Args: VaList): JObject;
function CallStaticObjectMethodA(Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JObject;
function CallStaticBooleanMethod(Clazz: JClass; MethodID: JMethodID { ... } ): JBoolean;
function CallStaticBooleanMethodV(Clazz: JClass; MethodID: JMethodID; Args: VaList): JBoolean;
function CallStaticBooleanMethodA(Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JBoolean;
function CallStaticByteMethod(Clazz: JClass; MethodID: JMethodID { ... } ): JByte;
function CallStaticByteMethodV(Clazz: JClass; MethodID: JMethodID; Args: VaList): JByte;
function CallStaticByteMethodA(Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JByte;
function CallStaticCharMethod(Clazz: JClass; MethodID: JMethodID { ... } ): JChar;
function CallStaticCharMethodV(Clazz: JClass; MethodID: JMethodID; Args: VaList): JChar;
function CallStaticCharMethodA(Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JChar;
function CallStaticShortMethod(Clazz: JClass; MethodID: JMethodID { ... } ): JShort;
function CallStaticShortMethodV(Clazz: JClass; MethodID: JMethodID; Args: VaList): JShort;
function CallStaticShortMethodA(Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JShort;
function CallStaticIntMethod(Clazz: JClass; MethodID: JMethodID { ... } ): JInt;
function CallStaticIntMethodV(Clazz: JClass; MethodID: JMethodID; Args: VaList): JInt;
function CallStaticIntMethodA(Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JInt;
function CallStaticLongMethod(Clazz: JClass; MethodID: JMethodID { ... } ): JLong;
function CallStaticLongMethodV(Clazz: JClass; MethodID: JMethodID; Args: VaList): JLong;
function CallStaticLongMethodA(Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JLong;
function CallStaticFloatMethod(Clazz: JClass; MethodID: JMethodID { ... } ): JFloat;
function CallStaticFloatMethodV(Clazz: JClass; MethodID: JMethodID; Args: VaList): JFloat;
function CallStaticFloatMethodA(Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JFloat;
function CallStaticDoubleMethod(Clazz: JClass; MethodID: JMethodID { ... } ): JDouble;
function CallStaticDoubleMethodV(Clazz: JClass; MethodID: JMethodID; Args: VaList): JDouble;
function CallStaticDoubleMethodA(Clazz: JClass; MethodID: JMethodID; const Args: PJValue): JDouble;
procedure CallStaticVoidMethod(Cls: JClass; MethodID: JMethodID { ... } );
procedure CallStaticVoidMethodV(Cls: JClass; MethodID: JMethodID; Args: VaList);
procedure CallStaticVoidMethodA(Cls: JClass; MethodID: JMethodID; const Args: PJValue);
function GetStaticFieldID(Clazz: JClass; const Name, Sig: PAnsiChar): JFieldID;
function GetStaticObjectField(Clazz: JClass; FieldID: JFieldID): JObject;
function GetStaticBooleanField(Clazz: JClass; FieldID: JFieldID): JBoolean;
function GetStaticByteField(Clazz: JClass; FieldID: JFieldID): JByte;
function GetStaticCharField(Clazz: JClass; FieldID: JFieldID): JChar;
function GetStaticShortField(Clazz: JClass; FieldID: JFieldID): JShort;
function GetStaticIntField(Clazz: JClass; FieldID: JFieldID): JInt;
function GetStaticLongField(Clazz: JClass; FieldID: JFieldID): JLong;
function GetStaticFloatField(Clazz: JClass; FieldID: JFieldID): JFloat;
function GetStaticDoubleField(Clazz: JClass; FieldID: JFieldID): JDouble;
procedure SetStaticObjectField(Clazz: JClass; FieldID: JFieldID; Value: JObject);
procedure SetStaticBooleanField(Clazz: JClass; FieldID: JFieldID; Value: JBoolean);
procedure SetStaticByteField(Clazz: JClass; FieldID: JFieldID; Value: JByte);
procedure SetStaticCharField(Clazz: JClass; FieldID: JFieldID; Value: JChar);
procedure SetStaticShortField(Clazz: JClass; FieldID: JFieldID; Value: JShort);
procedure SetStaticIntField(Clazz: JClass; FieldID: JFieldID; Value: JInt);
procedure SetStaticLongField(Clazz: JClass; FieldID: JFieldID; Value: JLong);
procedure SetStaticFloatField(Clazz: JClass; FieldID: JFieldID; Value: JFloat);
procedure SetStaticDoubleField(Clazz: JClass; FieldID: JFieldID; Value: JDouble);
function NewString(const Unicode: PJChar; Len: JSize): JString;
function GetStringLength(Str: JString): JSize;
function GetStringChars(Str: JString; var IsCopy: JBoolean): PJChar;
procedure ReleaseStringChars(Str: JString; const Chars: PJChar);
function NewStringUTF(const Utf: PAnsiChar): JString;
function GetStringUTFLength(Str: JString): JSize;
function GetStringUTFChars(Str: JString; var IsCopy: JBoolean): PAnsiChar;
procedure ReleaseStringUTFChars(Str: JString; const Chars: PAnsiChar);
function GetArrayLength(Array_: JArray): JSize;
function NewObjectArray(Len: JSize; Clazz: JClass; Init: JObject): JObjectArray;
function GetObjectArrayElement(Array_: JObjectArray; Index: JSize): JObject;
procedure SetObjectArrayElement(Array_: JObjectArray; Index: JSize; Val: JObject);
function NewBooleanArray(Len: JSize): JBooleanArray;
function NewByteArray(Len: JSize): JByteArray;
function NewCharArray(Len: JSize): JCharArray;
function NewShortArray(Len: JSize): JShortArray;
function NewIntArray(Len: JSize): JIntArray;
function NewLongArray(Len: JSize): JLongArray;
function NewFloatArray(Len: JSize): JFloatArray;
function NewDoubleArray(Len: JSize): JDoubleArray;
function GetBooleanArrayElements(Array_: JBooleanArray; var IsCopy: JBoolean): PJBoolean;
function GetByteArrayElements(Array_: JByteArray; var IsCopy: JBoolean): PJByte;
function GetCharArrayElements(Array_: JCharArray; var IsCopy: JBoolean): PJChar;
function GetShortArrayElements(Array_: JShortArray; var IsCopy: JBoolean): PJShort;
function GetIntArrayElements(Array_: JIntArray; var IsCopy: JBoolean): PJInt;
function GetLongArrayElements(Array_: JLongArray; var IsCopy: JBoolean): PJLong;
function GetFloatArrayElements(Array_: JFloatArray; var IsCopy: JBoolean): PJFloat;
function GetDoubleArrayElements(Array_: JDoubleArray; var IsCopy: JBoolean): PJDouble;
procedure ReleaseBooleanArrayElements(Array_: JBooleanArray; Elems: PJBoolean; Mode: JInt);
procedure ReleaseByteArrayElements(Array_: JByteArray; Elems: PJByte; Mode: JInt);
procedure ReleaseCharArrayElements(Array_: JCharArray; Elems: PJChar; Mode: JInt);
procedure ReleaseShortArrayElements(Array_: JShortArray; Elems: PJShort; Mode: JInt);
procedure ReleaseIntArrayElements(Array_: JIntArray; Elems: PJInt; Mode: JInt);
procedure ReleaseLongArrayElements(Array_: JLongArray; Elems: PJLong; Mode: JInt);
procedure ReleaseFloatArrayElements(Array_: JFloatArray; Elems: PJFloat; Mode: JInt);
procedure ReleaseDoubleArrayElements(Array_: JDoubleArray; Elems: PJDouble; Mode: JInt);
procedure GetBooleanArrayRegion(Array_: JBooleanArray; Start, Len: JSize; Buf: PJBoolean);
procedure GetByteArrayRegion(Array_: JByteArray; Start, Len: JSize; Buf: PJByte);
procedure GetCharArrayRegion(Array_: JCharArray; Start, Len: JSize; Buf: PJChar);
procedure GetShortArrayRegion(Array_: JShortArray; Start, Len: JSize; Buf: PJShort);
procedure GetIntArrayRegion(Array_: JIntArray; Start, Len: JSize; Buf: PJInt);
procedure GetLongArrayRegion(Array_: JLongArray; Start, Len: JSize; Buf: PJLong);
procedure GetFloatArrayRegion(Array_: JFloatArray; Start, Len: JSize; Buf: PJFloat);
procedure GetDoubleArrayRegion(Array_: JDoubleArray; Start, Len: JSize; Buf: PJDouble);
procedure SetBooleanArrayRegion(Array_: JBooleanArray; Start, Len: JSize; const Buf: PJBoolean);
procedure SetByteArrayRegion(Array_: JByteArray; Start, Len: JSize; const Buf: PJByte);
procedure SetCharArrayRegion(Array_: JCharArray; Start, Len: JSize; const Buf: PJChar);
procedure SetShortArrayRegion(Array_: JShortArray; Start, Len: JSize; const Buf: PJShort);
procedure SetIntArrayRegion(Array_: JIntArray; Start, Len: JSize; const Buf: PJInt);
procedure SetLongArrayRegion(Array_: JLongArray; Start, Len: JSize; const Buf: PJLong);
procedure SetFloatArrayRegion(Array_: JFloatArray; Start, Len: JSize; const Buf: PJFloat);
procedure SetDoubleArrayRegion(Array_: JDoubleArray; Start, Len: JSize; const Buf: PJDouble);
function RegisterNatives(Clazz: JClass; const Methods: PJNINativeMethod; NMethods: JInt): JInt;
function UnregisterNatives(Clazz: JClass): JInt;
function MonitorEnter(Obj: JObject): JInt;
function MonitorExit(Obj: JObject): JInt;
function GetJavaVM(out VM: PJavaVM): JInt;
procedure GetStringRegion(Str: JString; Start, Len: JSize; Buf: PJChar);
procedure GetStringUTFRegion(Str: JString; Start, Len: JSize; Buf: PAnsiChar);
function GetPrimitiveArrayCritical(Array_: JArray; var IsCopy: JBoolean): Pointer;
procedure ReleasePrimitiveArrayCritical(Array_: JArray; Carray: Pointer; Mode: JInt);
function GetStringCritical(String_: JString; var IsCopy: JBoolean): PJChar;
procedure ReleaseStringCritical(String_: JString; const CString: PJChar);
function NewWeakGlobalRef(Obj: JObject): JWeak;
procedure DeleteWeakGlobalRef(Ref: JWeak);
function ExceptionCheck: JBoolean;
function NewDirectByteBuffer(Address: Pointer; Capacity: JLong): JObject;
function GetDirectBufferAddress(Buf: JObject): Pointer;
function GetDirectBufferCapacity(Buf: JObject): JLong;
function GetObjectRefType(Obj: JObject): JObjectRefType;
function GetModule(Clazz: JClass): JObject;
property Environment: PJNIEnv read;
property JavaVm: PJavaVM read;
property JavaVmArguments: JavaVMInitArgs read;
property JavaVmCreated: Boolean read write;
property LibraryLoaded: Boolean read write;
property LibraryModule: HMODULE read;
property LibraryName: string read write;
end;
What's new
Version 3.0
added support for Delphi 11
added macOS support
added Linux support
added TJavaBridge class
updated declarations for Java 17
removed JNI interfaces
improved demo examples
bug fixes and improvements
Version 3.0
added support for Delphi 11
added macOS support
added Linux support
added TJavaBridge class
updated declarations for Java 17
removed JNI interfaces
improved demo examples
bug fixes and improvements
Only for V.I.P
Warning! You are not allowed to view this text.