ACT-CV - Machine Vision for Cognitive Modeling
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
JVM Class Reference

the java virtual machine More...

#include <JVM.h>

Inheritance diagram for JVM:
Inheritance graph
Collaboration diagram for JVM:
Collaboration graph

Public Member Functions

 JVM ()
 create the VM with additional classpath "." More...
 
 JVM (const char *cp)
 create the VM with additional classpath cp More...
 
 ~JVM ()
 (don't) destroy the vm More...
 

Protected Member Functions

JNIEnv * GetEnv ()
 the environment More...
 
void CreateJVM (const char *classpath)
 create the Java Virtual Machine More...
 
jobject CreateGlobalRef (jobject obj)
 hinder the VM from garbage collecting obj More...
 
jclass CreateGlobalRef (jclass obj)
 hinder the VM from garbage collecting obj More...
 
void AttachCurrentThread ()
 threads different from the one within which the VM was created must be attached More...
 
void DetachCurrentThread ()
 any attached thread has to be detached afterwards More...
 
int GetThreadId ()
 system specific code! More...
 
JavaVM * GetCreatedJavaVM ()
 pointer to an already created virtual machine More...
 

Protected Attributes

JavaVM * jvm
 pointer to the virtual machine More...
 

Private Member Functions

 jint (__stdcall *jniCreateJavaVM)(JavaVM **
 
void void * jint (__stdcall *jniGetCreatedJavaVMs)(JavaVM **
 
void void jsize *void LoadJvmLib ()
 

Private Attributes

JavaVMInitArgs vm_args
 for vm creation More...
 
JavaVMOption options [3]
 for vm creation More...
 
std::map< int, JNIEnv * > threadSpecificEnvs
 environments are only valid in one thread More...
 
bool mustDestroyVM
 flagged in the class that created the VM More...
 
void * jvmInstance
 
void void jsize
 

Detailed Description

the java virtual machine

Definition at line 70 of file JVM.h.

Constructor & Destructor Documentation

JVM::JVM ( )

create the VM with additional classpath "."

Definition at line 237 of file JVM.cpp.

References AttachCurrentThread(), CreateJVM(), GetCreatedJavaVM(), GetThreadId(), jvm, LoadJvmLib(), MHDBGMSG, and threadSpecificEnvs.

JVM::JVM ( const char *  cp)

create the VM with additional classpath cp

Definition at line 263 of file JVM.cpp.

References AttachCurrentThread(), CreateJVM(), GetCreatedJavaVM(), GetThreadId(), jvm, LoadJvmLib(), MHDBGMSG, and threadSpecificEnvs.

JVM::~JVM ( )

(don't) destroy the vm

Doesn't destroy it by now. The singleton pattern should be used. As long as this is not the case, it can't be guaranteed that the class that created the JVM may destroy it, too.

Definition at line 179 of file JVM.cpp.

References MHDBGMSG.

Member Function Documentation

void JVM::AttachCurrentThread ( )
protected

threads different from the one within which the VM was created must be attached

Definition at line 299 of file JVM.cpp.

References GetCreatedJavaVM(), GetThreadId(), jvm, MHDBGMSG, and threadSpecificEnvs.

Referenced by Robot::AttachCurrentThread(), GetEnv(), and JVM().

jobject JVM::CreateGlobalRef ( jobject  obj)
protected

hinder the VM from garbage collecting obj

Definition at line 294 of file JVM.cpp.

References GetEnv().

Referenced by Robot::Robot().

jclass JVM::CreateGlobalRef ( jclass  obj)
protected

hinder the VM from garbage collecting obj

Definition at line 289 of file JVM.cpp.

References GetEnv().

void JVM::CreateJVM ( const char *  classpath)
protected

create the Java Virtual Machine

When NDEBUG is not set, two options are passed to the VM: "-verbose:gc,class,jni" and "-Xdebug"

The user classpath is always passed to the VM

Todo:
use JNI_GetCreatedJavaVMs to ensure that no more than one virtual machine is created per process!

Definition at line 200 of file JVM.cpp.

References MHDBGMSG, and MHDBGMSG_P.

Referenced by JVM().

void JVM::DetachCurrentThread ( )
protected

any attached thread has to be detached afterwards

Definition at line 315 of file JVM.cpp.

References GetThreadId(), jvm, and threadSpecificEnvs.

Referenced by Robot::DetachCurrentThread().

JavaVM * JVM::GetCreatedJavaVM ( )
protected

pointer to an already created virtual machine

Definition at line 320 of file JVM.cpp.

References jint(), and jsize.

Referenced by AttachCurrentThread(), and JVM().

JNIEnv* JVM::GetEnv ( )
protected
int JVM::GetThreadId ( )
protected

system specific code!

Definition at line 124 of file JVM.h.

Referenced by AttachCurrentThread(), DetachCurrentThread(), GetEnv(), and JVM().

JVM::jint ( __stdcall jniCreateJavaVM)
private
void void* JVM::jint ( __stdcall jniGetCreatedJavaVMs)
private
void JVM::LoadJvmLib ( )
private

Definition at line 114 of file JVM.cpp.

References __stdcall, and MHDBGMSG.

Referenced by JVM().

Member Data Documentation

void void JVM::jsize
private

Definition at line 91 of file JVM.h.

Referenced by GetCreatedJavaVM().

JavaVM* JVM::jvm
protected

pointer to the virtual machine

Definition at line 97 of file JVM.h.

Referenced by AttachCurrentThread(), DetachCurrentThread(), and JVM().

void* JVM::jvmInstance
private

Definition at line 86 of file JVM.h.

bool JVM::mustDestroyVM
private

flagged in the class that created the VM

not used now

Definition at line 81 of file JVM.h.

JavaVMOption JVM::options[3]
private

for vm creation

Definition at line 72 of file JVM.h.

std::map<int,JNIEnv*> JVM::threadSpecificEnvs
private

environments are only valid in one thread

Definition at line 75 of file JVM.h.

Referenced by AttachCurrentThread(), DetachCurrentThread(), GetEnv(), and JVM().

JavaVMInitArgs JVM::vm_args
private

for vm creation

Definition at line 71 of file JVM.h.


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


ACT-CV - Machine Vision for Cognitive Modeling
© 2015 Marc Halbruegge (actcvlibrary@googlemail.com)