AArch64: Use of long for pointers in PropertyValuesHolder
Long is used in PropertyValuesHolder class to store native pointers
as they can be 64-bit. Note that jmethodID, a pointer to structures,
is also carried in long rather than int to support 64-bit system.
Change-Id: Ifb514fc8473d7c41c0d6194fc6eb85d4816b2cd9
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
diff --git a/core/java/android/animation/PropertyValuesHolder.java b/core/java/android/animation/PropertyValuesHolder.java
index 43014ad..21f6eda 100644
--- a/core/java/android/animation/PropertyValuesHolder.java
+++ b/core/java/android/animation/PropertyValuesHolder.java
@@ -743,9 +743,9 @@
static class IntPropertyValuesHolder extends PropertyValuesHolder {
// Cache JNI functions to avoid looking them up twice
- private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap =
- new HashMap<Class, HashMap<String, Integer>>();
- int mJniSetter;
+ private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap =
+ new HashMap<Class, HashMap<String, Long>>();
+ long mJniSetter;
private IntProperty mIntProperty;
IntKeyframeSet mIntKeyframeSet;
@@ -845,11 +845,11 @@
// Check new static hashmap<propName, int> for setter method
try {
mPropertyMapLock.writeLock().lock();
- HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass);
+ HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass);
if (propertyMap != null) {
- Integer mJniSetterInteger = propertyMap.get(mPropertyName);
- if (mJniSetterInteger != null) {
- mJniSetter = mJniSetterInteger;
+ Long jniSetter = propertyMap.get(mPropertyName);
+ if (jniSetter != null) {
+ mJniSetter = jniSetter;
}
}
if (mJniSetter == 0) {
@@ -857,7 +857,7 @@
mJniSetter = nGetIntMethod(targetClass, methodName);
if (mJniSetter != 0) {
if (propertyMap == null) {
- propertyMap = new HashMap<String, Integer>();
+ propertyMap = new HashMap<String, Long>();
sJNISetterPropertyMap.put(targetClass, propertyMap);
}
propertyMap.put(mPropertyName, mJniSetter);
@@ -880,9 +880,9 @@
static class FloatPropertyValuesHolder extends PropertyValuesHolder {
// Cache JNI functions to avoid looking them up twice
- private static final HashMap<Class, HashMap<String, Integer>> sJNISetterPropertyMap =
- new HashMap<Class, HashMap<String, Integer>>();
- int mJniSetter;
+ private static final HashMap<Class, HashMap<String, Long>> sJNISetterPropertyMap =
+ new HashMap<Class, HashMap<String, Long>>();
+ long mJniSetter;
private FloatProperty mFloatProperty;
FloatKeyframeSet mFloatKeyframeSet;
@@ -982,11 +982,11 @@
// Check new static hashmap<propName, int> for setter method
try {
mPropertyMapLock.writeLock().lock();
- HashMap<String, Integer> propertyMap = sJNISetterPropertyMap.get(targetClass);
+ HashMap<String, Long> propertyMap = sJNISetterPropertyMap.get(targetClass);
if (propertyMap != null) {
- Integer mJniSetterInteger = propertyMap.get(mPropertyName);
- if (mJniSetterInteger != null) {
- mJniSetter = mJniSetterInteger;
+ Long jniSetter = propertyMap.get(mPropertyName);
+ if (jniSetter != null) {
+ mJniSetter = jniSetter;
}
}
if (mJniSetter == 0) {
@@ -994,7 +994,7 @@
mJniSetter = nGetFloatMethod(targetClass, methodName);
if (mJniSetter != 0) {
if (propertyMap == null) {
- propertyMap = new HashMap<String, Integer>();
+ propertyMap = new HashMap<String, Long>();
sJNISetterPropertyMap.put(targetClass, propertyMap);
}
propertyMap.put(mPropertyName, mJniSetter);
@@ -1015,8 +1015,8 @@
}
- native static private int nGetIntMethod(Class targetClass, String methodName);
- native static private int nGetFloatMethod(Class targetClass, String methodName);
- native static private void nCallIntMethod(Object target, int methodID, int arg);
- native static private void nCallFloatMethod(Object target, int methodID, float arg);
-}
\ No newline at end of file
+ native static private long nGetIntMethod(Class targetClass, String methodName);
+ native static private long nGetFloatMethod(Class targetClass, String methodName);
+ native static private void nCallIntMethod(Object target, long methodID, int arg);
+ native static private void nCallFloatMethod(Object target, long methodID, float arg);
+}
diff --git a/core/jni/android_animation_PropertyValuesHolder.cpp b/core/jni/android_animation_PropertyValuesHolder.cpp
index 5991805..1e3ec18 100644
--- a/core/jni/android_animation_PropertyValuesHolder.cpp
+++ b/core/jni/android_animation_PropertyValuesHolder.cpp
@@ -29,44 +29,44 @@
const char* const kClassPathName = "android/animation/PropertyValuesHolder";
-static jmethodID android_animation_PropertyValuesHolder_getIntMethod(
+static jlong android_animation_PropertyValuesHolder_getIntMethod(
JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName)
{
const char *nativeString = env->GetStringUTFChars(methodName, 0);
jmethodID mid = env->GetMethodID(targetClass, nativeString, "(I)V");
env->ReleaseStringUTFChars(methodName, nativeString);
- return mid;
+ return reinterpret_cast<jlong>(mid);
}
-static jmethodID android_animation_PropertyValuesHolder_getFloatMethod(
+static jlong android_animation_PropertyValuesHolder_getFloatMethod(
JNIEnv* env, jclass pvhClass, jclass targetClass, jstring methodName)
{
const char *nativeString = env->GetStringUTFChars(methodName, 0);
jmethodID mid = env->GetMethodID(targetClass, nativeString, "(F)V");
env->ReleaseStringUTFChars(methodName, nativeString);
- return mid;
+ return reinterpret_cast<jlong>(mid);
}
static void android_animation_PropertyValuesHolder_callIntMethod(
- JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, int arg)
+ JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jint arg)
{
- env->CallVoidMethod(target, methodID, arg);
+ env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg);
}
static void android_animation_PropertyValuesHolder_callFloatMethod(
- JNIEnv* env, jclass pvhObject, jobject target, jmethodID methodID, float arg)
+ JNIEnv* env, jclass pvhObject, jobject target, jlong methodID, jfloat arg)
{
- env->CallVoidMethod(target, methodID, arg);
+ env->CallVoidMethod(target, reinterpret_cast<jmethodID>(methodID), arg);
}
static JNINativeMethod gMethods[] = {
- { "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)I",
+ { "nGetIntMethod", "(Ljava/lang/Class;Ljava/lang/String;)J",
(void*)android_animation_PropertyValuesHolder_getIntMethod },
- { "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)I",
+ { "nGetFloatMethod", "(Ljava/lang/Class;Ljava/lang/String;)J",
(void*)android_animation_PropertyValuesHolder_getFloatMethod },
- { "nCallIntMethod", "(Ljava/lang/Object;II)V",
+ { "nCallIntMethod", "(Ljava/lang/Object;JI)V",
(void*)android_animation_PropertyValuesHolder_callIntMethod },
- { "nCallFloatMethod", "(Ljava/lang/Object;IF)V",
+ { "nCallFloatMethod", "(Ljava/lang/Object;JF)V",
(void*)android_animation_PropertyValuesHolder_callFloatMethod }
};
diff --git a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java
index 7b444aa..224eac6 100644
--- a/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/animation/PropertyValuesHolder_Delegate.java
@@ -36,24 +36,24 @@
/*package*/ class PropertyValuesHolder_Delegate {
@LayoutlibDelegate
- /*package*/ static int nGetIntMethod(Class<?> targetClass, String methodName) {
+ /*package*/ static long nGetIntMethod(Class<?> targetClass, String methodName) {
// return 0 to force PropertyValuesHolder to use Java reflection.
return 0;
}
@LayoutlibDelegate
- /*package*/ static int nGetFloatMethod(Class<?> targetClass, String methodName) {
+ /*package*/ static long nGetFloatMethod(Class<?> targetClass, String methodName) {
// return 0 to force PropertyValuesHolder to use Java reflection.
return 0;
}
@LayoutlibDelegate
- /*package*/ static void nCallIntMethod(Object target, int methodID, int arg) {
+ /*package*/ static void nCallIntMethod(Object target, long methodID, int arg) {
// do nothing
}
@LayoutlibDelegate
- /*package*/ static void nCallFloatMethod(Object target, int methodID, float arg) {
+ /*package*/ static void nCallFloatMethod(Object target, long methodID, float arg) {
// do nothing
}
}