MADARA  3.4.1
Acquire_VM.h
Go to the documentation of this file.
1 
2 #ifndef _MADARA_JAVA_ACQUIRE_VM_H_
3 #define _MADARA_JAVA_ACQUIRE_VM_H_
4 
5 #include "madara_jni.h"
6 
14 namespace madara
15 {
16 namespace utility
17 {
18 namespace java
19 {
25 {
26 public:
32  Acquire_VM(bool no_detach = false)
33  {
34  if (!no_detach)
35  {
36  needs_detach = !madara_jni_is_attached();
37  }
38  else
39  {
40  needs_detach = false;
41  }
42 
43  env = madara_jni_get_env();
44  }
45 
50  {
51  if (needs_detach)
52  jni_detach();
53  }
54 
58  JNIEnv* env;
59 
60 protected:
65 };
66 }
67 }
68 }
69 
70 #endif // not defined _MADARA_JAVA_ACQUIRE_VM_H_
This class encapsulates attaching and detaching to a VM.
Definition: Acquire_VM.h:25
Acquire_VM(bool no_detach=false)
Constructor.
Definition: Acquire_VM.h:32
JNIEnv * env
The Java environment.
Definition: Acquire_VM.h:58
bool needs_detach
Flag for determining whether to call detach in destructor.
Definition: Acquire_VM.h:64
Provides utility functions and classes for common tasks and needs.
Definition: IteratorImpl.h:15
Copyright(c) 2020 Galois.