Class JVMBridgeBase
Public entry point of JVMBridgeBase
public abstract class JVMBridgeBase : DynamicObject, IDynamicMetaObjectProvider, IJVMBridgeBase, IJVMBridgeDefinition, IJVMBridgeCore, IDisposable
- Inheritance
-
JVMBridgeBase
- Implements
- Derived
- Inherited Members
- Extension Methods
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
TNewClass
The 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
TNewClass
The 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
T
A 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
T
A type implementing IJVMBridgeBase
ClazzOf(string, bool)
Return the IJavaType associated to the className
public static IJavaType ClazzOf(string className, bool throwOnError = true)
Parameters
className
stringThe class name for which retrieve IJavaType
throwOnError
boolThrow exception if 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
throwOnError
boolThrow exception if the class is not found
Returns
Type Parameters
TClass
The type implementing IJVMBridgeBase
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public virtual void Dispose()
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
obj
objectThe 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
args
T[]Possible arguments
Type Parameters
T
The argument type to be used
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<T>(string, params object[])
Execute the method and build the result as an array of T
public T[] IExecuteArray<T>(string methodName, params object[] args)
Parameters
Returns
- T[]
An array of
T
Type Parameters
T
The expected result Type
IExecuteWithSignature(string, string, params object[])
Executes an instance method
public object IExecuteWithSignature(string methodName, string signature, params object[] args)
Parameters
methodName
stringThe instance method to be invoked
signature
stringMethod signature to use in search criteria
args
object[]Possible arguments
Returns
- object
The result of execution. Void functions returns null.
IExecuteWithSignatureArray<T>(string, string, params object[])
Execute the method and build the result as an array of T
public T[] IExecuteWithSignatureArray<T>(string methodName, string signature, params object[] args)
Parameters
methodName
stringThe method to execute
signature
stringMethod signature to use in search criteria
args
object[]The aruments
Returns
- T[]
An array of
T
Type Parameters
T
The expected result Type
IExecuteWithSignature<TReturn>(string, string, params object[])
Executes an instance method
public TReturn IExecuteWithSignature<TReturn>(string methodName, string signature, params object[] args)
Parameters
methodName
stringThe instance method to be invoked
signature
stringMethod signature to use in search criteria
args
object[]Possible arguments
Returns
- TReturn
The result of execution. Void functions returns default.
Type Parameters
TReturn
The 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
methodName
stringThe instance method to be invoked
signature
stringMethod signature to use in search criteria
args
object[]Possible arguments
Returns
- TReturn
The result of execution. Void functions returns default.
Type Parameters
TNewClass
The argument type to be used
TReturn
The 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
methodName
stringThe instance method to be invoked
signature
stringMethod signature to use in search criteria
args
object[]Possible arguments
Returns
- TReturn
The result of execution. Void functions returns default.
Type Parameters
TNewClass
The argument type to be used
TReturn
The return type expected: class implementing IJVMBridgeBase, IJavaObject, Enum, primitive types or array of primitives types
TConverter
The converter to be used to convert from
TNewClass
toTReturn
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
TReturn
The 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
TNewClass
The argument type to be used
TReturn
The 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
TNewClass
The argument type to be used
TReturn
The return type expected: class implementing IJVMBridgeBase, IJavaObject, Enum, primitive types or array of primitives types
TConverter
The converter to be used to convert from
TNewClass
toTReturn
IGetField(string)
Gets the value of a field identified by fieldName
public object IGetField(string fieldName)
Parameters
fieldName
stringThe 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
fieldName
stringThe field name to get
Returns
- TReturn[]
The field value expressed as an array of
TReturn
Type Parameters
TReturn
The 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
fieldName
stringThe field name to read
Returns
- TReturn
The field value expressed as
TReturn
type
Type Parameters
TReturn
The 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
fieldName
stringThe field name
val
TValueThe value to set on the field
Type Parameters
TValue
A 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
clazz
stringThe 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
T
A 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()
RuntimeClassNameOf<T>()
Retrieve the BridgeClassName of T
public static string RuntimeClassNameOf<T>()
Returns
- string
The BridgeClassName or null if
T
does not implement IJVMBridgeBase
Type Parameters
T
Expected 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
T
A 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
timeoutMillis
longThe 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
timeoutMillis
longThe maximum time to wait, in milliseconds
nanos
intAdditional 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
type
TypeThe Type implementing IJVMBridgeBase to be instantiated
javaObject
IJavaObjectThe BridgeInstance to be used
className
stringThe 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
javaObject
IJavaObjectThe IJavaObject to be wrapped from
TNewClass
Returns
- TNewClass
An newly initialized
TNewClass
Type Parameters
TNewClass
The class implementing IJVMBridgeBase
Wraps<TNewClass>(IJavaObject)
Wraps the javaObject
with a new TNewClass
class
public static TNewClass Wraps<TNewClass>(IJavaObject javaObject)
Parameters
javaObject
IJavaObjectThe BridgeInstance to be used
Returns
- TNewClass
An newly initialized
TNewClass
Type Parameters
TNewClass
The 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
type
TypeThe Type implementing IJVMBridgeBase to be instantiated
javaObject
IJavaObjectThe BridgeInstance to be used
className
stringThe name of destination class, null or empty to do not apply class name change
Returns
- TReturn
An newly initialized
TReturn
Type Parameters
TReturn
The 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
javaObject
IJavaObjectThe BridgeInstance to be used
Returns
- TReturn
An newly initialized
TReturn
Type Parameters
TNewClass
The class implementing IJVMBridgeBase
TReturn
The 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
type
TypeThe Type implementing IJVMBridgeBase to be instantiated
javaObject
IJavaObjectThe BridgeInstance to be used
Returns
- TReturn
An newly initialized
TReturn
Type Parameters
TReturn
The return type extended or implmeneted from
type
: in some condition can be helpful to return a differentTReturn
TConverter
The converter to be used to convert from instance of
type
toTReturn
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
javaObject
IJavaObjectThe BridgeInstance to be used
Returns
- TReturn
An newly initialized
TReturn
Type Parameters
TNewClass
The class implementing IJVMBridgeBase
TReturn
The return type: in some condition can be helpful to return a different
TReturn
TConverter
The converter to be used to convert from
TNewClass
toTReturn