1 /* 2 * Copyright (C) 2012 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 #ifndef ART_RUNTIME_WELL_KNOWN_CLASSES_H_ 18 #define ART_RUNTIME_WELL_KNOWN_CLASSES_H_ 19 20 #include "base/mutex.h" 21 #include "jni.h" 22 23 namespace art { 24 namespace mirror { 25 class Class; 26 } // namespace mirror 27 28 // Various classes used in JNI. We cache them so we don't have to keep looking 29 // them up. Similar to libcore's JniConstants (except there's no overlap, so 30 // we keep them separate). 31 32 jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, const char* name, const char* signature); 33 34 struct WellKnownClasses { 35 public: 36 static void Init(JNIEnv* env); // Run before native methods are registered. 37 static void LateInit(JNIEnv* env); // Run after native methods are registered. 38 static jmethodID StringInitToStringFactoryMethodID(jmethodID string_init); 39 40 static mirror::Class* ToClass(jclass global_jclass) 41 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 42 43 static jclass com_android_dex_Dex; 44 static jclass dalvik_system_DexFile; 45 static jclass dalvik_system_DexPathList; 46 static jclass dalvik_system_DexPathList__Element; 47 static jclass dalvik_system_PathClassLoader; 48 static jclass dalvik_system_VMRuntime; 49 static jclass java_lang_BootClassLoader; 50 static jclass java_lang_ClassLoader; 51 static jclass java_lang_ClassNotFoundException; 52 static jclass java_lang_Daemons; 53 static jclass java_lang_Error; 54 static jclass java_lang_Object; 55 static jclass java_lang_OutOfMemoryError; 56 static jclass java_lang_reflect_AbstractMethod; 57 static jclass java_lang_reflect_Constructor; 58 static jclass java_lang_reflect_Field; 59 static jclass java_lang_reflect_Method; 60 static jclass java_lang_reflect_Proxy; 61 static jclass java_lang_RuntimeException; 62 static jclass java_lang_StackOverflowError; 63 static jclass java_lang_String; 64 static jclass java_lang_StringFactory; 65 static jclass java_lang_System; 66 static jclass java_lang_Thread; 67 static jclass java_lang_ThreadGroup; 68 static jclass java_lang_Thread__UncaughtExceptionHandler; 69 static jclass java_lang_Throwable; 70 static jclass java_util_ArrayList; 71 static jclass java_util_Collections; 72 static jclass java_nio_DirectByteBuffer; 73 static jclass libcore_util_EmptyArray; 74 static jclass org_apache_harmony_dalvik_ddmc_Chunk; 75 static jclass org_apache_harmony_dalvik_ddmc_DdmServer; 76 77 static jmethodID com_android_dex_Dex_create; 78 static jmethodID dalvik_system_VMRuntime_runFinalization; 79 static jmethodID java_lang_Boolean_valueOf; 80 static jmethodID java_lang_Byte_valueOf; 81 static jmethodID java_lang_Character_valueOf; 82 static jmethodID java_lang_ClassLoader_loadClass; 83 static jmethodID java_lang_ClassNotFoundException_init; 84 static jmethodID java_lang_Daemons_requestHeapTrim; 85 static jmethodID java_lang_Daemons_start; 86 static jmethodID java_lang_Daemons_stop; 87 static jmethodID java_lang_Double_valueOf; 88 static jmethodID java_lang_Float_valueOf; 89 static jmethodID java_lang_Integer_valueOf; 90 static jmethodID java_lang_Long_valueOf; 91 static jmethodID java_lang_ref_FinalizerReference_add; 92 static jmethodID java_lang_ref_ReferenceQueue_add; 93 static jmethodID java_lang_reflect_Proxy_invoke; 94 static jmethodID java_lang_Runtime_nativeLoad; 95 static jmethodID java_lang_Short_valueOf; 96 static jmethodID java_lang_String_init; 97 static jmethodID java_lang_String_init_B; 98 static jmethodID java_lang_String_init_BI; 99 static jmethodID java_lang_String_init_BII; 100 static jmethodID java_lang_String_init_BIII; 101 static jmethodID java_lang_String_init_BIIString; 102 static jmethodID java_lang_String_init_BString; 103 static jmethodID java_lang_String_init_BIICharset; 104 static jmethodID java_lang_String_init_BCharset; 105 static jmethodID java_lang_String_init_C; 106 static jmethodID java_lang_String_init_CII; 107 static jmethodID java_lang_String_init_IIC; 108 static jmethodID java_lang_String_init_String; 109 static jmethodID java_lang_String_init_StringBuffer; 110 static jmethodID java_lang_String_init_III; 111 static jmethodID java_lang_String_init_StringBuilder; 112 static jmethodID java_lang_StringFactory_newEmptyString; 113 static jmethodID java_lang_StringFactory_newStringFromBytes_B; 114 static jmethodID java_lang_StringFactory_newStringFromBytes_BI; 115 static jmethodID java_lang_StringFactory_newStringFromBytes_BII; 116 static jmethodID java_lang_StringFactory_newStringFromBytes_BIII; 117 static jmethodID java_lang_StringFactory_newStringFromBytes_BIIString; 118 static jmethodID java_lang_StringFactory_newStringFromBytes_BString; 119 static jmethodID java_lang_StringFactory_newStringFromBytes_BIICharset; 120 static jmethodID java_lang_StringFactory_newStringFromBytes_BCharset; 121 static jmethodID java_lang_StringFactory_newStringFromChars_C; 122 static jmethodID java_lang_StringFactory_newStringFromChars_CII; 123 static jmethodID java_lang_StringFactory_newStringFromChars_IIC; 124 static jmethodID java_lang_StringFactory_newStringFromString; 125 static jmethodID java_lang_StringFactory_newStringFromStringBuffer; 126 static jmethodID java_lang_StringFactory_newStringFromCodePoints; 127 static jmethodID java_lang_StringFactory_newStringFromStringBuilder; 128 static jmethodID java_lang_System_runFinalization; 129 static jmethodID java_lang_Thread_init; 130 static jmethodID java_lang_Thread_run; 131 static jmethodID java_lang_Thread__UncaughtExceptionHandler_uncaughtException; 132 static jmethodID java_lang_ThreadGroup_removeThread; 133 static jmethodID java_nio_DirectByteBuffer_init; 134 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; 135 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; 136 137 static jfieldID dalvik_system_DexFile_cookie; 138 static jfieldID dalvik_system_DexPathList_dexElements; 139 static jfieldID dalvik_system_DexPathList__Element_dexFile; 140 static jfieldID dalvik_system_PathClassLoader_pathList; 141 static jfieldID java_lang_reflect_AbstractMethod_artMethod; 142 static jfieldID java_lang_reflect_Proxy_h; 143 static jfieldID java_lang_Thread_daemon; 144 static jfieldID java_lang_Thread_group; 145 static jfieldID java_lang_Thread_lock; 146 static jfieldID java_lang_Thread_name; 147 static jfieldID java_lang_Thread_priority; 148 static jfieldID java_lang_Thread_uncaughtHandler; 149 static jfieldID java_lang_Thread_nativePeer; 150 static jfieldID java_lang_ThreadGroup_groups; 151 static jfieldID java_lang_ThreadGroup_mainThreadGroup; 152 static jfieldID java_lang_ThreadGroup_name; 153 static jfieldID java_lang_ThreadGroup_parent; 154 static jfieldID java_lang_ThreadGroup_systemThreadGroup; 155 static jfieldID java_lang_Throwable_cause; 156 static jfieldID java_lang_Throwable_detailMessage; 157 static jfieldID java_lang_Throwable_stackTrace; 158 static jfieldID java_lang_Throwable_stackState; 159 static jfieldID java_lang_Throwable_suppressedExceptions; 160 static jfieldID java_nio_DirectByteBuffer_capacity; 161 static jfieldID java_nio_DirectByteBuffer_effectiveDirectAddress; 162 static jfieldID java_util_ArrayList_array; 163 static jfieldID java_util_ArrayList_size; 164 static jfieldID java_util_Collections_EMPTY_LIST; 165 static jfieldID libcore_util_EmptyArray_STACK_TRACE_ELEMENT; 166 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_data; 167 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_length; 168 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_offset; 169 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_type; 170 }; 171 172 } // namespace art 173 174 #endif // ART_RUNTIME_WELL_KNOWN_CLASSES_H_ 175