Class JVMBridgeBase
Public entry point of JVMBridgeBase
public abstract class JVMBridgeBase : DynamicObject, IDynamicMetaObjectProvider, IJVMBridgeBase, IJVMBridgeDefinition, IJVMBridgeCore, IEquatable<IJVMBridgeBase>, IDisposable
- Inheritance
-
JVMBridgeBase
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
JVMBridgeBase(IJVMBridgeBaseInitializer)
Initializer used internally
public JVMBridgeBase(IJVMBridgeBaseInitializer initializer)
Parameters
initializerIJVMBridgeBaseInitializerAn instance of IJVMBridgeBaseInitializer
Remarks
Shall be available in any class inherited from JVMBridgeBase
Properties
BridgeClassName
Java class name to be instantiated
public abstract string BridgeClassName { get; }
Property Value
BridgeInstance
The IJavaObject instance
public IJavaObject BridgeInstance { get; protected set; }
Property Value
DynBridgeInstance
The dynamic accessor to BridgeInstance
public dynamic DynBridgeInstance { get; }
Property Value
- dynamic
IsBridgeAbstract
true if the BridgeClassName is an abstract class, i.e. cannot be created an instance
public virtual bool IsBridgeAbstract { get; }
Property Value
IsBridgeCloseable
true if the BridgeClassName implements Closeable
public virtual bool IsBridgeCloseable { get; }
Property Value
IsBridgeInterface
true if the BridgeClassName is an interface, i.e. does not have any public constructor
public virtual bool IsBridgeInterface { get; }
Property Value
IsBridgeListener
true if the BridgeClassName follows the listener pattern of JCOBridge: the BridgeClassName extends a JCListener or implements IJCListener
public virtual bool IsBridgeListener { get; }
Property Value
IsBridgeStatic
true if the BridgeClassName is a static class, i.e. does not have any public constructor
public virtual bool IsBridgeStatic { get; }
Property Value
Methods
CastDirect<TNewClass>()
Simplified version of CastTo<TNewClass>() which wraps this instance with a new TNewClass class
public TNewClass CastDirect<TNewClass>() where TNewClass : IJVMBridgeBase, new()
Returns
- TNewClass
An newly initialized
TNewClass
Type Parameters
TNewClassThe class implementing IJVMBridgeBase
Remarks
Use this method with caution since no check on target TNewClass will be made
CastTo<TNewClass>()
Casts this IJVMBridgeBase object into TNewClass
public TNewClass CastTo<TNewClass>() where TNewClass : IJVMBridgeBase, new()
Returns
- TNewClass
The return value converted to
TNewClass
Type Parameters
TNewClassThe return type expected which implements IJVMBridgeBase
Remarks
This method can checks the convertibility to TNewClass using CastTo(IJavaObjectBase, string, bool)
ClassNameOf<T>()
Retrieve the BridgeClassName of T
public static string ClassNameOf<T>() where T : IJVMBridgeBase, new()
Returns
Type Parameters
TA type implementing IJVMBridgeBase
ClassOf<T>()
Retrieve the IJavaObject of the Java Class class associated to T
public static IJavaObject ClassOf<T>() where T : IJVMBridgeBase, new()
Returns
Type Parameters
TA type implementing IJVMBridgeBase
ClazzOf(string, bool)
Return the IJavaType associated to the className
public static IJavaType ClazzOf(string className, bool throwOnError = true)
Parameters
classNamestringThe class name for which retrieve IJavaType
throwOnErrorboolThrow exception if the class is not found
Returns
ClazzOf(string, out Exception, bool)
Return the IJavaType associated to the className
public static IJavaType ClazzOf(string className, out Exception exception, bool throwOnError = false)
Parameters
classNamestringThe class name for which retrieve IJavaType
exceptionExceptionthrowOnErrorboolThrow the
exceptionif the class is not found
Returns
ClazzOf<TClass>(bool)
Return the IJavaType associated to the TClass
public static IJavaType ClazzOf<TClass>(bool throwOnError = true) where TClass : IJVMBridgeBase, new()
Parameters
throwOnErrorboolThrow exception if the class is not found
Returns
Type Parameters
TClassThe type implementing IJVMBridgeBase
ClazzOf<TClass>(out Exception, bool)
Return the IJavaType associated to the TClass
public static IJavaType ClazzOf<TClass>(out Exception exception, bool throwOnError = false) where TClass : IJVMBridgeBase, new()
Parameters
Returns
Type Parameters
TClassThe type implementing IJVMBridgeBase
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Implements the pattern described in https://learn.microsoft.com/en-en/dotnet/standard/garbage-collection/implementing-dispose
protected virtual void Dispose(bool disposing)
Parameters
disposingboolThe disposing parameter is a bool that indicates whether the method call comes from a Dispose() method (its value is true) or from a finalizer (its value is false)
Equals(IJVMBridgeBase)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(IJVMBridgeBase other)
Parameters
otherIJVMBridgeBaseAn object to compare with this object.
Returns
- bool
true if the current object is equal to the
otherparameter; otherwise, false.
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current object.
Returns
- bool
true if the specified object is equal to the current object; otherwise, false.
Execute<T>(params T[])
Executes the code
public abstract void Execute<T>(params T[] args)
Parameters
argsT[]Possible arguments
Type Parameters
TThe argument type to be used
~JVMBridgeBase()
Finalizer
protected ~JVMBridgeBase()
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
IExecute(string, params object[])
Executes an instance method
public object IExecute(string methodName, params object[] args)
Parameters
Returns
- object
The result of execution. Void functions returns null.
IExecuteArray<TArrayType>(string, params object[])
Execute the method and build the result as an array of TArrayType
public TArrayType[] IExecuteArray<TArrayType>(string methodName, params object[] args)
Parameters
Returns
- TArrayType[]
An array of
TArrayType
Type Parameters
TArrayTypeThe expected Type of the returned array
IExecuteWithSignature(string, string, params object[])
Executes an instance method
public object IExecuteWithSignature(string methodName, string signature, params object[] args)
Parameters
methodNamestringThe instance method to be invoked
signaturestringMethod signature to use in search criteria
argsobject[]Possible arguments
Returns
- object
The result of execution. Void functions returns null.
IExecuteWithSignatureArray<TArrayType>(string, string, params object[])
Execute the method and build the result as an array of TArrayType
public TArrayType[] IExecuteWithSignatureArray<TArrayType>(string methodName, string signature, params object[] args)
Parameters
methodNamestringThe method to execute
signaturestringMethod signature to use in search criteria
argsobject[]The aruments
Returns
- TArrayType[]
An array of
TArrayType
Type Parameters
TArrayTypeThe expected Type of the returned array
IExecuteWithSignature<TReturn>(string, string, params object[])
Executes an instance method
public TReturn IExecuteWithSignature<TReturn>(string methodName, string signature, params object[] args)
Parameters
methodNamestringThe instance method to be invoked
signaturestringMethod signature to use in search criteria
argsobject[]Possible arguments
Returns
- TReturn
The result of execution. Void functions returns default.
Type Parameters
TReturnThe return type expected: class implementing IJVMBridgeBase, IJavaObject, Enum, primitive types or array of primitives types
IExecuteWithSignature<TNewClass, TReturn>(string, string, params object[])
Executes an instance method
public TReturn IExecuteWithSignature<TNewClass, TReturn>(string methodName, string signature, params object[] args) where TNewClass : IJVMBridgeBase, TReturn
Parameters
methodNamestringThe instance method to be invoked
signaturestringMethod signature to use in search criteria
argsobject[]Possible arguments
Returns
- TReturn
The result of execution. Void functions returns default.
Type Parameters
TNewClassThe argument type to be used
TReturnThe return type expected: class implementing IJVMBridgeBase, IJavaObject, Enum, primitive types or array of primitives types
IExecuteWithSignature<TNewClass, TReturn, TConverter>(string, string, params object[])
Executes an instance method
public TReturn IExecuteWithSignature<TNewClass, TReturn, TConverter>(string methodName, string signature, params object[] args) where TNewClass : IJVMBridgeBase, TReturn where TConverter : IJVMBridgeBaseConvert<TNewClass, TReturn>, new()
Parameters
methodNamestringThe instance method to be invoked
signaturestringMethod signature to use in search criteria
argsobject[]Possible arguments
Returns
- TReturn
The result of execution. Void functions returns default.
Type Parameters
TNewClassThe argument type to be used
TReturnThe return type expected: class implementing IJVMBridgeBase, IJavaObject, Enum, primitive types or array of primitives types
TConverterThe converter to be used to convert from
TNewClasstoTReturn
IExecute<TReturn>(string, params object[])
Executes an instance method
public TReturn IExecute<TReturn>(string methodName, params object[] args)
Parameters
Returns
- TReturn
The result of execution. Void functions returns default.
Type Parameters
TReturnThe return type expected: class implementing IJVMBridgeBase, IJavaObject, Enum, primitive types or array of primitives types
IExecute<TNewClass, TReturn>(string, params object[])
Executes an instance method
public TReturn IExecute<TNewClass, TReturn>(string methodName, params object[] args) where TNewClass : IJVMBridgeBase, TReturn
Parameters
Returns
- TReturn
The result of execution. Void functions returns default.
Type Parameters
TNewClassThe argument type to be used
TReturnThe return type expected: class implementing IJVMBridgeBase, IJavaObject, Enum, primitive types or array of primitives types
IExecute<TNewClass, TReturn, TConverter>(string, params object[])
Executes an instance method
public TReturn IExecute<TNewClass, TReturn, TConverter>(string methodName, params object[] args) where TNewClass : IJVMBridgeBase, TReturn where TConverter : IJVMBridgeBaseConvert<TNewClass, TReturn>, new()
Parameters
Returns
- TReturn
The result of execution. Void functions returns default.
Type Parameters
TNewClassThe argument type to be used
TReturnThe return type expected: class implementing IJVMBridgeBase, IJavaObject, Enum, primitive types or array of primitives types
TConverterThe converter to be used to convert from
TNewClasstoTReturn
IGetField(string)
Gets the value of a field identified by fieldName
public object IGetField(string fieldName)
Parameters
fieldNamestringThe field name to read
Returns
- object
The field value
IGetFieldArray<TReturn>(string)
Gets the value of a field identified by fieldName
public TReturn[] IGetFieldArray<TReturn>(string fieldName)
Parameters
fieldNamestringThe field name to get
Returns
- TReturn[]
The field value expressed as an array of
TReturn
Type Parameters
TReturnThe return type expected: a type inherited from IJVMBridgeBase, IJavaObject, Enum or primitive types
IGetField<TReturn>(string)
Gets the value of a field identified by fieldName
public TReturn IGetField<TReturn>(string fieldName)
Parameters
fieldNamestringThe field name to read
Returns
- TReturn
The field value expressed as
TReturntype
Type Parameters
TReturnThe return type expected: a type inherited from IJVMBridgeBase, IJavaObject, Enum or primitive types
ISetField(string, object)
Sets the value of a field identified by fieldName
public void ISetField(string fieldName, object val)
Parameters
ISetField<TValue>(string, TValue)
Sets the value of a field identified by fieldName
public void ISetField<TValue>(string fieldName, TValue val)
Parameters
fieldNamestringThe field name
valTValueThe value to set on the field
Type Parameters
TValueA type inherited from IJVMBridgeBase, IJavaObject, Enum or primitive types
IsInstanceOf(IJavaType)
Verify if this IJVMBridgeBase is an instance of clazz
public bool IsInstanceOf(IJavaType clazz)
Parameters
Returns
IsInstanceOf(string)
Verify if this IJVMBridgeBase is an instance of clazz
public bool IsInstanceOf(string clazz)
Parameters
clazzstringThe class name to be checked
Returns
IsInstanceOf<T>()
Verify if this IJVMBridgeBase is an instance of T
public bool IsInstanceOf<T>() where T : IJVMBridgeBase, new()
Returns
Type Parameters
TA type implementing IJVMBridgeBase
MonitorEnter()
Enters the monitor associated with the underlying with this IJVMBridgeBase
public void MonitorEnter()
Remarks
Each Java object has a monitor associated with it. If the current thread already owns the monitor associated with IJVMBridgeBase, the JVM increments a counter in the monitor indicating the number of times this thread has entered the monitor. If the monitor associated with IJVMBridgeBase is not owned by any thread, the current thread becomes the owner of the monitor, setting the entry count of this monitor to 1. If another thread already owns the monitor associated with obj, the current thread waits until the monitor is released, then tries again to gain ownership.
A monitor entered through a <xref href="MASES.JCOBridge.C2JBridge.IJVMBridgeBase.MonitorEnter" data-throw-if-not-resolved="false"></xref> function call cannot be exited using the monitorexit Java virtual machine instruction or a synchronized method return.
A <xref href="MASES.JCOBridge.C2JBridge.IJVMBridgeBase.MonitorEnter" data-throw-if-not-resolved="false"></xref> function call and a monitorenter Java virtual machine instruction may race to enter the monitor associated with the same object.
To avoid deadlocks, a monitor entered through a <xref href="MASES.JCOBridge.C2JBridge.IJVMBridgeBase.MonitorEnter" data-throw-if-not-resolved="false"></xref> function call must be exited using the <xref href="MASES.JCOBridge.C2JBridge.IJVMBridgeBase.MonitorExit" data-throw-if-not-resolved="false"></xref> call, unless the DetachCurrentThread call is used to implicitly release JNI monitors.
MonitorExit()
Exits the monitor associated with the underlying with this IJVMBridgeBase
public void MonitorExit()
Remarks
The current thread must be the owner of the monitor associated with the underlying Java object referred to by IJVMBridgeBase. The thread decrements the counter indicating the number of times it has entered this monitor. If the value of the counter becomes zero, the current thread releases the monitor. Native code must not use MonitorExit() to exit a monitor entered through a synchronized method or a monitorenter Java virtual machine instruction.
Notify()
Wakes up a single thread that is waiting on this object's monitor.
public void Notify()
NotifyAll()
Wakes up all threads that are waiting on this object's monitor.
public void NotifyAll()
ReferenceEqualsJVM(JVMBridgeBase, JVMBridgeBase)
Check if the o1 instance is the same reference of o2 in the JVM
public static bool ReferenceEqualsJVM(JVMBridgeBase o1, JVMBridgeBase o2)
Parameters
o1JVMBridgeBaseFirst IJavaObjectBase to check
o2JVMBridgeBaseSecond IJavaObjectBase to check against
o1
Returns
RuntimeClassNameOf(Type)
Retrieve the BridgeClassName of type
public static string RuntimeClassNameOf(Type type)
Parameters
typeTypeThe type implementing IJVMBridgeBase
Returns
- string
The BridgeClassName or null if
typedoes not implement IJVMBridgeBase
RuntimeClassNameOf<T>()
Retrieve the BridgeClassName of T
public static string RuntimeClassNameOf<T>()
Returns
- string
The BridgeClassName or null if
Tdoes not implement IJVMBridgeBase
Type Parameters
TExpected a type implementing IJVMBridgeBase
RuntimeIsInstanceOf<T>()
Verify if this IJVMBridgeBase is an instance of T; the constraints of T are checked at runtime, while IsInstanceOf<T>() checks T constraint at compile time
public bool RuntimeIsInstanceOf<T>()
Returns
Type Parameters
TA type implementing IJVMBridgeBase
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
Wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
public void Wait()
Wait(long)
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
public void Wait(long timeoutMillis)
Parameters
timeoutMillislongThe maximum time to wait, in milliseconds
Wait(long, int)
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
public void Wait(long timeoutMillis, int nanos)
Parameters
timeoutMillislongThe maximum time to wait, in milliseconds
nanosintAdditional time, in nanoseconds, in the range range 0-999999 inclusive
Wraps(Type, IJavaObject, string)
Wraps the javaObject with a new type class
public static IJVMBridgeBase Wraps(Type type, IJavaObject javaObject, string className)
Parameters
typeTypeThe Type implementing IJVMBridgeBase to be instantiated
javaObjectIJavaObjectThe BridgeInstance to be used
classNamestringThe name of destination class, null or empty to do not apply class name change
Returns
- IJVMBridgeBase
A newly initialized
type
WrapsDirect<TNewClass>(IJavaObject)
Simplified version of Wraps<TNewClass>(IJavaObject) which wraps the javaObject with a new TNewClass class
public static TNewClass WrapsDirect<TNewClass>(IJavaObject javaObject) where TNewClass : IJVMBridgeBase, new()
Parameters
javaObjectIJavaObjectThe IJavaObject to be wrapped from
TNewClass
Returns
- TNewClass
An newly initialized
TNewClass
Type Parameters
TNewClassThe class implementing IJVMBridgeBase
Wraps<TNewClass>(IJavaObject)
Wraps the javaObject with a new TNewClass class
public static TNewClass Wraps<TNewClass>(IJavaObject javaObject)
Parameters
javaObjectIJavaObjectThe BridgeInstance to be used
Returns
- TNewClass
An newly initialized
TNewClass
Type Parameters
TNewClassThe class implementing IJVMBridgeBase
Wraps<TReturn>(Type, IJavaObject, string)
Wraps the javaObject with a new type class
public static TReturn Wraps<TReturn>(Type type, IJavaObject javaObject, string className)
Parameters
typeTypeThe Type implementing IJVMBridgeBase to be instantiated
javaObjectIJavaObjectThe BridgeInstance to be used
classNamestringThe name of destination class, null or empty to do not apply class name change
Returns
- TReturn
An newly initialized
TReturn
Type Parameters
TReturnThe return type extended or implmeneted from
type: in some condition can be helpful to return a differentTReturn
Wraps<TNewClass, TReturn>(IJavaObject)
Wraps the javaObject with a new TNewClass class
public static TReturn Wraps<TNewClass, TReturn>(IJavaObject javaObject)
Parameters
javaObjectIJavaObjectThe BridgeInstance to be used
Returns
- TReturn
An newly initialized
TReturn
Type Parameters
TNewClassThe class implementing IJVMBridgeBase
TReturnThe return type: in some condition can be helpful to return a different
TReturn
Wraps<TReturn, TConverter>(Type, IJavaObject)
Wraps the javaObject with a new type class
public static TReturn Wraps<TReturn, TConverter>(Type type, IJavaObject javaObject) where TConverter : IJVMBridgeBaseConvert<object, TReturn>, new()
Parameters
typeTypeThe Type implementing IJVMBridgeBase to be instantiated
javaObjectIJavaObjectThe BridgeInstance to be used
Returns
- TReturn
An newly initialized
TReturn
Type Parameters
TReturnThe return type extended or implmeneted from
type: in some condition can be helpful to return a differentTReturnTConverterThe converter to be used to convert from instance of
typetoTReturn
Wraps<TNewClass, TReturn, TConverter>(IJavaObject)
Wraps the javaObject with a new TNewClass class
public static TReturn Wraps<TNewClass, TReturn, TConverter>(IJavaObject javaObject) where TNewClass : IJVMBridgeBase where TConverter : IJVMBridgeBaseConvert<TNewClass, TReturn>, new()
Parameters
javaObjectIJavaObjectThe BridgeInstance to be used
Returns
- TReturn
An newly initialized
TReturn
Type Parameters
TNewClassThe class implementing IJVMBridgeBase
TReturnThe return type: in some condition can be helpful to return a different
TReturnTConverterThe converter to be used to convert from
TNewClasstoTReturn