• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "cutils/log.h"
20 #include "JniConstants.h"
21 #include "ScopedLocalFrame.h"
22 
23 #include <stdlib.h>
24 
25 // DalvikVM calls this on startup, so we can statically register all our native methods.
JNI_OnLoad(JavaVM * vm,void *)26 jint JNI_OnLoad(JavaVM* vm, void*) {
27     JNIEnv* env;
28     if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
29         ALOGE("JavaVM::GetEnv() failed");
30         abort();
31     }
32 
33     ScopedLocalFrame localFrame(env);
34 
35 #define REGISTER(FN) extern void FN(JNIEnv*); FN(env)
36     REGISTER(register_android_system_OsConstants);
37     //    REGISTER(register_java_lang_StringToReal);
38     REGISTER(register_java_math_NativeBN);
39     REGISTER(register_java_util_regex_Matcher);
40     REGISTER(register_java_util_regex_Pattern);
41     REGISTER(register_libcore_icu_ICU);
42     REGISTER(register_libcore_icu_NativeConverter);
43     REGISTER(register_libcore_icu_TimeZoneNames);
44     REGISTER(register_libcore_io_AsynchronousCloseMonitor);
45     REGISTER(register_libcore_io_Memory);
46     REGISTER(register_libcore_io_Posix);
47     REGISTER(register_libcore_util_NativeAllocationRegistry);
48     REGISTER(register_org_apache_harmony_dalvik_NativeTestTarget);
49     REGISTER(register_org_apache_harmony_xml_ExpatParser);
50     REGISTER(register_sun_misc_Unsafe);
51 #undef REGISTER
52 
53     return JNI_VERSION_1_6;
54 }
55