Bug 1484823 - Fix Android build errors with NDK r18-beta1. r=snorp

Getting a working local build with the system clang might be tricky, while
building with NDK r17 clang is broken (bug 1484723).
NDK r18-beta1 fixes this, but also made all jvalue* method parameters in jni.h
const,so in order to support building with it we need to adjust our relevant
function types, too.

Differential Revision: https://phabricator.services.mozilla.com/D3832

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan Henning 2018-08-22 16:01:33 +00:00
parent e7f78d6d6c
commit e04236b5f9
2 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,7 @@
#ifndef mozilla_jni_Types_h__
#define mozilla_jni_Types_h__
#include <android/ndk-version.h>
#include <jni.h>
#include "mozilla/jni/Refs.h"
@ -53,10 +54,16 @@ template<class Cls> struct TypeAdapter<LocalRef<Cls>> {
#define MOZ_JNICALL_ABI
#endif
#if __NDK_MAJOR__ >= 18
#define JVALUE_PTR const jvalue*
#else
#define JVALUE_PTR jvalue*
#endif
template<class Cls> constexpr jobject
(JNIEnv::*TypeAdapter<LocalRef<Cls>>::Call)(jobject, jmethodID, jvalue*) MOZ_JNICALL_ABI;
(JNIEnv::*TypeAdapter<LocalRef<Cls>>::Call)(jobject, jmethodID, JVALUE_PTR) MOZ_JNICALL_ABI;
template<class Cls> constexpr jobject
(JNIEnv::*TypeAdapter<LocalRef<Cls>>::StaticCall)(jclass, jmethodID, jvalue*) MOZ_JNICALL_ABI;
(JNIEnv::*TypeAdapter<LocalRef<Cls>>::StaticCall)(jclass, jmethodID, JVALUE_PTR) MOZ_JNICALL_ABI;
template<class Cls> constexpr jobject
(JNIEnv::*TypeAdapter<LocalRef<Cls>>::Get)(jobject, jfieldID);
template<class Cls> constexpr jobject

View File

@ -19,9 +19,9 @@ namespace detail {
#define DEFINE_PRIMITIVE_TYPE_ADAPTER(NativeType, JNIType, JNIName, ABIName) \
\
constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::Call) \
(jobject, jmethodID, jvalue*) MOZ_JNICALL_ABI; \
(jobject, jmethodID, JVALUE_PTR) MOZ_JNICALL_ABI; \
constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::StaticCall) \
(jclass, jmethodID, jvalue*) MOZ_JNICALL_ABI; \
(jclass, jmethodID, JVALUE_PTR) MOZ_JNICALL_ABI; \
constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::Get) \
(jobject, jfieldID) ABIName; \
constexpr JNIType (JNIEnv::*TypeAdapter<NativeType>::StaticGet) \