LibreOffice Module jvmaccess (master) 1
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
jvmaccess::VirtualMachine Class Referencefinal

An encapsulating wrapper around a Java virtual machine. More...

#include <virtualmachine.hxx>

Inheritance diagram for jvmaccess::VirtualMachine:
[legend]
Collaboration diagram for jvmaccess::VirtualMachine:
[legend]

Classes

class  AttachGuard
 A helper to attach a thread to a Java virtual machine. More...
 

Public Member Functions

 VirtualMachine (JavaVM *pVm, int nVersion, bool bDestroy, JNIEnv const *pMainThreadEnv)
 Create a wrapper around a Java virtual machine. More...
 
- Public Member Functions inherited from salhelper::SimpleReferenceObject
 SimpleReferenceObject ()
 
void acquire ()
 
void release ()
 

Private Member Functions

 VirtualMachine (VirtualMachine const &)=delete
 
VirtualMachineoperator= (VirtualMachine const &)=delete
 
virtual ~VirtualMachine () override
 
JNIEnv * attachThread (bool *pAttached) const
 
void detachThread () const
 

Private Attributes

JavaVM * m_pVm
 
jint m_nVersion
 
bool m_bDestroy
 

Friends

class AttachGuard
 

Additional Inherited Members

- Static Public Member Functions inherited from salhelper::SimpleReferenceObject
static void * operator new (std::size_t nSize)
 
static void * operator new (std::size_t nSize, std::nothrow_t const &rNothrow)
 
static void operator delete (void *pPtr)
 
static void operator delete (void *pPtr, std::nothrow_t const &rNothrow)
 
- Protected Member Functions inherited from salhelper::SimpleReferenceObject
virtual ~SimpleReferenceObject () COVERITY_NOEXCEPT_FALSE
 
- Protected Attributes inherited from salhelper::SimpleReferenceObject
oslInterlockedCount m_nCount
 

Detailed Description

An encapsulating wrapper around a Java virtual machine.

Definition at line 40 of file virtualmachine.hxx.

Constructor & Destructor Documentation

◆ VirtualMachine() [1/2]

VirtualMachine::VirtualMachine ( JavaVM *  pVm,
int  nVersion,
bool  bDestroy,
JNIEnv const *  pMainThreadEnv 
)

Create a wrapper around a Java virtual machine.

Parameters
pVmA JNI pointer to virtual machine. Must not be null.
nVersionThe JNI version of the virtual machine pointed to by pVm. Must be at least JNI_VERSION_1_2. This parameter should be of type jint, not int, but at least on some platforms the definition of jint changed from JDK 1.3 (long) to JDK 1.4 (int), so that the mangled C++ name of the constructor would depend on the JDK version used at compile time.
bDestroyWhether to destroy the virtual machine when destructing the wrapper (i.e., whether the wrapper owns the virtual machine pointed to by pVm).
pMainThreadEnvA valid JNI environment pointer for the current thread; must not be null. The current thread must be "initially attached" to the virtual machine while this constructor is being called (i.e., it must be the thread that has called JNI_CreateJavaVM in case the virtual machine has been started via the JNI Invocation API, and it must not already have called DetachCurrentThread; or it must be executing native code called from a "primordial" virtual machine). This environment pointer was formerly used to obtain a reference to the thread's current context class loader (java.lang.Thread.getCurrentClassLoader; if later a native thread was attached to the virtual machine, that thread's context class loader would be null, so the AttachGuard first of all set it to the saved value; this feature has been removed again for performance reasons and because the default context class loader is often not useful, so that code relying on a context class loader has to set one explicitly, anyway). This parameter is currently unused (but may be used again in the future).

Definition at line 60 of file virtualmachine.cxx.

References nVersion.

◆ VirtualMachine() [2/2]

jvmaccess::VirtualMachine::VirtualMachine ( VirtualMachine const &  )
privatedelete

◆ ~VirtualMachine()

VirtualMachine::~VirtualMachine ( )
overrideprivatevirtual

Definition at line 70 of file virtualmachine.cxx.

References m_bDestroy.

Member Function Documentation

◆ attachThread()

JNIEnv * VirtualMachine::attachThread ( bool *  pAttached) const
private

Definition at line 85 of file virtualmachine.cxx.

References m_nVersion, m_pVm, n, and SAL_WARN_IF.

◆ detachThread()

void VirtualMachine::detachThread ( ) const
private

Definition at line 113 of file virtualmachine.cxx.

References m_pVm, n, and SAL_WARN_IF.

◆ operator=()

VirtualMachine & jvmaccess::VirtualMachine::operator= ( VirtualMachine const &  )
privatedelete

Friends And Related Function Documentation

◆ AttachGuard

friend class AttachGuard
friend

Member Data Documentation

◆ m_bDestroy

bool jvmaccess::VirtualMachine::m_bDestroy
private

Definition at line 146 of file virtualmachine.hxx.

Referenced by ~VirtualMachine().

◆ m_nVersion

jint jvmaccess::VirtualMachine::m_nVersion
private

Definition at line 145 of file virtualmachine.hxx.

Referenced by attachThread().

◆ m_pVm

JavaVM* jvmaccess::VirtualMachine::m_pVm
private

Definition at line 144 of file virtualmachine.hxx.

Referenced by attachThread(), and detachThread().


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