AArch64: Make AssetManager and related classes 64-bit compatible
Following changes have been done:
[x] Long is used to store native pointers as pointers can be
64-bit.
[x] AssetManager openAsset native function returned -1 if
file name was empty and java function considered any
non-zero value as success. This has been fixed by native
function throwing Illegal Argument Exception as well.
[x] AssetManager incRefsLocked and decRefsLocked now accept
long as input to support 64-bit native references.
[x] AssetManager incRefsLocked method incorrecly used
'this.hashCode()' instead of the passed parameter id.
This has been fixed.
[x] Some minor changes have been done to conform with
standard JNI practice (e.g. use of jint instead of int
in JNI function prototypes)
Change-Id: I095b9f900d49e51f43ad6afc47cbc23116a6a64a
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Craig Barber <craig.barber@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
diff --git a/core/jni/android_util_StringBlock.cpp b/core/jni/android_util_StringBlock.cpp
index 463d3c0..f29250f 100644
--- a/core/jni/android_util_StringBlock.cpp
+++ b/core/jni/android_util_StringBlock.cpp
@@ -31,7 +31,7 @@
// ----------------------------------------------------------------------------
-static jint android_content_StringBlock_nativeCreate(JNIEnv* env, jobject clazz,
+static jlong android_content_StringBlock_nativeCreate(JNIEnv* env, jobject clazz,
jbyteArray bArray,
jint off, jint len)
{
@@ -56,13 +56,13 @@
return 0;
}
- return (jint)osb;
+ return reinterpret_cast<jlong>(osb);
}
static jint android_content_StringBlock_nativeGetSize(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResStringPool* osb = (ResStringPool*)token;
+ ResStringPool* osb = reinterpret_cast<ResStringPool*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
@@ -72,9 +72,9 @@
}
static jstring android_content_StringBlock_nativeGetString(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResStringPool* osb = (ResStringPool*)token;
+ ResStringPool* osb = reinterpret_cast<ResStringPool*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
@@ -96,9 +96,9 @@
}
static jintArray android_content_StringBlock_nativeGetStyle(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResStringPool* osb = (ResStringPool*)token;
+ ResStringPool* osb = reinterpret_cast<ResStringPool*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return NULL;
@@ -139,9 +139,9 @@
}
static void android_content_StringBlock_nativeDestroy(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResStringPool* osb = (ResStringPool*)token;
+ ResStringPool* osb = reinterpret_cast<ResStringPool*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return;
@@ -157,15 +157,15 @@
*/
static JNINativeMethod gStringBlockMethods[] = {
/* name, signature, funcPtr */
- { "nativeCreate", "([BII)I",
+ { "nativeCreate", "([BII)J",
(void*) android_content_StringBlock_nativeCreate },
- { "nativeGetSize", "(I)I",
+ { "nativeGetSize", "(J)I",
(void*) android_content_StringBlock_nativeGetSize },
- { "nativeGetString", "(II)Ljava/lang/String;",
+ { "nativeGetString", "(JI)Ljava/lang/String;",
(void*) android_content_StringBlock_nativeGetString },
- { "nativeGetStyle", "(II)[I",
+ { "nativeGetStyle", "(JI)[I",
(void*) android_content_StringBlock_nativeGetStyle },
- { "nativeDestroy", "(I)V",
+ { "nativeDestroy", "(J)V",
(void*) android_content_StringBlock_nativeDestroy },
};