| 146 | } |
| 147 | |
| 148 | JNIEnv* GetEnv() |
| 149 | { |
| 150 | // We have several options here to get the JNIEnv*. |
| 151 | // 1) We use the one we were passed originally in the registration call: m_JavaEnv |
| 152 | // 2) We call m_JavaVM->GetEnv((void**)&penv, JNI_VERSION_1_4) ; |
| 153 | // 3) We call m_JavaVM->AttachCurrentThread((void**)&penv, 0) ; |
| 154 | // I think we need to use the 3rd form if we wish to support callbacks on a different thread. |
| 155 | JNIEnv* penv ; |
| 156 | int result = m_JavaVM->AttachCurrentThread((void**)&penv, 0) ; |
| 157 | |
| 158 | // Error attaching to the VM |
| 159 | if (result < 0) |
| 160 | { |
| 161 | return 0 ; |
| 162 | } |
| 163 | |
| 164 | return penv ; |
| 165 | } |
| 166 | |
| 167 | // We need to clean up the global references that we created earlier |
| 168 | ~JavaCallbackData() |
no outgoing calls
no test coverage detected