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_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index 8836918..f96aef8 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -88,7 +88,7 @@
{
env->SetIntField(outValue, gTypedValueOffsets.mType, value.dataType);
env->SetIntField(outValue, gTypedValueOffsets.mAssetCookie,
- (jint)table->getTableCookie(block));
+ static_cast<jint>(table->getTableCookie(block)));
env->SetIntField(outValue, gTypedValueOffsets.mData, value.data);
env->SetObjectField(outValue, gTypedValueOffsets.mString, NULL);
env->SetIntField(outValue, gTypedValueOffsets.mResourceId, ref);
@@ -105,7 +105,8 @@
// this guy is exported to other jni routines
AssetManager* assetManagerForJavaObject(JNIEnv* env, jobject obj)
{
- AssetManager* am = (AssetManager*)env->GetIntField(obj, gAssetManagerOffsets.mObject);
+ jlong amHandle = env->GetLongField(obj, gAssetManagerOffsets.mObject);
+ AssetManager* am = reinterpret_cast<AssetManager*>(amHandle);
if (am != NULL) {
return am;
}
@@ -113,7 +114,7 @@
return NULL;
}
-static jint android_content_AssetManager_openAsset(JNIEnv* env, jobject clazz,
+static jlong android_content_AssetManager_openAsset(JNIEnv* env, jobject clazz,
jstring fileName, jint mode)
{
AssetManager* am = assetManagerForJavaObject(env, clazz);
@@ -125,6 +126,7 @@
ScopedUtfChars fileName8(env, fileName);
if (fileName8.c_str() == NULL) {
+ jniThrowException(env, "java/lang/IllegalArgumentException", "Empty file name");
return -1;
}
@@ -143,7 +145,7 @@
//printf("Created Asset Stream: %p\n", a);
- return (jint)a;
+ return reinterpret_cast<jlong>(a);
}
static jobject returnParcelFileDescriptor(JNIEnv* env, Asset* a, jlongArray outOffsets)
@@ -205,7 +207,7 @@
return returnParcelFileDescriptor(env, a, outOffsets);
}
-static jint android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject clazz,
+static jlong android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject clazz,
jint cookie,
jstring fileName,
jint mode)
@@ -240,7 +242,7 @@
//printf("Created Asset Stream: %p\n", a);
- return (jint)a;
+ return reinterpret_cast<jlong>(a);
}
static jobject android_content_AssetManager_openNonAssetFdNative(JNIEnv* env, jobject clazz,
@@ -320,9 +322,9 @@
}
static void android_content_AssetManager_destroyAsset(JNIEnv* env, jobject clazz,
- jint asset)
+ jlong assetHandle)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
//printf("Destroying Asset Stream: %p\n", a);
@@ -335,9 +337,9 @@
}
static jint android_content_AssetManager_readAssetChar(JNIEnv* env, jobject clazz,
- jint asset)
+ jlong assetHandle)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
if (a == NULL) {
jniThrowNullPointerException(env, "asset");
@@ -350,10 +352,10 @@
}
static jint android_content_AssetManager_readAsset(JNIEnv* env, jobject clazz,
- jint asset, jbyteArray bArray,
+ jlong assetHandle, jbyteArray bArray,
jint off, jint len)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
if (a == NULL || bArray == NULL) {
jniThrowNullPointerException(env, "asset");
@@ -374,7 +376,7 @@
ssize_t res = a->read(b+off, len);
env->ReleaseByteArrayElements(bArray, b, 0);
- if (res > 0) return res;
+ if (res > 0) return static_cast<jint>(res);
if (res < 0) {
jniThrowException(env, "java/io/IOException", "");
@@ -383,10 +385,10 @@
}
static jlong android_content_AssetManager_seekAsset(JNIEnv* env, jobject clazz,
- jint asset,
+ jlong assetHandle,
jlong offset, jint whence)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
if (a == NULL) {
jniThrowNullPointerException(env, "asset");
@@ -398,9 +400,9 @@
}
static jlong android_content_AssetManager_getAssetLength(JNIEnv* env, jobject clazz,
- jint asset)
+ jlong assetHandle)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
if (a == NULL) {
jniThrowNullPointerException(env, "asset");
@@ -411,9 +413,9 @@
}
static jlong android_content_AssetManager_getAssetRemainingLength(JNIEnv* env, jobject clazz,
- jint asset)
+ jlong assetHandle)
{
- Asset* a = (Asset*)asset;
+ Asset* a = reinterpret_cast<Asset*>(assetHandle);
if (a == NULL) {
jniThrowNullPointerException(env, "asset");
@@ -725,7 +727,11 @@
}
#endif
}
- return block >= 0 ? copyValue(env, outValue, &res, value, ref, block, typeSpecFlags, &config) : block;
+ if (block >= 0) {
+ return copyValue(env, outValue, &res, value, ref, block, typeSpecFlags, &config);
+ }
+
+ return static_cast<jint>(block);
}
static jint android_content_AssetManager_loadResourceBagValue(JNIEnv* env, jobject clazz,
@@ -759,7 +765,7 @@
res.unlock();
if (block < 0) {
- return block;
+ return static_cast<jint>(block);
}
uint32_t ref = ident;
@@ -772,7 +778,11 @@
}
#endif
}
- return block >= 0 ? copyValue(env, outValue, &res, value, ref, block, typeSpecFlags) : block;
+ if (block >= 0) {
+ return copyValue(env, outValue, &res, value, ref, block, typeSpecFlags);
+ }
+
+ return static_cast<jint>(block);
}
static jint android_content_AssetManager_getStringBlockCount(JNIEnv* env, jobject clazz)
@@ -784,14 +794,14 @@
return am->getResources().getTableCount();
}
-static jint android_content_AssetManager_getNativeStringBlock(JNIEnv* env, jobject clazz,
+static jlong android_content_AssetManager_getNativeStringBlock(JNIEnv* env, jobject clazz,
jint block)
{
AssetManager* am = assetManagerForJavaObject(env, clazz);
if (am == NULL) {
return 0;
}
- return (jint)am->getResources().getTableStringBlock(block);
+ return reinterpret_cast<jlong>(am->getResources().getTableStringBlock(block));
}
static jstring android_content_AssetManager_getCookieName(JNIEnv* env, jobject clazz,
@@ -810,43 +820,43 @@
return str;
}
-static jint android_content_AssetManager_newTheme(JNIEnv* env, jobject clazz)
+static jlong android_content_AssetManager_newTheme(JNIEnv* env, jobject clazz)
{
AssetManager* am = assetManagerForJavaObject(env, clazz);
if (am == NULL) {
return 0;
}
- return (jint)(new ResTable::Theme(am->getResources()));
+ return reinterpret_cast<jlong>(new ResTable::Theme(am->getResources()));
}
static void android_content_AssetManager_deleteTheme(JNIEnv* env, jobject clazz,
- jint themeInt)
+ jlong themeHandle)
{
- ResTable::Theme* theme = (ResTable::Theme*)themeInt;
+ ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle);
delete theme;
}
static void android_content_AssetManager_applyThemeStyle(JNIEnv* env, jobject clazz,
- jint themeInt,
+ jlong themeHandle,
jint styleRes,
jboolean force)
{
- ResTable::Theme* theme = (ResTable::Theme*)themeInt;
+ ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle);
theme->applyStyle(styleRes, force ? true : false);
}
static void android_content_AssetManager_copyTheme(JNIEnv* env, jobject clazz,
- jint destInt, jint srcInt)
+ jlong destHandle, jlong srcHandle)
{
- ResTable::Theme* dest = (ResTable::Theme*)destInt;
- ResTable::Theme* src = (ResTable::Theme*)srcInt;
+ ResTable::Theme* dest = reinterpret_cast<ResTable::Theme*>(destHandle);
+ ResTable::Theme* src = reinterpret_cast<ResTable::Theme*>(srcHandle);
dest->setTo(*src);
}
static jint android_content_AssetManager_loadThemeAttributeValue(
- JNIEnv* env, jobject clazz, jint themeInt, jint ident, jobject outValue, jboolean resolve)
+ JNIEnv* env, jobject clazz, jlong themeHandle, jint ident, jobject outValue, jboolean resolve)
{
- ResTable::Theme* theme = (ResTable::Theme*)themeInt;
+ ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle);
const ResTable& res(theme->getResTable());
Res_value value;
@@ -867,10 +877,10 @@
}
static void android_content_AssetManager_dumpTheme(JNIEnv* env, jobject clazz,
- jint themeInt, jint pri,
+ jlong themeHandle, jint pri,
jstring tag, jstring prefix)
{
- ResTable::Theme* theme = (ResTable::Theme*)themeInt;
+ ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle);
const ResTable& res(theme->getResTable());
// XXX Need to use params.
@@ -878,10 +888,10 @@
}
static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject clazz,
- jint themeToken,
+ jlong themeToken,
jint defStyleAttr,
jint defStyleRes,
- jint xmlParserToken,
+ jlong xmlParserToken,
jintArray attrs,
jintArray outValues,
jintArray outIndices)
@@ -902,9 +912,9 @@
DEBUG_STYLES(LOGI("APPLY STYLE: theme=0x%x defStyleAttr=0x%x defStyleRes=0x%x xml=0x%x",
themeToken, defStyleAttr, defStyleRes, xmlParserToken));
- ResTable::Theme* theme = (ResTable::Theme*)themeToken;
+ ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeToken);
const ResTable& res = theme->getResTable();
- ResXMLParser* xmlParser = (ResXMLParser*)xmlParserToken;
+ ResXMLParser* xmlParser = reinterpret_cast<ResXMLParser*>(xmlParserToken);
ResTable_config config;
Res_value value;
@@ -1097,7 +1107,7 @@
dest[STYLE_TYPE] = value.dataType;
dest[STYLE_DATA] = value.data;
dest[STYLE_ASSET_COOKIE] =
- block != kXmlBlock ? (jint)res.getTableCookie(block) : (jint)-1;
+ block != kXmlBlock ? reinterpret_cast<jint>(res.getTableCookie(block)) : (jint)-1;
dest[STYLE_RESOURCE_ID] = resid;
dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags;
dest[STYLE_DENSITY] = config.density;
@@ -1123,7 +1133,7 @@
}
static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, jobject clazz,
- jint xmlParserToken,
+ jlong xmlParserToken,
jintArray attrs,
jintArray outValues,
jintArray outIndices)
@@ -1240,7 +1250,7 @@
dest[STYLE_TYPE] = value.dataType;
dest[STYLE_DATA] = value.data;
dest[STYLE_ASSET_COOKIE] =
- block != kXmlBlock ? (jint)res.getTableCookie(block) : (jint)-1;
+ block != kXmlBlock ? reinterpret_cast<jint>(res.getTableCookie(block)) : (jint)-1;
dest[STYLE_RESOURCE_ID] = resid;
dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags;
dest[STYLE_DENSITY] = config.density;
@@ -1280,7 +1290,7 @@
ssize_t bagOff = res.getBagLocked(id, &defStyleEnt);
res.unlock();
- return bagOff;
+ return static_cast<jint>(bagOff);
}
static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject clazz,
@@ -1352,7 +1362,7 @@
// Write the final value back to Java.
dest[STYLE_TYPE] = value.dataType;
dest[STYLE_DATA] = value.data;
- dest[STYLE_ASSET_COOKIE] = (jint)res.getTableCookie(block);
+ dest[STYLE_ASSET_COOKIE] = reinterpret_cast<jint>(res.getTableCookie(block));
dest[STYLE_RESOURCE_ID] = resid;
dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags;
dest[STYLE_DENSITY] = config.density;
@@ -1370,7 +1380,7 @@
return i;
}
-static jint android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject clazz,
+static jlong android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject clazz,
jint cookie,
jstring fileName)
{
@@ -1405,7 +1415,7 @@
return 0;
}
- return (jint)block;
+ return reinterpret_cast<jlong>(block);
}
static jintArray android_content_AssetManager_getArrayStringInfo(JNIEnv* env, jobject clazz,
@@ -1580,17 +1590,17 @@
am->addDefaultAssets();
ALOGV("Created AssetManager %p for Java object %p\n", am, clazz);
- env->SetIntField(clazz, gAssetManagerOffsets.mObject, (jint)am);
+ env->SetLongField(clazz, gAssetManagerOffsets.mObject, reinterpret_cast<jlong>(am));
}
static void android_content_AssetManager_destroy(JNIEnv* env, jobject clazz)
{
AssetManager* am = (AssetManager*)
- (env->GetIntField(clazz, gAssetManagerOffsets.mObject));
+ (env->GetLongField(clazz, gAssetManagerOffsets.mObject));
ALOGV("Destroying AssetManager %p for Java object %p\n", am, clazz);
if (am != NULL) {
delete am;
- env->SetIntField(clazz, gAssetManagerOffsets.mObject, 0);
+ env->SetLongField(clazz, gAssetManagerOffsets.mObject, 0);
}
}
@@ -1624,27 +1634,27 @@
/* name, signature, funcPtr */
// Basic asset stuff.
- { "openAsset", "(Ljava/lang/String;I)I",
+ { "openAsset", "(Ljava/lang/String;I)J",
(void*) android_content_AssetManager_openAsset },
{ "openAssetFd", "(Ljava/lang/String;[J)Landroid/os/ParcelFileDescriptor;",
(void*) android_content_AssetManager_openAssetFd },
- { "openNonAssetNative", "(ILjava/lang/String;I)I",
+ { "openNonAssetNative", "(ILjava/lang/String;I)J",
(void*) android_content_AssetManager_openNonAssetNative },
{ "openNonAssetFdNative", "(ILjava/lang/String;[J)Landroid/os/ParcelFileDescriptor;",
(void*) android_content_AssetManager_openNonAssetFdNative },
{ "list", "(Ljava/lang/String;)[Ljava/lang/String;",
(void*) android_content_AssetManager_list },
- { "destroyAsset", "(I)V",
+ { "destroyAsset", "(J)V",
(void*) android_content_AssetManager_destroyAsset },
- { "readAssetChar", "(I)I",
+ { "readAssetChar", "(J)I",
(void*) android_content_AssetManager_readAssetChar },
- { "readAsset", "(I[BII)I",
+ { "readAsset", "(J[BII)I",
(void*) android_content_AssetManager_readAsset },
- { "seekAsset", "(IJI)J",
+ { "seekAsset", "(JJI)J",
(void*) android_content_AssetManager_seekAsset },
- { "getAssetLength", "(I)J",
+ { "getAssetLength", "(J)J",
(void*) android_content_AssetManager_getAssetLength },
- { "getAssetRemainingLength", "(I)J",
+ { "getAssetRemainingLength", "(J)J",
(void*) android_content_AssetManager_getAssetRemainingLength },
{ "addAssetPathNative", "(Ljava/lang/String;)I",
(void*) android_content_AssetManager_addAssetPath },
@@ -1674,27 +1684,27 @@
(void*) android_content_AssetManager_loadResourceBagValue },
{ "getStringBlockCount","()I",
(void*) android_content_AssetManager_getStringBlockCount },
- { "getNativeStringBlock","(I)I",
+ { "getNativeStringBlock","(I)J",
(void*) android_content_AssetManager_getNativeStringBlock },
{ "getCookieName","(I)Ljava/lang/String;",
(void*) android_content_AssetManager_getCookieName },
// Themes.
- { "newTheme", "()I",
+ { "newTheme", "()J",
(void*) android_content_AssetManager_newTheme },
- { "deleteTheme", "(I)V",
+ { "deleteTheme", "(J)V",
(void*) android_content_AssetManager_deleteTheme },
- { "applyThemeStyle", "(IIZ)V",
+ { "applyThemeStyle", "(JIZ)V",
(void*) android_content_AssetManager_applyThemeStyle },
- { "copyTheme", "(II)V",
+ { "copyTheme", "(JJ)V",
(void*) android_content_AssetManager_copyTheme },
- { "loadThemeAttributeValue", "(IILandroid/util/TypedValue;Z)I",
+ { "loadThemeAttributeValue", "(JILandroid/util/TypedValue;Z)I",
(void*) android_content_AssetManager_loadThemeAttributeValue },
- { "dumpTheme", "(IILjava/lang/String;Ljava/lang/String;)V",
+ { "dumpTheme", "(JILjava/lang/String;Ljava/lang/String;)V",
(void*) android_content_AssetManager_dumpTheme },
- { "applyStyle","(IIII[I[I[I)Z",
+ { "applyStyle","(JIIJ[I[I[I)Z",
(void*) android_content_AssetManager_applyStyle },
- { "retrieveAttributes","(I[I[I[I)Z",
+ { "retrieveAttributes","(J[I[I[I)Z",
(void*) android_content_AssetManager_retrieveAttributes },
{ "getArraySize","(I)I",
(void*) android_content_AssetManager_getArraySize },
@@ -1702,7 +1712,7 @@
(void*) android_content_AssetManager_retrieveArray },
// XML files.
- { "openXmlAssetNative", "(ILjava/lang/String;)I",
+ { "openXmlAssetNative", "(ILjava/lang/String;)J",
(void*) android_content_AssetManager_openXmlAssetNative },
// Arrays.
@@ -1766,7 +1776,7 @@
jclass assetManager = env->FindClass("android/content/res/AssetManager");
LOG_FATAL_IF(assetManager == NULL, "Unable to find class android/content/res/AssetManager");
gAssetManagerOffsets.mObject
- = env->GetFieldID(assetManager, "mObject", "I");
+ = env->GetFieldID(assetManager, "mObject", "J");
LOG_FATAL_IF(gAssetManagerOffsets.mObject == NULL, "Unable to find AssetManager.mObject");
jclass stringClass = env->FindClass("java/lang/String");
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 },
};
diff --git a/core/jni/android_util_XmlBlock.cpp b/core/jni/android_util_XmlBlock.cpp
index ad6033b..03de5c0 100644
--- a/core/jni/android_util_XmlBlock.cpp
+++ b/core/jni/android_util_XmlBlock.cpp
@@ -31,7 +31,7 @@
// ----------------------------------------------------------------------------
-static jint android_content_XmlBlock_nativeCreate(JNIEnv* env, jobject clazz,
+static jlong android_content_XmlBlock_nativeCreate(JNIEnv* env, jobject clazz,
jbyteArray bArray,
jint off, jint len)
{
@@ -55,25 +55,25 @@
return 0;
}
- return (jint)osb;
+ return reinterpret_cast<jlong>(osb);
}
-static jint android_content_XmlBlock_nativeGetStringBlock(JNIEnv* env, jobject clazz,
- jint token)
+static jlong android_content_XmlBlock_nativeGetStringBlock(JNIEnv* env, jobject clazz,
+ jlong token)
{
- ResXMLTree* osb = (ResXMLTree*)token;
+ ResXMLTree* osb = reinterpret_cast<ResXMLTree*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)&osb->getStrings();
+ return reinterpret_cast<jlong>(&osb->getStrings());
}
-static jint android_content_XmlBlock_nativeCreateParseState(JNIEnv* env, jobject clazz,
- jint token)
+static jlong android_content_XmlBlock_nativeCreateParseState(JNIEnv* env, jobject clazz,
+ jlong token)
{
- ResXMLTree* osb = (ResXMLTree*)token;
+ ResXMLTree* osb = reinterpret_cast<ResXMLTree*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
@@ -87,19 +87,19 @@
st->restart();
- return (jint)st;
+ return reinterpret_cast<jlong>(st);
}
static jint android_content_XmlBlock_nativeNext(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
return ResXMLParser::END_DOCUMENT;
}
do {
- jint code = (jint)st->next();
+ ResXMLParser::event_code_t code = st->next();
switch (code) {
case ResXMLParser::START_TAG:
return 2;
@@ -123,139 +123,139 @@
}
static jint android_content_XmlBlock_nativeGetNamespace(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
return -1;
}
- return (jint)st->getElementNamespaceID();
+ return static_cast<jint>(st->getElementNamespaceID());
}
static jint android_content_XmlBlock_nativeGetName(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
return -1;
}
- return (jint)st->getElementNameID();
+ return static_cast<jint>(st->getElementNameID());
}
static jint android_content_XmlBlock_nativeGetText(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
return -1;
}
- return (jint)st->getTextID();
+ return static_cast<jint>(st->getTextID());
}
static jint android_content_XmlBlock_nativeGetLineNumber(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getLineNumber();
+ return static_cast<jint>(st->getLineNumber());
}
static jint android_content_XmlBlock_nativeGetAttributeCount(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeCount();
+ return static_cast<jint>(st->getAttributeCount());
}
static jint android_content_XmlBlock_nativeGetAttributeNamespace(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeNamespaceID(idx);
+ return static_cast<jint>(st->getAttributeNamespaceID(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeName(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeNameID(idx);
+ return static_cast<jint>(st->getAttributeNameID(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeResource(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeNameResID(idx);
+ return static_cast<jint>(st->getAttributeNameResID(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeDataType(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeDataType(idx);
+ return static_cast<jint>(st->getAttributeDataType(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeData(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeData(idx);
+ return static_cast<jint>(st->getAttributeData(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeStringValue(JNIEnv* env, jobject clazz,
- jint token, jint idx)
+ jlong token, jint idx)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
- return (jint)st->getAttributeValueStringID(idx);
+ return static_cast<jint>(st->getAttributeValueStringID(idx));
}
static jint android_content_XmlBlock_nativeGetAttributeIndex(JNIEnv* env, jobject clazz,
- jint token,
+ jlong token,
jstring ns, jstring name)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL || name == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
@@ -271,7 +271,7 @@
const char16_t* name16 = env->GetStringChars(name, NULL);
jsize nameLen = env->GetStringLength(name);
- jint idx = (jint)st->indexOfAttribute(ns16, nsLen, name16, nameLen);
+ jint idx = static_cast<jint>(st->indexOfAttribute(ns16, nsLen, name16, nameLen));
if (ns) {
env->ReleaseStringChars(ns, ns16);
@@ -282,35 +282,35 @@
}
static jint android_content_XmlBlock_nativeGetIdAttribute(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
ssize_t idx = st->indexOfID();
- return idx >= 0 ? (jint)st->getAttributeValueStringID(idx) : -1;
+ return idx >= 0 ? static_cast<jint>(st->getAttributeValueStringID(idx)) : -1;
}
static jint android_content_XmlBlock_nativeGetClassAttribute(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
}
ssize_t idx = st->indexOfClass();
- return idx >= 0 ? (jint)st->getAttributeValueStringID(idx) : -1;
+ return idx >= 0 ? static_cast<jint>(st->getAttributeValueStringID(idx)) : -1;
}
static jint android_content_XmlBlock_nativeGetStyleAttribute(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return 0;
@@ -332,9 +332,9 @@
}
static void android_content_XmlBlock_nativeDestroyParseState(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLParser* st = (ResXMLParser*)token;
+ ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token);
if (st == NULL) {
jniThrowNullPointerException(env, NULL);
return;
@@ -344,9 +344,9 @@
}
static void android_content_XmlBlock_nativeDestroy(JNIEnv* env, jobject clazz,
- jint token)
+ jlong token)
{
- ResXMLTree* osb = (ResXMLTree*)token;
+ ResXMLTree* osb = reinterpret_cast<ResXMLTree*>(token);
if (osb == NULL) {
jniThrowNullPointerException(env, NULL);
return;
@@ -362,47 +362,47 @@
*/
static JNINativeMethod gXmlBlockMethods[] = {
/* name, signature, funcPtr */
- { "nativeCreate", "([BII)I",
+ { "nativeCreate", "([BII)J",
(void*) android_content_XmlBlock_nativeCreate },
- { "nativeGetStringBlock", "(I)I",
+ { "nativeGetStringBlock", "(J)J",
(void*) android_content_XmlBlock_nativeGetStringBlock },
- { "nativeCreateParseState", "(I)I",
+ { "nativeCreateParseState", "(J)J",
(void*) android_content_XmlBlock_nativeCreateParseState },
- { "nativeNext", "(I)I",
+ { "nativeNext", "(J)I",
(void*) android_content_XmlBlock_nativeNext },
- { "nativeGetNamespace", "(I)I",
+ { "nativeGetNamespace", "(J)I",
(void*) android_content_XmlBlock_nativeGetNamespace },
- { "nativeGetName", "(I)I",
+ { "nativeGetName", "(J)I",
(void*) android_content_XmlBlock_nativeGetName },
- { "nativeGetText", "(I)I",
+ { "nativeGetText", "(J)I",
(void*) android_content_XmlBlock_nativeGetText },
- { "nativeGetLineNumber", "(I)I",
+ { "nativeGetLineNumber", "(J)I",
(void*) android_content_XmlBlock_nativeGetLineNumber },
- { "nativeGetAttributeCount", "(I)I",
+ { "nativeGetAttributeCount", "(J)I",
(void*) android_content_XmlBlock_nativeGetAttributeCount },
- { "nativeGetAttributeNamespace","(II)I",
+ { "nativeGetAttributeNamespace","(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeNamespace },
- { "nativeGetAttributeName", "(II)I",
+ { "nativeGetAttributeName", "(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeName },
- { "nativeGetAttributeResource", "(II)I",
+ { "nativeGetAttributeResource", "(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeResource },
- { "nativeGetAttributeDataType", "(II)I",
+ { "nativeGetAttributeDataType", "(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeDataType },
- { "nativeGetAttributeData", "(II)I",
+ { "nativeGetAttributeData", "(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeData },
- { "nativeGetAttributeStringValue", "(II)I",
+ { "nativeGetAttributeStringValue", "(JI)I",
(void*) android_content_XmlBlock_nativeGetAttributeStringValue },
- { "nativeGetAttributeIndex", "(ILjava/lang/String;Ljava/lang/String;)I",
+ { "nativeGetAttributeIndex", "(JLjava/lang/String;Ljava/lang/String;)I",
(void*) android_content_XmlBlock_nativeGetAttributeIndex },
- { "nativeGetIdAttribute", "(I)I",
+ { "nativeGetIdAttribute", "(J)I",
(void*) android_content_XmlBlock_nativeGetIdAttribute },
- { "nativeGetClassAttribute", "(I)I",
+ { "nativeGetClassAttribute", "(J)I",
(void*) android_content_XmlBlock_nativeGetClassAttribute },
- { "nativeGetStyleAttribute", "(I)I",
+ { "nativeGetStyleAttribute", "(J)I",
(void*) android_content_XmlBlock_nativeGetStyleAttribute },
- { "nativeDestroyParseState", "(I)V",
+ { "nativeDestroyParseState", "(J)V",
(void*) android_content_XmlBlock_nativeDestroyParseState },
- { "nativeDestroy", "(I)V",
+ { "nativeDestroy", "(J)V",
(void*) android_content_XmlBlock_nativeDestroy },
};