Skip to content

Commit 5758909

Browse files
committed
Add some casts for cross-JDK compatibility
1 parent cb44edd commit 5758909

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

include/jni/wrapping.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ namespace jni
138138
{
139139
::JNINativeMethod Unwrap(JNINativeMethod<R (JNIEnv*, T*, Args...)> method) const
140140
{
141-
return { method.name, method.signature, reinterpret_cast<void*>(method.fnPtr) };
141+
return { const_cast<char*>(method.name), const_cast<char*>(method.signature), reinterpret_cast<void*>(method.fnPtr) };
142142
}
143143
};
144144

test/test.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <jni/types.hpp>
22

3+
#ifdef _JAVASOFT_JNI_H_
4+
using JNINativeInterface = JNINativeInterface_;
5+
#endif
6+
37
template < class T >
48
struct Testable
59
{
@@ -12,8 +16,9 @@ struct Testable
1216
struct TestEnv : public jni::JNIEnv
1317
{
1418
TestEnv()
19+
: jni::JNIEnv { new JNINativeInterface },
20+
functions(const_cast<JNINativeInterface*>(jni::JNIEnv::functions))
1521
{
16-
functions = new JNINativeInterface;
1722
functions->ExceptionCheck = [] (JNIEnv* env) -> jboolean
1823
{
1924
return reinterpret_cast<TestEnv*>(env)->exception ? JNI_TRUE : JNI_FALSE;
@@ -23,6 +28,7 @@ struct TestEnv : public jni::JNIEnv
2328
~TestEnv() { delete functions; }
2429

2530
bool exception = false;
31+
JNINativeInterface* functions;
2632
};
2733

2834
template < class E, class Fn >

0 commit comments

Comments
 (0)