Register.cpp revision bb1c04167bdff1939e9e71ed04c57337d4951008
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
24extern int register_java_io_Console(JNIEnv* env);
25extern int register_java_io_File(JNIEnv* env);
26extern int register_java_io_FileDescriptor(JNIEnv* env);
27extern int register_java_io_ObjectStreamClass(JNIEnv* env);
28extern int register_java_lang_Character(JNIEnv* env);
29extern int register_java_lang_Math(JNIEnv* env);
30extern int register_java_lang_ProcessManager(JNIEnv* env);
31extern int register_java_lang_RealToString(JNIEnv* env);
32extern int register_java_lang_StrictMath(JNIEnv* env);
33extern int register_java_lang_System(JNIEnv* env);
34extern int register_java_math_NativeBN(JNIEnv* env);
35extern int register_java_net_InetAddress(JNIEnv* env);
36extern int register_java_net_NetworkInterface(JNIEnv* env);
37extern int register_java_nio_ByteOrder(JNIEnv* env);
38extern int register_java_nio_charset_Charsets(JNIEnv* env);
39extern int register_java_text_Bidi(JNIEnv* env);
40extern int register_java_util_regex_Matcher(JNIEnv* env);
41extern int register_java_util_regex_Pattern(JNIEnv* env);
42extern int register_java_util_zip_Adler32(JNIEnv* env);
43extern int register_java_util_zip_CRC32(JNIEnv* env);
44extern int register_java_util_zip_Deflater(JNIEnv* env);
45extern int register_java_util_zip_Inflater(JNIEnv* env);
46extern int register_libcore_icu_ICU(JNIEnv* env);
47extern int register_libcore_icu_NativeBreakIterator(JNIEnv* env);
48extern int register_libcore_icu_NativeCollation(JNIEnv* env);
49extern int register_libcore_icu_NativeConverter(JNIEnv* env);
50extern int register_libcore_icu_NativeDecimalFormat(JNIEnv* env);
51extern int register_libcore_icu_NativeIDN(JNIEnv* env);
52extern int register_libcore_icu_NativeNormalizer(JNIEnv* env);
53extern int register_libcore_icu_NativePluralRules(JNIEnv* env);
54extern int register_libcore_icu_TimeZones(JNIEnv* env);
55extern int register_libcore_io_IoUtils(JNIEnv* env);
56extern int register_libcore_net_RawSocket(JNIEnv* env);
57extern int register_org_apache_harmony_dalvik_NativeTestTarget(JNIEnv* env);
58extern int register_org_apache_harmony_luni_platform_OSFileSystem(JNIEnv* env);
59extern int register_org_apache_harmony_luni_platform_OSMemory(JNIEnv* env);
60extern int register_org_apache_harmony_luni_platform_OSNetworkSystem(JNIEnv* env);
61extern int register_org_apache_harmony_luni_util_fltparse(JNIEnv* env);
62extern int register_org_apache_harmony_xml_ExpatParser(JNIEnv* env);
63extern int register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(JNIEnv* env);
64
65// DalvikVM calls this on startup, so we can statically register all our native methods.
66extern "C" int registerCoreLibrariesJni(JNIEnv* env) {
67    ScopedLocalFrame localFrame(env);
68
69    JniConstants::init(env);
70
71    bool result =
72            register_java_io_Console(env) != -1 &&
73            register_java_io_File(env) != -1 &&
74            register_java_io_FileDescriptor(env) != -1 &&
75            register_java_io_ObjectStreamClass(env) != -1 &&
76            register_java_lang_Character(env) != -1 &&
77            register_java_lang_Math(env) != -1 &&
78            register_java_lang_ProcessManager(env) != -1 &&
79            register_java_lang_RealToString(env) != -1 &&
80            register_java_lang_StrictMath(env) != -1 &&
81            register_java_lang_System(env) != -1 &&
82            register_java_math_NativeBN(env) != -1 &&
83            register_java_net_InetAddress(env) != -1 &&
84            register_java_net_NetworkInterface(env) != -1 &&
85            register_java_nio_ByteOrder(env) != -1 &&
86            register_java_nio_charset_Charsets(env) != -1 &&
87            register_java_text_Bidi(env) != -1 &&
88            register_java_util_regex_Matcher(env) != -1 &&
89            register_java_util_regex_Pattern(env) != -1 &&
90            register_java_util_zip_Adler32(env) != -1 &&
91            register_java_util_zip_CRC32(env) != -1 &&
92            register_java_util_zip_Deflater(env) != -1 &&
93            register_java_util_zip_Inflater(env) != -1 &&
94            register_libcore_icu_ICU(env) != -1 &&
95            register_libcore_icu_NativeBreakIterator(env) != -1 &&
96            register_libcore_icu_NativeCollation(env) != -1 &&
97            register_libcore_icu_NativeConverter(env) != -1 &&
98            register_libcore_icu_NativeDecimalFormat(env) != -1 &&
99            register_libcore_icu_NativeIDN(env) != -1 &&
100            register_libcore_icu_NativeNormalizer(env) != -1 &&
101            register_libcore_icu_NativePluralRules(env) != -1 &&
102            register_libcore_icu_TimeZones(env) != -1 &&
103            register_libcore_io_IoUtils(env) != -1 &&
104            register_libcore_net_RawSocket(env) != -1 &&
105            register_org_apache_harmony_dalvik_NativeTestTarget(env) != -1 &&
106            register_org_apache_harmony_luni_platform_OSFileSystem(env) != -1 &&
107            register_org_apache_harmony_luni_platform_OSMemory(env) != -1 &&
108            register_org_apache_harmony_luni_platform_OSNetworkSystem(env) != -1 &&
109            register_org_apache_harmony_luni_util_fltparse(env) != -1 &&
110            register_org_apache_harmony_xml_ExpatParser(env) != -1 &&
111            register_org_apache_harmony_xnet_provider_jsse_NativeCrypto(env) != -1 &&
112            true;
113
114    if (!result) {
115        LOGE("Failed to initialize the core libraries; aborting...");
116        abort();
117    }
118    return 0;
119}
120