Home | History | Annotate | Download | only in native
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #define LOG_TAG "libcore" // We'll be next to "dalvikvm" in the log; make the distinction clear.
     18 
     19 #include "JniConstants.h"
     20 #include "ScopedLocalFrame.h"
     21 
     22 #include <stdlib.h>
     23 
     24 extern int register_java_io_Console(JNIEnv* env);
     25 extern int register_java_io_File(JNIEnv* env);
     26 extern int register_java_io_ObjectStreamClass(JNIEnv* env);
     27 extern int register_java_lang_Character(JNIEnv* env);
     28 extern int register_java_lang_Math(JNIEnv* env);
     29 extern int register_java_lang_ProcessManager(JNIEnv* env);
     30 extern int register_java_lang_RealToString(JNIEnv* env);
     31 extern int register_java_lang_StrictMath(JNIEnv* env);
     32 extern int register_java_lang_StringToReal(JNIEnv* env);
     33 extern int register_java_lang_System(JNIEnv* env);
     34 extern int register_java_math_NativeBN(JNIEnv* env);
     35 extern int register_java_nio_ByteOrder(JNIEnv* env);
     36 extern int register_java_nio_charset_Charsets(JNIEnv* env);
     37 extern int register_java_text_Bidi(JNIEnv* env);
     38 extern int register_java_util_regex_Matcher(JNIEnv* env);
     39 extern int register_java_util_regex_Pattern(JNIEnv* env);
     40 extern int register_java_util_zip_Adler32(JNIEnv* env);
     41 extern int register_java_util_zip_CRC32(JNIEnv* env);
     42 extern int register_java_util_zip_Deflater(JNIEnv* env);
     43 extern int register_java_util_zip_Inflater(JNIEnv* env);
     44 extern int register_libcore_icu_ICU(JNIEnv* env);
     45 extern int register_libcore_icu_NativeBreakIterator(JNIEnv* env);
     46 extern int register_libcore_icu_NativeCollation(JNIEnv* env);
     47 extern int register_libcore_icu_NativeConverter(JNIEnv* env);
     48 extern int register_libcore_icu_NativeDecimalFormat(JNIEnv* env);
     49 extern int register_libcore_icu_NativeIDN(JNIEnv* env);
     50 extern int register_libcore_icu_NativeNormalizer(JNIEnv* env);
     51 extern int register_libcore_icu_NativePluralRules(JNIEnv* env);
     52 extern int register_libcore_icu_TimeZones(JNIEnv* env);
     53 extern int register_libcore_io_AsynchronousCloseMonitor(JNIEnv* env);
     54 extern int register_libcore_io_Memory(JNIEnv* env);
     55 extern int register_libcore_io_OsConstants(JNIEnv* env);
     56 extern int register_libcore_io_Posix(JNIEnv* env);
     57 extern int register_libcore_net_RawSocket(JNIEnv* env);
     58 extern int register_org_apache_harmony_dalvik_NativeTestTarget(JNIEnv* env);
     59 extern int register_org_apache_harmony_xml_ExpatParser(JNIEnv* env);
     60 extern int register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(JNIEnv* env);
     61 
     62 // DalvikVM calls this on startup, so we can statically register all our native methods.
     63 int registerCoreLibrariesJni(JNIEnv* env) {
     64     ScopedLocalFrame localFrame(env);
     65 
     66     JniConstants::init(env);
     67 
     68     bool result =
     69             register_java_io_Console(env) != -1 &&
     70             register_java_io_File(env) != -1 &&
     71             register_java_io_ObjectStreamClass(env) != -1 &&
     72             register_java_lang_Character(env) != -1 &&
     73             register_java_lang_Math(env) != -1 &&
     74             register_java_lang_ProcessManager(env) != -1 &&
     75             register_java_lang_RealToString(env) != -1 &&
     76             register_java_lang_StrictMath(env) != -1 &&
     77             register_java_lang_StringToReal(env) != -1 &&
     78             register_java_lang_System(env) != -1 &&
     79             register_java_math_NativeBN(env) != -1 &&
     80             register_java_nio_ByteOrder(env) != -1 &&
     81             register_java_nio_charset_Charsets(env) != -1 &&
     82             register_java_text_Bidi(env) != -1 &&
     83             register_java_util_regex_Matcher(env) != -1 &&
     84             register_java_util_regex_Pattern(env) != -1 &&
     85             register_java_util_zip_Adler32(env) != -1 &&
     86             register_java_util_zip_CRC32(env) != -1 &&
     87             register_java_util_zip_Deflater(env) != -1 &&
     88             register_java_util_zip_Inflater(env) != -1 &&
     89             register_libcore_icu_ICU(env) != -1 &&
     90             register_libcore_icu_NativeBreakIterator(env) != -1 &&
     91             register_libcore_icu_NativeCollation(env) != -1 &&
     92             register_libcore_icu_NativeConverter(env) != -1 &&
     93             register_libcore_icu_NativeDecimalFormat(env) != -1 &&
     94             register_libcore_icu_NativeIDN(env) != -1 &&
     95             register_libcore_icu_NativeNormalizer(env) != -1 &&
     96             register_libcore_icu_NativePluralRules(env) != -1 &&
     97             register_libcore_icu_TimeZones(env) != -1 &&
     98             register_libcore_io_AsynchronousCloseMonitor(env) != -1 &&
     99             register_libcore_io_Memory(env) != -1 &&
    100             register_libcore_io_OsConstants(env) != -1 &&
    101             register_libcore_io_Posix(env) != -1 &&
    102             register_libcore_net_RawSocket(env) != -1 &&
    103             register_org_apache_harmony_dalvik_NativeTestTarget(env) != -1 &&
    104             register_org_apache_harmony_xml_ExpatParser(env) != -1 &&
    105             register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(env) != -1 &&
    106             true;
    107 
    108     if (!result) {
    109         LOGE("Failed to initialize the core libraries; aborting...");
    110         abort();
    111     }
    112     return 0;
    113 }
    114