Table of Contents

Class JCOBridge

Namespace
MASES.JCOBridge.C2JBridge
Assembly
C2JBridge.dll

General helper class

public static class JCOBridge
Inheritance
JCOBridge
Inherited Members

Properties

Global

The global instance pointer set with Globalize(IJVMBridgeCore, bool)

public static IJVMBridgeCore Global { get; }

Property Value

IJVMBridgeCore

IsCLRHostingProcess

true if the hosting process is a CLR, false if the hosting process is a JVM

public static bool IsCLRHostingProcess { get; }

Property Value

bool

LastBindingException

Reports last Exception raised from JCOBridge subsystem

public static Exception LastBindingException { get; }

Property Value

Exception

Methods

BiThrow<TException>(params object[])

Initialize and throw an instance of TException in JVM and then in CLR

public static void BiThrow<TException>(params object[] args) where TException : JVMBridgeException

Parameters

args object[]

The arguments of the TException constructor

Type Parameters

TException

A Type extending JVMBridgeException

Cast<TObject>(IJVMBridgeBase, bool)

Casts the input object implemeneting IJVMBridgeBase into TObject

public static TObject Cast<TObject>(IJVMBridgeBase obj, bool checkTypes = false)

Parameters

obj IJVMBridgeBase

IJVMBridgeBase to convert to TObject

checkTypes bool

If true executes a check using IsInstanceOf<T>() before cast, default is false

Returns

TObject

The return value converted to TObject

Type Parameters

TObject

The return type expected which implements IJVMBridgeBase

CheckForPrimitive(Type)

Check if type is one of string, bool, byte, char, double, float, int, long, short or array of previous types

public static bool CheckForPrimitive(Type type)

Parameters

type Type

The Type to be checked

Returns

bool

true if type is one of string, bool, byte, char, double, float, int, long, short or array of previous types

CheckForPrimitive<TType>()

Check if TType is one of string, bool, byte, char, double, float, int, long, short

public static bool CheckForPrimitive<TType>()

Returns

bool

true if TType is one of string, bool, byte, char, double, float, int, long, short

Type Parameters

TType

Primitive types or array of primitives types

CheckForRawPrimitive(Type)

Check if type is one of bool, byte, char, double, float, int, long, short or array of previous types

public static bool CheckForRawPrimitive(Type type)

Parameters

type Type

The Type to be checked

Returns

bool

true if type is one of bool, byte, char, double, float, int, long, short or array of previous types

CheckForRawPrimitive<TType>()

Check if TType is one of bool, byte, char, double, float, int, long, short

public static bool CheckForRawPrimitive<TType>()

Returns

bool

true if TType is one of bool, byte, char, double, float, int, long, short

Type Parameters

TType

Primitive types or array of primitives types

Convert(JavaException)

Converts a generic JavaException into a known exception

public static Exception Convert(JavaException jException)

Parameters

jException JavaException

The JavaException to be converted

Returns

Exception

The exception converted into an instance of JVMBridgeException or JavaException if it is not convertible

Convert<TException>(JavaException)

Converts a generic JavaException into a known exception

public static TException Convert<TException>(JavaException jException) where TException : JVMBridgeException

Parameters

jException JavaException

The JavaException to be converted

Returns

TException

The exception converted into TException or JavaException if it is not convertible

Type Parameters

TException

Expected JVMBridgeException class of the exception

Convert<TReturn>(object)

Converts a generic object

public static TReturn Convert<TReturn>(object obj)

Parameters

obj object

The value to be converted

Returns

TReturn

The return value converted to TReturn, or null

Type Parameters

TReturn

The return type expected: a class inherited from IJVMBridgeBase, IJavaObject, Enum, primitive types or array of primitives types

GetMainClasses(Assembly)

Retrieve all Main-Class from the assembly

public static IDictionary<string, Type> GetMainClasses(Assembly assembly)

Parameters

assembly Assembly

The Assembly to analyze

Returns

IDictionary<string, Type>

A IDictionary<TKey, TValue> containing the name of the Main-Class and its Type

Globalize(IJVMBridgeCore, bool)

Creates a new global instance pointer

public static void Globalize(this IJVMBridgeCore wrapper, bool thrownOnError = true)

