summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2021-05-06 17:18:31 +0300
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2021-06-02 08:20:17 +0000
commit78ed8034d24a4914c01546db188aa4832c71d551 (patch)
treed0f53ae5fd97642bb6c5f92b77ca4014d13e99a3 /src/corelib/doc
parent6d72896d0c09717c92fa1efb4dd48f372096753d (diff)
Add a const JNINativeMethod[] overload for registerNativeMethods()
The JNI interface expects a const JNINativeMethod[] and our wrapper takes a non-const. Also, this was causing refactoring of exisisting code with a const JNINativeMethod[] to fail because the call expects a non-const. Change-Id: If790c401650cb33fe31f93bafe41aab7714488e9 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/doc')
-rw-r--r--src/corelib/doc/snippets/jni/src_qjniobject.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/doc/snippets/jni/src_qjniobject.cpp b/src/corelib/doc/snippets/jni/src_qjniobject.cpp
index b729987d4f..dc58fda798 100644
--- a/src/corelib/doc/snippets/jni/src_qjniobject.cpp
+++ b/src/corelib/doc/snippets/jni/src_qjniobject.cpp
@@ -97,8 +97,9 @@ static void fromJavaTwo(JNIEnv *env, jobject thiz, jint x)
void foo()
{
// register the native methods first, ideally it better be done with the app start
- JNINativeMethod methods[] {{"callNativeOne", "(I)V", reinterpret_cast<void *>(fromJavaOne)},
- {"callNativeTwo", "(I)V", reinterpret_cast<void *>(fromJavaTwo)}};
+ const JNINativeMethod methods[] =
+ {{"callNativeOne", "(I)V", reinterpret_cast<void *>(fromJavaOne)},
+ {"callNativeTwo", "(I)V", reinterpret_cast<void *>(fromJavaTwo)}};
QJniEnvironment env;
env.registerNativeMethods("my/java/project/FooJavaClass", methods, 2);