diff options
41 files changed, 206 insertions, 250 deletions
diff --git a/archive/src/main/native/java_util_zip_Adler32.c b/archive/src/main/native/java_util_zip_Adler32.c index 0fcf549..4410e5b 100644 --- a/archive/src/main/native/java_util_zip_Adler32.c +++ b/archive/src/main/native/java_util_zip_Adler32.c @@ -43,17 +43,10 @@ Java_java_util_zip_Adler32_updateByteImpl (JNIEnv * env, jobject recv, return adler32 ((uLong) crc, (Bytef *) (&bytefVal), 1); } - -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "updateImpl", "([BIIJ)J", Java_java_util_zip_Adler32_updateImpl }, { "updateByteImpl", "(IJ)J", Java_java_util_zip_Adler32_updateByteImpl }, }; -int register_java_util_zip_Adler32(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/util/zip/Adler32", - gMethods, NELEM(gMethods)); +int register_java_util_zip_Adler32(JNIEnv* env) { + return jniRegisterNativeMethods(env, "java/util/zip/Adler32", gMethods, NELEM(gMethods)); } diff --git a/archive/src/main/native/java_util_zip_CRC32.c b/archive/src/main/native/java_util_zip_CRC32.c index fe50fca..95369a2 100644 --- a/archive/src/main/native/java_util_zip_CRC32.c +++ b/archive/src/main/native/java_util_zip_CRC32.c @@ -41,17 +41,10 @@ Java_java_util_zip_CRC32_updateByteImpl (JNIEnv * env, jobject recv, return crc32 ((uLong) crc, (Bytef *) (&val), 1); } - -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "updateImpl", "([BIIJ)J", Java_java_util_zip_CRC32_updateImpl }, { "updateByteImpl", "(BJ)J", Java_java_util_zip_CRC32_updateByteImpl }, }; -int register_java_util_zip_CRC32(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/util/zip/CRC32", - gMethods, NELEM(gMethods)); +int register_java_util_zip_CRC32(JNIEnv* env) { + return jniRegisterNativeMethods(env, "java/util/zip/CRC32", gMethods, NELEM(gMethods)); } diff --git a/archive/src/main/native/java_util_zip_Deflater.c b/archive/src/main/native/java_util_zip_Deflater.c index af0bfcc..59c7433 100644 --- a/archive/src/main/native/java_util_zip_Deflater.c +++ b/archive/src/main/native/java_util_zip_Deflater.c @@ -286,11 +286,7 @@ Java_java_util_zip_Deflater_oneTimeInitialization (JNIEnv * env, jclass clazz) gCachedFields.finished = (*env)->GetFieldID (env, clazz, "finished", "Z"); } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "setDictionaryImpl", "([BIIJ)V", Java_java_util_zip_Deflater_setDictionaryImpl }, { "getTotalInImpl", "(J)J", Java_java_util_zip_Deflater_getTotalInImpl }, { "getTotalOutImpl", "(J)J", Java_java_util_zip_Deflater_getTotalOutImpl }, @@ -303,8 +299,6 @@ static JNINativeMethod gMethods[] = { { "setLevelsImpl", "(IIJ)V", Java_java_util_zip_Deflater_setLevelsImpl }, { "oneTimeInitialization", "()V", Java_java_util_zip_Deflater_oneTimeInitialization }, }; -int register_java_util_zip_Deflater(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/util/zip/Deflater", - gMethods, NELEM(gMethods)); +int register_java_util_zip_Deflater(JNIEnv* env) { + return jniRegisterNativeMethods(env, "java/util/zip/Deflater", gMethods, NELEM(gMethods)); } diff --git a/archive/src/main/native/java_util_zip_Inflater.c b/archive/src/main/native/java_util_zip_Inflater.c index ba89ce8..6281081 100644 --- a/archive/src/main/native/java_util_zip_Inflater.c +++ b/archive/src/main/native/java_util_zip_Inflater.c @@ -322,11 +322,7 @@ Java_java_util_zip_Inflater_oneTimeInitialization (JNIEnv * env, jclass clazz) gCachedFields.needsDictionary = (*env)->GetFieldID (env, clazz, "needsDictionary", "Z"); } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "createStream", "(Z)J", Java_java_util_zip_Inflater_createStream }, { "setInputImpl", "([BIIJ)V", Java_java_util_zip_Inflater_setInputImpl }, { "setFileInputImpl", "(Ljava/io/FileDescriptor;JIJ)I", Java_java_util_zip_Inflater_setFileInputImpl }, @@ -339,8 +335,6 @@ static JNINativeMethod gMethods[] = { { "getTotalInImpl", "(J)J", Java_java_util_zip_Inflater_getTotalInImpl }, { "oneTimeInitialization", "()V", Java_java_util_zip_Inflater_oneTimeInitialization }, }; -int register_java_util_zip_Inflater(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/util/zip/Inflater", - gMethods, NELEM(gMethods)); +int register_java_util_zip_Inflater(JNIEnv* env) { + return jniRegisterNativeMethods(env, "java/util/zip/Inflater", gMethods, NELEM(gMethods)); } diff --git a/dalvik/src/main/native/dalvik_system_TouchDex.cpp b/dalvik/src/main/native/dalvik_system_TouchDex.cpp index e8b834b..b2614c9 100644 --- a/dalvik/src/main/native/dalvik_system_TouchDex.cpp +++ b/dalvik/src/main/native/dalvik_system_TouchDex.cpp @@ -259,20 +259,12 @@ static void logProcStatus(pid_t pid) fclose(fp); } -/* - * JNI registration. - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "trampoline", "(Ljava/lang/String;Ljava/lang/String;)I", (void*) dalvik_system_TouchDex_trampoline }, }; - -extern "C" int register_dalvik_system_TouchDex(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, JAVA_PACKAGE "/TouchDex", - gMethods, NELEM(gMethods)); +int register_dalvik_system_TouchDex(JNIEnv* env) { + return jniRegisterNativeMethods(env, JAVA_PACKAGE "/TouchDex", gMethods, NELEM(gMethods)); } }; // namespace android - diff --git a/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.c b/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.c index 25235dc..9aa0a8e 100644 --- a/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.c +++ b/dalvik/src/main/native/org_apache_harmony_dalvik_NativeTestTarget.c @@ -50,11 +50,7 @@ static void emptyJniStaticMethod6L(JNIEnv* env, jclass clazz, // This space intentionally left blank. } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "emptyJniStaticMethod0", "()V", emptyJniStaticMethod0 }, { "emptyJniStaticMethod6", "(IIIIII)V", emptyJniStaticMethod6 }, { "emptyJniStaticMethod6L", @@ -62,9 +58,7 @@ static JNINativeMethod gMethods[] = { "Ljava/lang/Object;[Ljava/lang/Object;[[[[Ljava/lang/Object;)V", emptyJniStaticMethod6L }, }; - -int register_org_apache_harmony_dalvik_NativeTestTarget(JNIEnv* env) -{ +int register_org_apache_harmony_dalvik_NativeTestTarget(JNIEnv* env) { int result = jniRegisterNativeMethods(env, "org/apache/harmony/dalvik/NativeTestTarget", gMethods, NELEM(gMethods)); @@ -75,4 +69,3 @@ int register_org_apache_harmony_dalvik_NativeTestTarget(JNIEnv* env) } return 0; } - diff --git a/icu/src/main/native/BidiWrapper.cpp b/icu/src/main/native/BidiWrapper.cpp index 7a25ff1..03efa92 100644 --- a/icu/src/main/native/BidiWrapper.cpp +++ b/icu/src/main/native/BidiWrapper.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ #define LOG_TAG "BidiWrapper" -#include "AndroidSystemNatives.h" + #include <JNIHelp.h> #include "ErrorCode.h" #include "UniquePtr.h" diff --git a/icu/src/main/native/ICU.cpp b/icu/src/main/native/ICU.cpp index 3066edb..1517932 100644 --- a/icu/src/main/native/ICU.cpp +++ b/icu/src/main/native/ICU.cpp @@ -15,8 +15,8 @@ */ #define LOG_TAG "ICU" + #include "JNIHelp.h" -#include "AndroidSystemNatives.h" #include "ScopedUtfChars.h" #include "UniquePtr.h" #include "cutils/log.h" @@ -679,7 +679,6 @@ static jboolean initLocaleDataImpl(JNIEnv* env, jclass, jstring locale, jobject } static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ {"getAvailableBreakIteratorLocalesNative", "()[Ljava/lang/String;", (void*) getAvailableBreakIteratorLocalesNative}, {"getAvailableCalendarLocalesNative", "()[Ljava/lang/String;", (void*) getAvailableCalendarLocalesNative}, {"getAvailableCollatorLocalesNative", "()[Ljava/lang/String;", (void*) getAvailableCollatorLocalesNative}, @@ -700,7 +699,6 @@ static JNINativeMethod gMethods[] = { {"getTimeZonesNative", "([[Ljava/lang/String;Ljava/lang/String;)V", (void*) getTimeZonesNative}, {"initLocaleDataImpl", "(Ljava/lang/String;Lcom/ibm/icu4jni/util/LocaleData;)Z", (void*) initLocaleDataImpl}, }; - int register_com_ibm_icu4jni_util_Resources(JNIEnv* env) { jclass stringclass = env->FindClass("java/lang/String"); if (stringclass == NULL) { diff --git a/icu/src/main/native/NativeBreakIterator.cpp b/icu/src/main/native/NativeBreakIterator.cpp index 5b12ba3..85ada2d 100644 --- a/icu/src/main/native/NativeBreakIterator.cpp +++ b/icu/src/main/native/NativeBreakIterator.cpp @@ -17,7 +17,6 @@ #define LOG_TAG "NativeBreakIterator" #include "JNIHelp.h" -#include "AndroidSystemNatives.h" #include "ErrorCode.h" #include "ScopedUtfChars.h" #include "unicode/ubrk.h" diff --git a/icu/src/main/native/NativeCollation.cpp b/icu/src/main/native/NativeCollation.cpp index 5bc7749..263a525 100644 --- a/icu/src/main/native/NativeCollation.cpp +++ b/icu/src/main/native/NativeCollation.cpp @@ -10,7 +10,6 @@ #define LOG_TAG "NativeCollation" #include "JNIHelp.h" -#include "AndroidSystemNatives.h" #include "ErrorCode.h" #include "unicode/ucol.h" #include "unicode/ucoleitr.h" @@ -499,7 +498,6 @@ static void setText(JNIEnv *env, jclass obj, jint address, } static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "openCollator", "()I", (void*) openCollator__ }, { "openCollator", "(Ljava/lang/String;)I", (void*) openCollator__Ljava_lang_String_2 }, { "openCollatorFromRules", "(Ljava/lang/String;II)I", (void*) openCollatorFromRules }, @@ -523,7 +521,6 @@ static JNINativeMethod gMethods[] = { { "getOffset", "(I)I", (void*) getOffset }, { "setOffset", "(II)V", (void*) setOffset } }; - int register_com_ibm_icu4jni_text_NativeCollator(JNIEnv *_env) { return jniRegisterNativeMethods(_env, "com/ibm/icu4jni/text/NativeCollation", gMethods, NELEM(gMethods)); diff --git a/icu/src/main/native/NativeConverter.cpp b/icu/src/main/native/NativeConverter.cpp index f227f3d..8cc6d15 100644 --- a/icu/src/main/native/NativeConverter.cpp +++ b/icu/src/main/native/NativeConverter.cpp @@ -17,7 +17,6 @@ #define LOG_TAG "NativeConverter" -#include "AndroidSystemNatives.h" #include "ErrorCode.h" #include "JNIHelp.h" #include "ScopedUtfChars.h" @@ -989,11 +988,7 @@ static jobject charsetForName(JNIEnv* env, jclass, jstring charsetName) { javaCanonicalName, env->NewStringUTF(icuCanonicalName), aliases); } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "canEncode", "(JI)Z", (void*) canEncode }, { "charsetForName", "(Ljava/lang/String;)Ljava/nio/charset/Charset;", (void*) charsetForName }, { "closeConverter", "(J)V", (void*) closeConverter }, @@ -1017,8 +1012,7 @@ static JNINativeMethod gMethods[] = { { "setSubstitutionBytes", "(J[BI)I", (void*) setSubstitutionBytes }, { "setSubstitutionChars", "(J[CI)I", (void*) setSubstitutionChars }, }; - -int register_com_ibm_icu4jni_converters_NativeConverter(JNIEnv *_env) { - return jniRegisterNativeMethods(_env, "com/ibm/icu4jni/charset/NativeConverter", +int register_com_ibm_icu4jni_converters_NativeConverter(JNIEnv* env) { + return jniRegisterNativeMethods(env, "com/ibm/icu4jni/charset/NativeConverter", gMethods, NELEM(gMethods)); } diff --git a/icu/src/main/native/NativeDecimalFormat.cpp b/icu/src/main/native/NativeDecimalFormat.cpp index 6909553..8f39a39 100644 --- a/icu/src/main/native/NativeDecimalFormat.cpp +++ b/icu/src/main/native/NativeDecimalFormat.cpp @@ -17,7 +17,6 @@ #define LOG_TAG "NativeDecimalFormat" #include "JNIHelp.h" -#include "AndroidSystemNatives.h" #include "cutils/log.h" #include "unicode/unum.h" #include "unicode/numfmt.h" @@ -586,7 +585,6 @@ static jint cloneDecimalFormatImpl(JNIEnv *env, jclass, jint addr) { } static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ {"applyPatternImpl", "(IZLjava/lang/String;)V", (void*) applyPatternImpl}, {"cloneDecimalFormatImpl", "(I)I", (void*) cloneDecimalFormatImpl}, {"closeDecimalFormatImpl", "(I)V", (void*) closeDecimalFormatImpl}, @@ -605,7 +603,6 @@ static JNINativeMethod gMethods[] = { {"toPatternImpl", "(IZ)Ljava/lang/String;", (void*) toPatternImpl}, }; int register_com_ibm_icu4jni_text_NativeDecimalFormat(JNIEnv* env) { - return jniRegisterNativeMethods(env, - "com/ibm/icu4jni/text/NativeDecimalFormat", gMethods, + return jniRegisterNativeMethods(env, "com/ibm/icu4jni/text/NativeDecimalFormat", gMethods, NELEM(gMethods)); } diff --git a/icu/src/main/native/NativeIDN.cpp b/icu/src/main/native/NativeIDN.cpp index 2b45dbe..e8052fc 100644 --- a/icu/src/main/native/NativeIDN.cpp +++ b/icu/src/main/native/NativeIDN.cpp @@ -61,6 +61,6 @@ static jstring convertImpl(JNIEnv* env, jclass, jstring s, jint flags, jboolean static JNINativeMethod gMethods[] = { {"convertImpl", "(Ljava/lang/String;IZ)Ljava/lang/String;", (void*) convertImpl}, }; -extern "C" int register_com_ibm_icu4jni_text_NativeIDN(JNIEnv* env) { +int register_com_ibm_icu4jni_text_NativeIDN(JNIEnv* env) { return jniRegisterNativeMethods(env, "com/ibm/icu4jni/text/NativeIDN", gMethods, NELEM(gMethods)); } diff --git a/icu/src/main/native/NativeNormalizer.cpp b/icu/src/main/native/NativeNormalizer.cpp index 663a7c1..257cf9b 100644 --- a/icu/src/main/native/NativeNormalizer.cpp +++ b/icu/src/main/native/NativeNormalizer.cpp @@ -41,11 +41,10 @@ static jboolean isNormalizedImpl(JNIEnv* env, jclass, jstring s, jint intMode) { } static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ {"normalizeImpl", "(Ljava/lang/String;I)Ljava/lang/String;", (void*) normalizeImpl}, {"isNormalizedImpl", "(Ljava/lang/String;I)Z", (void*) isNormalizedImpl}, }; -extern "C" int register_com_ibm_icu4jni_text_NativeNormalizer(JNIEnv* env) { - return jniRegisterNativeMethods(env, - "com/ibm/icu4jni/text/NativeNormalizer", gMethods, NELEM(gMethods)); +int register_com_ibm_icu4jni_text_NativeNormalizer(JNIEnv* env) { + return jniRegisterNativeMethods(env, "com/ibm/icu4jni/text/NativeNormalizer", + gMethods, NELEM(gMethods)); } diff --git a/icu/src/main/native/NativeRegEx.cpp b/icu/src/main/native/NativeRegEx.cpp index f8be4ee..511f1e4 100644 --- a/icu/src/main/native/NativeRegEx.cpp +++ b/icu/src/main/native/NativeRegEx.cpp @@ -16,8 +16,6 @@ #define LOG_TAG "NativeRegEx" -#include "AndroidSystemNatives.h" - #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/icu/src/main/native/UCharacter.cpp b/icu/src/main/native/UCharacter.cpp index 4186b75..1c5af48 100644 --- a/icu/src/main/native/UCharacter.cpp +++ b/icu/src/main/native/UCharacter.cpp @@ -15,8 +15,8 @@ */ #define LOG_TAG "UCharacter" + #include "JNIHelp.h" -#include "AndroidSystemNatives.h" #include "ScopedJavaUnicodeString.h" #include "ScopedUtfChars.h" #include "unicode/locid.h" @@ -171,11 +171,7 @@ static int ofImpl(JNIEnv*, jclass, jint codePoint) { return ublock_getCode(codePoint); } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "digit", "(II)I", (void*) digitImpl }, { "forName", "(Ljava/lang/String;)I", (void*) forNameImpl }, { "getDirectionality", "(I)B", (void*) getDirectionalityImpl }, @@ -201,7 +197,6 @@ static JNINativeMethod gMethods[] = { { "toLowerCase", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", (void*) toLowerCaseStringImpl }, { "toUpperCase", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", (void*) toUpperCaseStringImpl }, }; - int register_com_ibm_icu4jni_lang_UCharacter(JNIEnv* env) { return jniRegisterNativeMethods(env, "com/ibm/icu4jni/lang/UCharacter", gMethods, NELEM(gMethods)); diff --git a/include/ScopedLocalFrame.h b/include/ScopedLocalFrame.h new file mode 100644 index 0000000..35b6ad8 --- /dev/null +++ b/include/ScopedLocalFrame.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SCOPED_LOCAL_FRAME_H_included +#define SCOPED_LOCAL_FRAME_H_included + +#include "JNIHelp.h" + +class ScopedLocalFrame { +public: + ScopedLocalFrame(JNIEnv* env) : mEnv(env) { + mEnv->PushLocalFrame(128); + } + + ~ScopedLocalFrame() { + mEnv->PopLocalFrame(NULL); + } + +private: + JNIEnv* mEnv; + + // Disallow copy and assignment. + ScopedLocalFrame(const ScopedLocalFrame&); + void operator=(const ScopedLocalFrame&); +}; + +#endif // SCOPED_LOCAL_FRAME_H_included diff --git a/luni-kernel/src/main/native/Register.cpp b/luni-kernel/src/main/native/Register.cpp new file mode 100644 index 0000000..8980cc5 --- /dev/null +++ b/luni-kernel/src/main/native/Register.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ScopedLocalFrame.h" + +namespace android { + extern int register_dalvik_system_TouchDex(JNIEnv* env); +} + +extern int register_com_ibm_icu4jni_converters_NativeConverter(JNIEnv* env); +extern int register_com_ibm_icu4jni_lang_UCharacter(JNIEnv* env); +extern int register_com_ibm_icu4jni_regex_NativeRegEx(JNIEnv* env); +extern int register_com_ibm_icu4jni_text_NativeBreakIterator(JNIEnv* env); +extern int register_com_ibm_icu4jni_text_NativeCollator(JNIEnv* env); +extern int register_com_ibm_icu4jni_text_NativeDecimalFormat(JNIEnv* env); +extern int register_com_ibm_icu4jni_text_NativeIDN(JNIEnv* env); +extern int register_com_ibm_icu4jni_text_NativeNormalizer(JNIEnv* env); +extern int register_com_ibm_icu4jni_util_Resources(JNIEnv* env); +extern int register_java_io_Console(JNIEnv* env); +extern int register_java_io_File(JNIEnv* env); +extern "C" int register_java_io_FileDescriptor(JNIEnv* env); +extern "C" int register_java_io_ObjectInputStream(JNIEnv* env); +extern "C" int register_java_io_ObjectOutputStream(JNIEnv* env); +extern "C" int register_java_io_ObjectStreamClass(JNIEnv* env); +extern "C" int register_java_lang_Double(JNIEnv* env); +extern "C" int register_java_lang_Float(JNIEnv* env); +extern "C" int register_java_lang_Math(JNIEnv* env); +extern int register_java_lang_ProcessManager(JNIEnv* env); +extern "C" int register_java_lang_StrictMath(JNIEnv* env); +extern int register_java_lang_System(JNIEnv* env); +extern int register_java_net_InetAddress(JNIEnv* env); +extern int register_java_net_NetworkInterface(JNIEnv* env); +extern "C" int register_java_util_zip_Adler32(JNIEnv* env); +extern "C" int register_java_util_zip_CRC32(JNIEnv* env); +extern "C" int register_java_util_zip_Deflater(JNIEnv* env); +extern "C" int register_java_util_zip_Inflater(JNIEnv* env); +extern "C" int register_org_apache_harmony_dalvik_NativeTestTarget(JNIEnv* env); +extern int register_org_apache_harmony_luni_platform_OSFileSystem(JNIEnv* env); +extern int register_org_apache_harmony_luni_platform_OSMemory(JNIEnv* env); +extern int register_org_apache_harmony_luni_platform_OSNetworkSystem(JNIEnv* env); +extern "C" int register_org_apache_harmony_luni_util_NumberConvert(JNIEnv* env); +extern "C" int register_org_apache_harmony_luni_util_fltparse(JNIEnv* env); +extern int register_org_apache_harmony_text_BidiWrapper(JNIEnv* env); +extern int register_org_apache_harmony_xml_ExpatParser(JNIEnv* env); +extern int register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(JNIEnv* env); +extern "C" int register_org_openssl_NativeBN(JNIEnv* env); + +// DalvikVM calls this on startup, so we can statically register all our native methods. +extern "C" int registerCoreLibrariesJni(JNIEnv* env) { + ScopedLocalFrame localFrame(env); + + bool result = + register_com_ibm_icu4jni_converters_NativeConverter(env) != -1 && + register_com_ibm_icu4jni_lang_UCharacter(env) != -1 && + register_com_ibm_icu4jni_regex_NativeRegEx(env) != -1 && + register_com_ibm_icu4jni_text_NativeBreakIterator(env) != -1 && + register_com_ibm_icu4jni_text_NativeCollator(env) != -1 && + register_com_ibm_icu4jni_text_NativeDecimalFormat(env) != -1 && + register_com_ibm_icu4jni_text_NativeIDN(env) != -1 && + register_com_ibm_icu4jni_text_NativeNormalizer(env) != -1 && + register_com_ibm_icu4jni_util_Resources(env) != -1 && + register_java_io_Console(env) != -1 && + register_java_io_File(env) != -1 && + register_java_io_FileDescriptor(env) != -1 && + register_java_io_ObjectInputStream(env) != -1 && + register_java_io_ObjectOutputStream(env) != -1 && + register_java_io_ObjectStreamClass(env) != -1 && + register_java_lang_Double(env) != -1 && + register_java_lang_Float(env) != -1 && + register_java_lang_Math(env) != -1 && + register_java_lang_ProcessManager(env) != -1 && + register_java_lang_StrictMath(env) != -1 && + register_java_lang_System(env) != -1 && + register_java_net_InetAddress(env) != -1 && + register_java_net_NetworkInterface(env) != -1 && + register_java_util_zip_Adler32(env) != -1 && + register_java_util_zip_CRC32(env) != -1 && + register_java_util_zip_Deflater(env) != -1 && + register_java_util_zip_Inflater(env) != -1 && + register_org_apache_harmony_luni_platform_OSFileSystem(env) != -1 && + register_org_apache_harmony_luni_platform_OSMemory(env) != -1 && + register_org_apache_harmony_luni_platform_OSNetworkSystem(env) != -1 && + register_org_apache_harmony_luni_util_NumberConvert(env) != -1 && + register_org_apache_harmony_luni_util_fltparse(env) != -1 && + register_org_apache_harmony_text_BidiWrapper(env) != -1 && + register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(env) != -1 && + register_org_openssl_NativeBN(env) != -1 && + // Initialize the Android classes last, as they have dependencies on the "corer" core classes. + android::register_dalvik_system_TouchDex(env) != -1 && + register_org_apache_harmony_dalvik_NativeTestTarget(env) != -1 && + register_org_apache_harmony_xml_ExpatParser(env) != -1; + + return result ? 0 : -1; +} diff --git a/luni-kernel/src/main/native/java_lang_ProcessManager.cpp b/luni-kernel/src/main/native/java_lang_ProcessManager.cpp index 045d980..666a8c7 100644 --- a/luni-kernel/src/main/native/java_lang_ProcessManager.cpp +++ b/luni-kernel/src/main/native/java_lang_ProcessManager.cpp @@ -29,7 +29,6 @@ #include "jni.h" #include "JNIHelp.h" #include "utils/Log.h" -#include "AndroidSystemNatives.h" /** Environment variables. */ extern char **environ; @@ -415,8 +414,6 @@ static JNINativeMethod methods[] = { { "exec", "([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;Z)I", (void*) java_lang_ProcessManager_exec }, }; - int register_java_lang_ProcessManager(JNIEnv* env) { - return jniRegisterNativeMethods( - env, "java/lang/ProcessManager", methods, NELEM(methods)); + return jniRegisterNativeMethods(env, "java/lang/ProcessManager", methods, NELEM(methods)); } diff --git a/luni-kernel/src/main/native/java_lang_System.cpp b/luni-kernel/src/main/native/java_lang_System.cpp index 52150d3..b114dab 100644 --- a/luni-kernel/src/main/native/java_lang_System.cpp +++ b/luni-kernel/src/main/native/java_lang_System.cpp @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "AndroidSystemNatives.h" #include "JNIHelp.h" #include <stdlib.h> @@ -84,17 +83,11 @@ static void java_setFieldImpl(JNIEnv* env, jclass clazz, env->ReleaseStringUTFChars(sig, fieldSig); } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "getEnvByName", "(Ljava/lang/String;)Ljava/lang/String;", (void*) java_getEnvByName }, { "getEnvByIndex", "(I)Ljava/lang/String;", (void*) java_getEnvByIndex }, { "setFieldImpl", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V", (void*) java_setFieldImpl }, }; - int register_java_lang_System(JNIEnv* env) { - return jniRegisterNativeMethods(env, "java/lang/System", - gMethods, NELEM(gMethods)); + return jniRegisterNativeMethods(env, "java/lang/System", gMethods, NELEM(gMethods)); } diff --git a/luni-kernel/src/main/native/sub.mk b/luni-kernel/src/main/native/sub.mk index fcb7d0d..7f6417b 100644 --- a/luni-kernel/src/main/native/sub.mk +++ b/luni-kernel/src/main/native/sub.mk @@ -4,7 +4,8 @@ LOCAL_SRC_FILES := \ java_lang_ProcessManager.cpp \ - java_lang_System.cpp + java_lang_System.cpp \ + Register.cpp LOCAL_C_INCLUDES += diff --git a/luni/src/main/native/java_io_Console.cpp b/luni/src/main/native/java_io_Console.cpp index ee48383..fdaafaf 100644 --- a/luni/src/main/native/java_io_Console.cpp +++ b/luni/src/main/native/java_io_Console.cpp @@ -15,7 +15,6 @@ * limitations under the License. */ -#include "AndroidSystemNatives.h" #include "JNIHelp.h" #include <errno.h> @@ -46,7 +45,6 @@ static jint java_io_Console_setEcho(JNIEnv* env, jclass, jboolean on, jint previ } static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "isatty", "(I)Z", (void*) java_io_Console_isatty }, { "setEchoImpl", "(ZI)I", (void*) java_io_Console_setEcho }, }; diff --git a/luni/src/main/native/java_io_File.cpp b/luni/src/main/native/java_io_File.cpp index 3006275..dc25057 100644 --- a/luni/src/main/native/java_io_File.cpp +++ b/luni/src/main/native/java_io_File.cpp @@ -15,7 +15,6 @@ * limitations under the License. */ -#include "AndroidSystemNatives.h" #include "JNIHelp.h" #include "LocalArray.h" #include "ScopedByteArray.h" @@ -395,7 +394,6 @@ static jboolean java_io_File_renameToImpl(JNIEnv* env, jobject, jbyteArray oldPa } static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "canExecuteImpl", "([B)Z", (void*) java_io_File_canExecuteImpl }, { "canReadImpl", "([B)Z", (void*) java_io_File_canReadImpl }, { "canWriteImpl", "([B)Z", (void*) java_io_File_canWriteImpl }, @@ -420,6 +418,5 @@ static JNINativeMethod gMethods[] = { { "setLastModifiedImpl","([BJ)Z", (void*) java_io_File_setLastModifiedImpl }, }; int register_java_io_File(JNIEnv* env) { - return jniRegisterNativeMethods(env, "java/io/File", - gMethods, NELEM(gMethods)); + return jniRegisterNativeMethods(env, "java/io/File", gMethods, NELEM(gMethods)); } diff --git a/luni/src/main/native/java_io_FileDescriptor.c b/luni/src/main/native/java_io_FileDescriptor.c index 897e688..075e19b 100644 --- a/luni/src/main/native/java_io_FileDescriptor.c +++ b/luni/src/main/native/java_io_FileDescriptor.c @@ -185,15 +185,10 @@ void jniSetFileDescriptorOfFD (JNIEnv* env, jobject fileDescriptor, int value) { setFd(env, fileDescriptor, value); } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "oneTimeInitialization", "()V", nativeClassInit }, { "syncImpl", "()V", fd_sync } }; int register_java_io_FileDescriptor(JNIEnv* env) { - return jniRegisterNativeMethods(env, "java/io/FileDescriptor", - gMethods, NELEM(gMethods)); + return jniRegisterNativeMethods(env, "java/io/FileDescriptor", gMethods, NELEM(gMethods)); } diff --git a/luni/src/main/native/java_io_ObjectInputStream.c b/luni/src/main/native/java_io_ObjectInputStream.c index 3519055..0aa56b0 100644 --- a/luni/src/main/native/java_io_ObjectInputStream.c +++ b/luni/src/main/native/java_io_ObjectInputStream.c @@ -16,7 +16,6 @@ */ #include "JNIHelp.h" -#include "AndroidSystemNatives.h" static void java_setFieldBool (JNIEnv * env, jclass clazz, jobject targetObject, @@ -244,11 +243,7 @@ static void java_setFieldObj (JNIEnv * env, jclass clazz, } } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "setField", "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;J)V", (void*) java_setFieldLong }, @@ -282,6 +277,5 @@ static JNINativeMethod gMethods[] = { }; int register_java_io_ObjectInputStream(JNIEnv* env) { - return jniRegisterNativeMethods(env, "java/io/ObjectInputStream", - gMethods, NELEM(gMethods)); + return jniRegisterNativeMethods(env, "java/io/ObjectInputStream", gMethods, NELEM(gMethods)); } diff --git a/luni/src/main/native/java_io_ObjectOutputStream.c b/luni/src/main/native/java_io_ObjectOutputStream.c index e465bc2..d6432c7 100644 --- a/luni/src/main/native/java_io_ObjectOutputStream.c +++ b/luni/src/main/native/java_io_ObjectOutputStream.c @@ -16,7 +16,6 @@ */ #include "JNIHelp.h" -#include "AndroidSystemNatives.h" static jlong java_getFieldLong(JNIEnv * env, jclass clazz, jobject targetObject, @@ -205,11 +204,7 @@ static jint java_getFieldInt(JNIEnv * env, jclass clazz, } } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "getFieldLong", "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;)J", (void*) java_getFieldLong }, @@ -240,7 +235,5 @@ static JNINativeMethod gMethods[] = { }; int register_java_io_ObjectOutputStream(JNIEnv* env) { - return jniRegisterNativeMethods(env, "java/io/ObjectOutputStream", - gMethods, NELEM(gMethods)); + return jniRegisterNativeMethods(env, "java/io/ObjectOutputStream", gMethods, NELEM(gMethods)); } - diff --git a/luni/src/main/native/java_io_ObjectStreamClass.c b/luni/src/main/native/java_io_ObjectStreamClass.c index c3fb518..935ff37 100644 --- a/luni/src/main/native/java_io_ObjectStreamClass.c +++ b/luni/src/main/native/java_io_ObjectStreamClass.c @@ -16,7 +16,6 @@ */ #include "JNIHelp.h" -#include "AndroidSystemNatives.h" static jobject java_io_osc_getFieldSignature(JNIEnv * env, jclass clazz, jobject reflectField) { @@ -109,11 +108,7 @@ static void java_io_osc_oneTimeInitialization(JNIEnv * env, jclass clazz) { // dummy to stay compatible to harmony } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "getFieldSignature", "(Ljava/lang/reflect/Field;)Ljava/lang/String;", (void*) java_io_osc_getFieldSignature }, @@ -129,6 +124,5 @@ static JNINativeMethod gMethods[] = { (void*) java_io_osc_oneTimeInitialization } }; int register_java_io_ObjectStreamClass(JNIEnv* env) { - return jniRegisterNativeMethods(env, "java/io/ObjectStreamClass", - gMethods, NELEM(gMethods)); + return jniRegisterNativeMethods(env, "java/io/ObjectStreamClass", gMethods, NELEM(gMethods)); } diff --git a/luni/src/main/native/java_lang_Double.c b/luni/src/main/native/java_lang_Double.c index fd4b7f1..9cc0869 100644 --- a/luni/src/main/native/java_lang_Double.c +++ b/luni/src/main/native/java_lang_Double.c @@ -60,18 +60,11 @@ static jdouble longBitsToDouble(JNIEnv* env, jclass clazz, jlong val) return d.d; } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "doubleToLongBits", "(D)J", doubleToLongBits }, { "doubleToRawLongBits", "(D)J", doubleToRawLongBits }, { "longBitsToDouble", "(J)D", longBitsToDouble }, }; -int register_java_lang_Double(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/lang/Double", - gMethods, NELEM(gMethods)); +int register_java_lang_Double(JNIEnv* env) { + return jniRegisterNativeMethods(env, "java/lang/Double", gMethods, NELEM(gMethods)); } - diff --git a/luni/src/main/native/java_lang_Float.c b/luni/src/main/native/java_lang_Float.c index 2a7af21..6426495 100644 --- a/luni/src/main/native/java_lang_Float.c +++ b/luni/src/main/native/java_lang_Float.c @@ -68,18 +68,11 @@ static jfloat intBitsToFloat(JNIEnv* env, jclass clazz, jint val) return f.f; } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "floatToIntBits", "(F)I", floatToIntBits }, { "floatToRawIntBits", "(F)I", floatToRawBits }, { "intBitsToFloat", "(I)F", intBitsToFloat }, }; -int register_java_lang_Float(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/lang/Float", - gMethods, NELEM(gMethods)); +int register_java_lang_Float(JNIEnv* env) { + return jniRegisterNativeMethods(env, "java/lang/Float", gMethods, NELEM(gMethods)); } - diff --git a/luni/src/main/native/java_lang_Math.c b/luni/src/main/native/java_lang_Math.c index 90cb9b5..2092c2d 100644 --- a/luni/src/main/native/java_lang_Math.c +++ b/luni/src/main/native/java_lang_Math.c @@ -169,11 +169,7 @@ static jfloat copySign_f(JNIEnv* env, jclass clazz, jfloat a, jfloat b) { return copysignf(a, isnan(b) ? 1.0 : b); } -/* - * JNI registration. - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "IEEEremainder", "(DD)D", jieee_remainder }, { "acos", "(D)D", jacos }, { "asin", "(D)D", jasin }, @@ -203,8 +199,6 @@ static JNINativeMethod gMethods[] = { { "tanh", "(D)D", jtanh }, }; -int register_java_lang_Math(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/lang/Math", gMethods, - NELEM(gMethods)); +int register_java_lang_Math(JNIEnv* env) { + return jniRegisterNativeMethods(env, "java/lang/Math", gMethods, NELEM(gMethods)); } diff --git a/luni/src/main/native/java_lang_StrictMath.c b/luni/src/main/native/java_lang_StrictMath.c index cb0f87e..651e2dd 100644 --- a/luni/src/main/native/java_lang_StrictMath.c +++ b/luni/src/main/native/java_lang_StrictMath.c @@ -184,11 +184,7 @@ static jfloat jnextafterf(JNIEnv* env, jclass clazz, jfloat arg1, jfloat arg2) return arg1; } -/* - * JNI registration. - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "IEEEremainder", "(DD)D", jieee_remainder }, { "acos", "(D)D", jacos }, { "asin", "(D)D", jasin }, @@ -216,8 +212,6 @@ static JNINativeMethod gMethods[] = { { "tanh", "(D)D", jtanh }, }; -int register_java_lang_StrictMath(JNIEnv* env) -{ - return jniRegisterNativeMethods(env, "java/lang/StrictMath", gMethods, - NELEM(gMethods)); +int register_java_lang_StrictMath(JNIEnv* env) { + return jniRegisterNativeMethods(env, "java/lang/StrictMath", gMethods, NELEM(gMethods)); } diff --git a/luni/src/main/native/java_net_InetAddress.cpp b/luni/src/main/native/java_net_InetAddress.cpp index 62318e9..2fc575a 100644 --- a/luni/src/main/native/java_net_InetAddress.cpp +++ b/luni/src/main/native/java_net_InetAddress.cpp @@ -214,17 +214,12 @@ static jstring InetAddress_getnameinfo(JNIEnv* env, jobject obj, return env->NewStringUTF(name); } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "getaddrinfo", "(Ljava/lang/String;)[[B", (void*) InetAddress_getaddrinfo }, { "gethostname", "()Ljava/lang/String;", (void*) InetAddress_gethostname }, { "getnameinfo", "([B)Ljava/lang/String;", (void*) InetAddress_getnameinfo }, }; - -extern "C" int register_java_net_InetAddress(JNIEnv* env) { +int register_java_net_InetAddress(JNIEnv* env) { jclass tempClass = env->FindClass("[B"); if (tempClass) { byteArrayClass = (jclass) env->NewGlobalRef(tempClass); diff --git a/luni/src/main/native/java_net_NetworkInterface.cpp b/luni/src/main/native/java_net_NetworkInterface.cpp index 4aea781..16b4619 100644 --- a/luni/src/main/native/java_net_NetworkInterface.cpp +++ b/luni/src/main/native/java_net_NetworkInterface.cpp @@ -15,7 +15,6 @@ * limitations under the License. */ -#include "AndroidSystemNatives.h" #include "JNIHelp.h" #include "jni.h" #include "ScopedFd.h" @@ -229,7 +228,6 @@ static jboolean supportsMulticastImpl(JNIEnv* env, jclass, jstring name, jint in } static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "getAllInterfaceAddressesImpl", "()[Ljava/net/InterfaceAddress;", (void*) getAllInterfaceAddressesImpl }, { "getHardwareAddressImpl", "(Ljava/lang/String;I)[B", (void*) getHardwareAddressImpl }, { "getMTUImpl", "(Ljava/lang/String;I)I", (void*) getMTUImpl }, @@ -239,6 +237,5 @@ static JNINativeMethod gMethods[] = { { "supportsMulticastImpl", "(Ljava/lang/String;I)Z", (void*) supportsMulticastImpl }, }; int register_java_net_NetworkInterface(JNIEnv* env) { - return jniRegisterNativeMethods(env, "java/net/NetworkInterface", - gMethods, NELEM(gMethods)); + return jniRegisterNativeMethods(env, "java/net/NetworkInterface", gMethods, NELEM(gMethods)); } diff --git a/luni/src/main/native/org_apache_harmony_luni_platform_OSFileSystem.cpp b/luni/src/main/native/org_apache_harmony_luni_platform_OSFileSystem.cpp index c33cbed..af82efc 100644 --- a/luni/src/main/native/org_apache_harmony_luni_platform_OSFileSystem.cpp +++ b/luni/src/main/native/org_apache_harmony_luni_platform_OSFileSystem.cpp @@ -38,7 +38,6 @@ #define HyOpenSync 128 #define SHARED_LOCK_TYPE 1L -#include "AndroidSystemNatives.h" #include "JNIHelp.h" #include "LocalArray.h" #include "ScopedByteArray.h" @@ -501,11 +500,7 @@ static jint harmony_io_ioctlAvailable(JNIEnv*env, jobject, jobject fileDescripto return (jint) avail; } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "close", "(I)V", (void*) harmony_io_close }, { "fflush", "(IZ)V", (void*) harmony_io_fflush }, { "getAllocGranularity","()I", (void*) harmony_io_getAllocGranularity }, @@ -524,8 +519,7 @@ static JNINativeMethod gMethods[] = { { "writeImpl", "(I[BII)J", (void*) harmony_io_writeImpl }, { "writev", "(I[I[I[II)J",(void*) harmony_io_writev }, }; -int register_org_apache_harmony_luni_platform_OSFileSystem(JNIEnv* _env) { - return jniRegisterNativeMethods(_env, - "org/apache/harmony/luni/platform/OSFileSystem", gMethods, +int register_org_apache_harmony_luni_platform_OSFileSystem(JNIEnv* env) { + return jniRegisterNativeMethods(env, "org/apache/harmony/luni/platform/OSFileSystem", gMethods, NELEM(gMethods)); } diff --git a/luni/src/main/native/org_apache_harmony_luni_platform_OSMemory.cpp b/luni/src/main/native/org_apache_harmony_luni_platform_OSMemory.cpp index 1d63faf..d1dafdb 100644 --- a/luni/src/main/native/org_apache_harmony_luni_platform_OSMemory.cpp +++ b/luni/src/main/native/org_apache_harmony_luni_platform_OSMemory.cpp @@ -15,8 +15,8 @@ */ #define LOG_TAG "OSMemory" + #include "JNIHelp.h" -#include "AndroidSystemNatives.h" #include "utils/misc.h" #include "utils/Log.h" #include <sys/mman.h> @@ -535,11 +535,7 @@ static jint harmony_nio_flushImpl(JNIEnv *_env, jobject _this, jint address, return msync((void *)address, size, MS_SYNC); } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "isLittleEndianImpl", "()Z", (void*) harmony_nio_littleEndian }, { "getPointerSizeImpl", "()I", (void*) harmony_nio_getPointerSizeImpl }, { "malloc", "(I)I", (void*) harmony_nio_mallocImpl }, @@ -570,7 +566,7 @@ static JNINativeMethod gMethods[] = { { "isLoadedImpl", "(IJ)Z", (void*) harmony_nio_isLoadedImpl }, { "flushImpl", "(IJ)I", (void*) harmony_nio_flushImpl } }; -int register_org_apache_harmony_luni_platform_OSMemory(JNIEnv *_env) { +int register_org_apache_harmony_luni_platform_OSMemory(JNIEnv* env) { /* * We need to call VMRuntime.trackExternal{Allocation,Free}. Cache * method IDs and a reference to the singleton. @@ -579,16 +575,16 @@ int register_org_apache_harmony_luni_platform_OSMemory(JNIEnv *_env) { jmethodID method_getRuntime; jclass clazz; - clazz = _env->FindClass(kVMRuntimeName); + clazz = env->FindClass(kVMRuntimeName); if (clazz == NULL) { LOGE("Unable to find class %s\n", kVMRuntimeName); return -1; } - gIDCache.method_trackExternalAllocation = _env->GetMethodID(clazz, + gIDCache.method_trackExternalAllocation = env->GetMethodID(clazz, "trackExternalAllocation", "(J)Z"); - gIDCache.method_trackExternalFree = _env->GetMethodID(clazz, + gIDCache.method_trackExternalFree = env->GetMethodID(clazz, "trackExternalFree", "(J)V"); - method_getRuntime = _env->GetStaticMethodID(clazz, + method_getRuntime = env->GetStaticMethodID(clazz, "getRuntime", "()Ldalvik/system/VMRuntime;"); if (gIDCache.method_trackExternalAllocation == NULL || @@ -599,17 +595,13 @@ int register_org_apache_harmony_luni_platform_OSMemory(JNIEnv *_env) { return -1; } - jobject instance = _env->CallStaticObjectMethod(clazz, method_getRuntime); + jobject instance = env->CallStaticObjectMethod(clazz, method_getRuntime); if (instance == NULL) { LOGE("Unable to obtain VMRuntime instance\n"); return -1; } - gIDCache.runtimeInstance = _env->NewGlobalRef(instance); + gIDCache.runtimeInstance = env->NewGlobalRef(instance); - /* - * Register methods. - */ - return jniRegisterNativeMethods(_env, - "org/apache/harmony/luni/platform/OSMemory", - gMethods, NELEM(gMethods)); + return jniRegisterNativeMethods(env, "org/apache/harmony/luni/platform/OSMemory", + gMethods, NELEM(gMethods)); } diff --git a/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp b/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp index f3ba44a..0dbb070 100644 --- a/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp +++ b/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp @@ -23,7 +23,6 @@ #define LOG_TAG "OSNetworkSystem" -#include "AndroidSystemNatives.h" #include "JNIHelp.h" #include "LocalArray.h" #include "jni.h" @@ -2834,11 +2833,7 @@ static void osNetworkSystem_socketClose(JNIEnv* env, jobject, jobject fileDescri close(fd); } -/* - * JNI registration. - */ static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ { "accept", "(Ljava/io/FileDescriptor;Ljava/net/SocketImpl;Ljava/io/FileDescriptor;I)V",(void*) osNetworkSystem_accept }, { "bind", "(Ljava/io/FileDescriptor;Ljava/net/InetAddress;I)V", (void*) osNetworkSystem_bind }, { "byteArrayToIpString", "([B)Ljava/lang/String;", (void*) osNetworkSystem_byteArrayToIpString }, @@ -2878,11 +2873,8 @@ static JNINativeMethod gMethods[] = { { "writeDirect", "(Ljava/io/FileDescriptor;III)I", (void*) osNetworkSystem_writeDirect }, { "write", "(Ljava/io/FileDescriptor;[BII)I", (void*) osNetworkSystem_write }, }; - int register_org_apache_harmony_luni_platform_OSNetworkSystem(JNIEnv* env) { return initCachedFields(env) && jniRegisterNativeMethods(env, - "org/apache/harmony/luni/platform/OSNetworkSystem", - gMethods, - NELEM(gMethods)); + "org/apache/harmony/luni/platform/OSNetworkSystem", gMethods, NELEM(gMethods)); } // END android-changed diff --git a/luni/src/main/native/org_apache_harmony_luni_util_NumberConvert.c b/luni/src/main/native/org_apache_harmony_luni_util_NumberConvert.c index 70761fb..496fe6f 100644 --- a/luni/src/main/native/org_apache_harmony_luni_util_NumberConvert.c +++ b/luni/src/main/native/org_apache_harmony_luni_util_NumberConvert.c @@ -271,21 +271,13 @@ Java_org_apache_harmony_luni_util_NumberConverter_bigIntDigitGeneratorInstImpl ( fid = (*env)->GetFieldID (env, clazz, "firstK", "I"); (*env)->SetIntField (env, inst, fid, firstK); - } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* NAME, SIGNATURE, FUNCPTR */ { "bigIntDigitGeneratorInstImpl", "(JIZZI)V" , Java_org_apache_harmony_luni_util_NumberConverter_bigIntDigitGeneratorInstImpl }, }; - -int register_org_apache_harmony_luni_util_NumberConvert(JNIEnv *env) -{ - return jniRegisterNativeMethods(env, - "org/apache/harmony/luni/util/NumberConverter", +int register_org_apache_harmony_luni_util_NumberConvert(JNIEnv *env) { + return jniRegisterNativeMethods(env, "org/apache/harmony/luni/util/NumberConverter", gMethods, NELEM(gMethods)); } diff --git a/luni/src/main/native/org_apache_harmony_luni_util_fltparse.c b/luni/src/main/native/org_apache_harmony_luni_util_fltparse.c index 80f2bee..daef934 100644 --- a/luni/src/main/native/org_apache_harmony_luni_util_fltparse.c +++ b/luni/src/main/native/org_apache_harmony_luni_util_fltparse.c @@ -589,19 +589,13 @@ Java_org_apache_harmony_luni_util_FloatingPointParser_parseDblImpl (JNIEnv * env return 0.0; } -/* - * JNI registration - */ static JNINativeMethod gMethods[] = { - /* NAME, SIGNATURE, FUNCPTR */ { "parseFltImpl", "(Ljava/lang/String;I)F", Java_org_apache_harmony_luni_util_FloatingPointParser_parseFltImpl }, { "parseDblImpl", "(Ljava/lang/String;I)D", Java_org_apache_harmony_luni_util_FloatingPointParser_parseDblImpl }, }; -int register_org_apache_harmony_luni_util_fltparse(JNIEnv *env) -{ - return jniRegisterNativeMethods(env, - "org/apache/harmony/luni/util/FloatingPointParser", +int register_org_apache_harmony_luni_util_fltparse(JNIEnv *env) { + return jniRegisterNativeMethods(env, "org/apache/harmony/luni/util/FloatingPointParser", gMethods, NELEM(gMethods)); } diff --git a/openssl/src/main/native/BNInterface.c b/openssl/src/main/native/BNInterface.c index 8ac2395..07f0288 100644 --- a/openssl/src/main/native/BNInterface.c +++ b/openssl/src/main/native/BNInterface.c @@ -650,12 +650,6 @@ static jboolean NativeBN_BN_is_prime_ex(JNIEnv* env, jclass cls, BIGNUM* p, int return BN_is_prime_ex(p, nchecks, ctx, (BN_GENCB*) cb); } - -/** - * Defines the mapping from Java methods and their signatures - * to native functions. Order is Java name, Java signature, - * then pointer to C function. - */ static JNINativeMethod METHODS[] = { { "ERR_get_error", "()I", (void*)NativeBN_ERR_get_error }, { "ERR_error_string", "(I)Ljava/lang/String;", (void*)NativeBN_ERR_error_string }, @@ -699,7 +693,6 @@ static JNINativeMethod METHODS[] = { { "BN_generate_prime_ex", "(IIZIII)Z", (void*)NativeBN_BN_generate_prime_ex }, { "BN_is_prime_ex", "(IIII)Z", (void*)NativeBN_BN_is_prime_ex } }; - int register_org_openssl_NativeBN(JNIEnv* env) { return jniRegisterNativeMethods(env, "org/openssl/NativeBN", METHODS, NELEM(METHODS)); } diff --git a/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp b/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp index da91a99..08628f2 100644 --- a/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp +++ b/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp @@ -2386,15 +2386,7 @@ static JNINativeClass sClasses[] = { { "org/apache/harmony/xnet/provider/jsse/OpenSSLServerSocketImpl", sServerSocketImplMethods, NELEM(sServerSocketImplMethods) }, { "org/apache/harmony/xnet/provider/jsse/OpenSSLSessionImpl", sSessionImplMethods, NELEM(sSessionImplMethods) }, }; - -/* - * Peforms the actual registration of the native methods. - * Also looks up the fields that belong to the class (if - * any) and stores the field IDs. Simply remove what you - * don't need. - */ -extern "C" int register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(JNIEnv* env) { - +int register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(JNIEnv* env) { // Register org.apache.harmony.xnet.provider.jsse.* methods for (int i = 0; i < NELEM(sClasses); i++) { int result = jniRegisterNativeMethods(env, diff --git a/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp b/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp index d4fc557..c684708 100644 --- a/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp +++ b/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp @@ -1526,11 +1526,7 @@ static JNINativeMethod attributeMethods[] = { (void*) getAttributeValueForQName }, { "freeAttributes", "(I)V", (void*) freeAttributes }, }; - -/** - * Called from Register.c. - */ -extern "C" int register_org_apache_harmony_xml_ExpatParser(JNIEnv* env) { +int register_org_apache_harmony_xml_ExpatParser(JNIEnv* env) { int result = jniRegisterNativeMethods(env, "org/apache/harmony/xml/ExpatParser", parserMethods, NELEM(parserMethods)); if (result != 0) { |