libcommonc++  0.7
JavaVirtualMachine Class Reference

An object that encapsulates (most of) the Java Native Interface (JNI) to a Java Virtual Machine. More...

#include <JavaVirtualMachine.h++>

Public Member Functions

 JavaVirtualMachine (const SearchPath &classPath=SearchPath::empty, const SearchPath &linkerPath=SearchPath::empty, uint_t initialHeapSize=0, uint_t maxHeapSize=0, bool server=false, bool verbose=false, bool nojit=false)
 Construct and initialize a new Java Virtual Machine. More...
 
 JavaVirtualMachine (JavaVM *jvm)
 Construct a JavaVirtualMachine object for the given JavaVM instance. More...
 
 ~JavaVirtualMachine ()
 Destructor. More...
 
JavaContext attachThread ()
 Attach the calling native thread to the Java Virtual Machine if it is not already attached, and return the JavaContext for the calling thread. More...
 
void detachThread ()
 Detach the calling native thread from the Java Virtual Machine. More...
 
bool isVerbose () const
 Determine if verbose mode is enabled for this JVM. More...
 

Detailed Description

An object that encapsulates (most of) the Java Native Interface (JNI) to a Java Virtual Machine.

Since the JNI Environment pointers are stored in thread-local storage, instances of this class may be used concurrently from multiple native threads, provided that each native thread attaches to the JVM via attachThread() before performing any JNI operations and detaches via detachThread() afterwards.

For more information about the JNI, see The Java Native Interface Programmer's Guide and Specification.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ JavaVirtualMachine() [1/2]

JavaVirtualMachine ( const SearchPath classPath = SearchPath::empty,
const SearchPath linkerPath = SearchPath::empty,
uint_t  initialHeapSize = 0,
uint_t  maxHeapSize = 0,
bool  server = false,
bool  verbose = false,
bool  nojit = false 
)

Construct and initialize a new Java Virtual Machine.

Parameters
classPathThe path for locating classes and JAR files.
linkerPathThe path for locating native libraries.
initialHeapSizeThe initial JVM heap size, in megabytes.
maxHeapSizeThe maximum JVM heap size, in megabytes.
serverA flag indicating whether the Server VM (true) or Client VM (false) should be used.
verboseA flag indicating whether verbose mode should be enabled.
nojitA flag indicating whether the Just-in-Time (JIT) compiler should be disabled.

◆ JavaVirtualMachine() [2/2]

JavaVirtualMachine ( JavaVM *  jvm)

Construct a JavaVirtualMachine object for the given JavaVM instance.

Parameters
jvmThe JavaVM instance.

◆ ~JavaVirtualMachine()

Destructor.

Shuts down and destroys the Java Virtual Machine.

Member Function Documentation

◆ attachThread()

JavaContext attachThread ( )

Attach the calling native thread to the Java Virtual Machine if it is not already attached, and return the JavaContext for the calling thread.

Exceptions
JavaExceptionIf an error occurs.

◆ detachThread()

void detachThread ( )

Detach the calling native thread from the Java Virtual Machine.

If the thread is already detached, the method has no effect.

Exceptions
JavaExceptionIf an error occurs.

◆ isVerbose()

bool isVerbose ( ) const
inline

Determine if verbose mode is enabled for this JVM.


The documentation for this class was generated from the following files: