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

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

#include <virtualmachine.hxx>

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

Classes

class  CreationException
 An exception indicating failure to create an AttachGuard. More...
 

Public Member Functions

 AttachGuard (rtl::Reference< VirtualMachine > xMachine)
 Attach the current thread to a virtual machine. More...
 
 ~AttachGuard ()
 Detach the current thread from the virtual machine again. More...
 
JNIEnv * getEnvironment () const
 Get a JNI environment pointer for the current thread. More...
 

Private Member Functions

 AttachGuard (AttachGuard const &)=delete
 
AttachGuardoperator= (AttachGuard const &)=delete
 

Private Attributes

rtl::Reference< VirtualMachinem_xMachine
 
JNIEnv * m_pEnvironment
 
bool m_bDetach
 

Detailed Description

A helper to attach a thread to a Java virtual machine.

@descr Upon construction of a guard the current thread is attached to the virtual machine, and upon destruction of the guard the thread is detached again. For any one thread, multiple instances of this class may be used in a stack-like fashion (care is taken to only really detach the thread from the virtual machine upon destruction of the guard at the bottom of the stack).

Definition at line 53 of file virtualmachine.hxx.

Constructor & Destructor Documentation

◆ AttachGuard() [1/2]

VirtualMachine::AttachGuard::AttachGuard ( rtl::Reference< VirtualMachine xMachine)
explicit

Attach the current thread to a virtual machine.

Parameters
rMachineThe virtual machine to attach to. Must not be a null reference.
Exceptions
CreationExceptionThrown in case attaching fails (due to a JNI problem).

Definition at line 44 of file virtualmachine.cxx.

References m_bDetach, m_pEnvironment, and m_xMachine.

◆ ~AttachGuard()

VirtualMachine::AttachGuard::~AttachGuard ( )

Detach the current thread from the virtual machine again.

Definition at line 54 of file virtualmachine.cxx.

◆ AttachGuard() [2/2]

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

Member Function Documentation

◆ getEnvironment()

JNIEnv * jvmaccess::VirtualMachine::AttachGuard::getEnvironment ( ) const
inline

Get a JNI environment pointer for the current thread.

Returns
A valid JNI environment pointer. Will never be null.

Definition at line 87 of file virtualmachine.hxx.

◆ operator=()

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

Member Data Documentation

◆ m_bDetach

bool jvmaccess::VirtualMachine::AttachGuard::m_bDetach
private

Definition at line 95 of file virtualmachine.hxx.

Referenced by AttachGuard().

◆ m_pEnvironment

JNIEnv* jvmaccess::VirtualMachine::AttachGuard::m_pEnvironment
private

Definition at line 94 of file virtualmachine.hxx.

Referenced by AttachGuard().

◆ m_xMachine

rtl::Reference<VirtualMachine> jvmaccess::VirtualMachine::AttachGuard::m_xMachine
private

Definition at line 93 of file virtualmachine.hxx.

Referenced by AttachGuard().


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