Table of Contents

Class SetupJVMWrapper<T>

Namespace
MASES.JCOBridge.C2JBridge
Assembly
C2JBridge.dll

Main entry point for JVM languages setup and execution.
Extend this class to use external threading

public class SetupJVMWrapper<T> : SetupJVMWrapper, IJVMWrapperManagement, IJVMBridgeCore where T : SetupJVMWrapper

Type Parameters

T

The class extending SetupJVMWrapper

Inheritance
SetupJVMWrapper<T>
Implements
Inherited Members
Extension Methods

Examples

This is a basic example showing SetupJVMWrapper class usage

class JVMWrapperApp : SetupJVMWrapper<JVMWrapperApp<
{
    public void UnwrappedExecute(object args)
    {
        // put here the code to execute in a different JVM thread
    }

    public void Execute()
    {
         // use the following to execute the thread in JVM as deamon
         // the function returns a reference to the instance of the class allocated in the new thread
         // var jvmwrapperRefFromNewThread = UnwrapAndDemonizeOn(UnwrappedExecute);

         // use the following to execute the thread in JVM
         // the function returns a reference to the instance of the class allocated in the new thread
         // var jvmwrapperRefFromNewThread = UnwrapOn(UnwrappedExecute);

         // ... continue here with normal code; it will execute in parallel with unwrapped code
    }
}

To run use: applicationName --JVMPath:[ABSOLUTE PATH TO JRE LIBRARY (jvm.dll/libjvm.so)] Other command line switch are available on https://www.jcobridge.com/command-line-options/

Properties

GlobalInstance

Create and return a singleton global instance of T

public static T GlobalInstance { get; }

Property Value

T

HasGlobalInstance

Return true if a singleton global instance of T was previously created, otherwise false

public static bool HasGlobalInstance { get; }

Property Value

bool

Methods

CreateGlobalInstance()

Create a singleton global instance of T

public static string[] CreateGlobalInstance()

Returns

string[]

The FilteredArgs content

Remarks

Multiple calls to this method does not produce any effect

UnwrapAndDemonizeOn(ParameterizedThreadStart, object, ApartmentState)

Creates and unwrap the JVM instance as daemon

public T UnwrapAndDemonizeOn(ParameterizedThreadStart handler, object arg = null, ApartmentState apartment = ApartmentState.STA)

Parameters

handler ParameterizedThreadStart

An handler to the function to be invoked

arg object

The argument for handler. Default is null.

apartment ApartmentState

The ApartmentState to be used when the thread is started

Returns

T

An instance of T

Remarks

apartment is valid only on Windows

UnwrapOn(ParameterizedThreadStart, object, ApartmentState)

Creates and unwrap the JVM instance

public T UnwrapOn(ParameterizedThreadStart handler, object arg = null, ApartmentState apartment = ApartmentState.STA)

Parameters

handler ParameterizedThreadStart

An handler to the function to be invoked

arg object

The argument for handler. Default is null.

apartment ApartmentState

The ApartmentState to use to start the thread

Returns

T

An instance of T