Parameters

wrapper IJVMBridgeCore

The IJVMBridgeCore instance to be globalized

thrownOnError bool

Raise exception if an instance was previously globalized

Launch(Type, params string[])

Launch the type with the args arguments

public static void Launch(Type type, params string[] args)

Parameters

type Type

The Type extending IJVMBridgeMain

args string[]

The arguments of the main method

Launch<TClass>(params string[])

Launch the TClass class with the args arguments

public static void Launch<TClass>(params string[] args) where TClass : IJVMBridgeMain

Parameters

args string[]

The arguments of the main method

Type Parameters

TClass

A type which is defined as Main-Class

RaiseEventOrException(Exception)

Public method to publish e into logging chain

public static void RaiseEventOrException(Exception e)

Parameters

e Exception

The Exception to be published

RaiseEventOrException(string, params object[])

Public method to publish a message into logging chain

public static void RaiseEventOrException(string messageFormat, params object[] args)

Parameters

messageFormat string

The message to be published

args object[]

The arguments for the messageFormat

RegisterException(Type)

Registers a generic Type, which inherit from JVMBridgeException, to be used in Convert<TException>(JavaException)

public static void RegisterException(Type jException)

Parameters

jException Type

The Type, which inherit from JVMBridgeException, to be registered

RegisterException<TException>()

Registers a generic TException, which inherit from JVMBridgeException, to be used in Convert<TException>(JavaException)

public static void RegisterException<TException>() where TException : JVMBridgeException

Type Parameters

TException

Expected a type inherited from JVMBridgeException class of the exception

RegisterExceptions(IEnumerable<Type>)

Registers a generic Type, which inherit from JVMBridgeException, to be used in Convert<TException>(JavaException)

public static void RegisterExceptions(IEnumerable<Type> jExceptions)

Parameters

jExceptions IEnumerable<Type>

The Types, which inherit from JVMBridgeException, to be registered

RegisterExceptions(Assembly)

Registers a set of JVMBridgeException to be used in Convert<TException>(JavaException)

public static void RegisterExceptions(this Assembly assembly)

Parameters

assembly Assembly

The Assembly to scan for type inherited from JVMBridgeException

RegisterWrapper(Type, Type)

Registers a wrapper class to be used when generics has interfaces

public static void RegisterWrapper(Type tInterface, Type tWrapper)

Parameters

tInterface Type

The Type extending IJVMBridgeBase

tWrapper Type

The Type implementing tInterface

RegisterWrapper<TWrapper, TInterface>()

Registers a wrapper class to be used when generics has interfaces

public static void RegisterWrapper<TWrapper, TInterface>() where TWrapper : TInterface where TInterface : IJVMBridgeBase

Type Parameters

TWrapper

The wrapper implementing TInterface

TInterface

The interface to be associated to the TWrapper

SetEventOrExceptionHandler(EventHandler<EventOrExceptionEventArgs>)

Set a user defined EventHandler<TEventArgs> to receive info from JCOBridge

public static void SetEventOrExceptionHandler(EventHandler<EventOrExceptionEventArgs> handler)

Parameters

handler EventHandler<EventOrExceptionEventArgs>

An handler in the form of EventHandler<TEventArgs>, null to set back the default

Throw<TException>(params object[])

Initialize and throw an instance of TException in JVM

public static void Throw<TException>(params object[] args) where TException : JVMBridgeException

Parameters

args object[]

The arguments of the TException constructor

Type Parameters

TException

A Type extending JVMBridgeException

To<TObject>(CLREventData)

Converts data associated to CLREventData into TObject

public static TObject To<TObject>(CLREventData data)

Parameters

data CLREventData

CLREventData to convert

Returns

TObject

The return value converted to TObject, or null

Type Parameters

TObject

The return type expected: IJavaObject, Enum, primitive types or array of primitives types

To<TObject>(CLREventData, int)

Converts extra data associated to CLREventData into TObject

public static TObject To<TObject>(CLREventData data, int index)

Parameters

data CLREventData

CLREventData to convert

index int

The index within ExtraData to be converted

Returns

TObject

The return value converted to TObject, or null

Type Parameters

TObject

The return type expected: IJavaObject, Enum, primitive types or array of primitives types