File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -588,8 +588,23 @@ namespace jni
588
588
589
589
inline UniqueEnv AttachCurrentThread (JavaVM& vm)
590
590
{
591
+ // Some implementations type the parameter as JNIEnv**, others as void**.
592
+ // See https://bugs.openjdk.java.net/browse/JDK-6569899
593
+ struct JNIEnvCast
594
+ {
595
+ void ** operator ()(JNIEnv** env, jint (JavaVM::*)(void **, void *))
596
+ {
597
+ return reinterpret_cast <void **>(env);
598
+ }
599
+
600
+ JNIEnv** operator ()(JNIEnv** env, jint (JavaVM::*)(JNIEnv**, void *))
601
+ {
602
+ return env;
603
+ }
604
+ };
605
+
591
606
JNIEnv* result;
592
- CheckErrorCode (vm.AttachCurrentThread (&result, nullptr ));
607
+ CheckErrorCode (vm.AttachCurrentThread (JNIEnvCast ()( &result, &JavaVM::AttachCurrentThread) , nullptr ));
593
608
return UniqueEnv (result, JNIEnvDeleter (vm));
594
609
}
595
610
You can’t perform that action at this time.
0 commit comments