Table of Contents

Class JVMBridgeBase

Namespace
MASES.JCOBridge.C2JBridge
Assembly
C2JBridge.dll

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

string

BridgeInstance

The IJavaObject instance

public IJavaObject BridgeInstance { get; protected set; }

Property Value

IJavaObject

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

bool

IsBridgeCloseable

true if the BridgeClassName implements Closeable

public virtual bool IsBridgeCloseable { get; }

Property Value

bool

IsBridgeInterface

true if the BridgeClassName is an interface, i.e. does not have any public constructor

public virtual bool IsBridgeInterface { get; }

Property Value

bool

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

bool

IsBridgeStatic

true if the BridgeClassName is a static class, i.e. does not have any public constructor

public virtual bool IsBridgeStatic { get; }

Property Value

bool

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

string

The BridgeClassName

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

IJavaObject

The BridgeClassName

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 string

The class name for which retrieve IJavaType

throwOnError bool

Throw exception if the class is not found

Returns

IJavaType

IJavaType associated to className

ClazzOf<TClass>(bool)

Return the IJavaType associated to the TClass

public static IJavaType ClazzOf<TClass>(bool throwOnError = true) where TClass : IJVMBridgeBase, new()

Parameters

throwOnError bool

Throw exception if the class is not found

Returns

IJavaType

IJavaType associated to TClass

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 object

The 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

methodName string

The instance method to be invoked

args object[]

Possible arguments

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

methodName string

The method to execute

args object[]

The aruments

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 string

The instance method to be invoked

signature string

Method 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 string

The method to execute

signature string

Method 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 string

The instance method to be invoked

signature string

Method 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 string

The instance method to be invoked

signature string

Method 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 string

The instance method to be invoked

signature string

Method 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 to TReturn

IExecute<TReturn>(string, params object[])

Executes an instance method

public TReturn IExecute<TReturn>(string methodName, params object[] args)

Parameters

methodName string

The instance method to be invoked

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

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

methodName string

The instance method to be invoked

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

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

methodName string

The instance method to be invoked

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 to TReturn

IGetField(string)

Gets the value of a field identified by fieldName

public object IGetField(string fieldName)

Parameters

fieldName string

The 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 string

The 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 string

The 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

fieldName string

The field name

val object

The value to set on the field

ISetField<TValue>(string, TValue)

Sets the value of a field identified by fieldName

public void ISetField<TValue>(string fieldName, TValue val)

Parameters

fieldName string

The field name

val TValue

The 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

clazz IJavaType

The IJavaType to be checked

Returns

bool

true if clazz is an instance of clazz, otherwise false

IsInstanceOf(string)

Verify if this IJVMBridgeBase is an instance of clazz

public bool IsInstanceOf(string clazz)

Parameters

clazz string

The class name to be checked

Returns

bool

true if clazz is an instance of clazz, otherwise false

IsInstanceOf<T>()

Verify if this IJVMBridgeBase is an instance of T

public bool IsInstanceOf<T>() where T : IJVMBridgeBase, new()

Returns

bool

true if T is an instance of T, otherwise false

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

bool

true if T is an instance of T, otherwise false

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 long

The 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 long

The maximum time to wait, in milliseconds

nanos int

Additional 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 Type

The Type implementing IJVMBridgeBase to be instantiated

javaObject IJavaObject

The BridgeInstance to be used

className string

The 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 IJavaObject

The 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 IJavaObject

The 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 Type

The Type implementing IJVMBridgeBase to be instantiated

javaObject IJavaObject

The BridgeInstance to be used

className string

The 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 different TReturn

Wraps<TNewClass, TReturn>(IJavaObject)

Wraps the javaObject with a new TNewClass class

public static TReturn Wraps<TNewClass, TReturn>(IJavaObject javaObject)

Parameters

javaObject IJavaObject

The 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 Type

The Type implementing IJVMBridgeBase to be instantiated

javaObject IJavaObject

The 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 different TReturn

TConverter

The converter to be used to convert from instance of type to TReturn

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 IJavaObject

The 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 to TReturn