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 39 static mirror::Class* ToClass(jclass global_jclass) 40 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 41 42 static jclass com_android_dex_Dex; 43 static jclass dalvik_system_PathClassLoader; 44 static jclass java_lang_ClassLoader; 45 static jclass java_lang_ClassNotFoundException; 46 static jclass java_lang_Daemons; 47 static jclass java_lang_Error; 48 static jclass java_lang_Object; 49 static jclass java_lang_reflect_AbstractMethod; 50 static jclass java_lang_reflect_ArtMethod; 51 static jclass java_lang_reflect_Constructor; 52 static jclass java_lang_reflect_Field; 53 static jclass java_lang_reflect_Method; 54 static jclass java_lang_reflect_Proxy; 55 static jclass java_lang_RuntimeException; 56 static jclass java_lang_StackOverflowError; 57 static jclass java_lang_System; 58 static jclass java_lang_Thread; 59 static jclass java_lang_ThreadGroup; 60 static jclass java_lang_Thread$UncaughtExceptionHandler; 61 static jclass java_lang_Throwable; 62 static jclass java_nio_DirectByteBuffer; 63 static jclass org_apache_harmony_dalvik_ddmc_Chunk; 64 static jclass org_apache_harmony_dalvik_ddmc_DdmServer; 65 66 static jmethodID com_android_dex_Dex_create; 67 static jmethodID java_lang_Boolean_valueOf; 68 static jmethodID java_lang_Byte_valueOf; 69 static jmethodID java_lang_Character_valueOf; 70 static jmethodID java_lang_ClassLoader_loadClass; 71 static jmethodID java_lang_ClassNotFoundException_init; 72 static jmethodID java_lang_Daemons_requestGC; 73 static jmethodID java_lang_Daemons_requestHeapTrim; 74 static jmethodID java_lang_Daemons_start; 75 static jmethodID java_lang_Double_valueOf; 76 static jmethodID java_lang_Float_valueOf; 77 static jmethodID java_lang_Integer_valueOf; 78 static jmethodID java_lang_Long_valueOf; 79 static jmethodID java_lang_ref_FinalizerReference_add; 80 static jmethodID java_lang_ref_ReferenceQueue_add; 81 static jmethodID java_lang_reflect_Proxy_invoke; 82 static jmethodID java_lang_Runtime_nativeLoad; 83 static jmethodID java_lang_Short_valueOf; 84 static jmethodID java_lang_System_runFinalization; 85 static jmethodID java_lang_Thread_init; 86 static jmethodID java_lang_Thread_run; 87 static jmethodID java_lang_Thread$UncaughtExceptionHandler_uncaughtException; 88 static jmethodID java_lang_ThreadGroup_removeThread; 89 static jmethodID java_nio_DirectByteBuffer_init; 90 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; 91 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; 92 93 static jfieldID java_lang_reflect_AbstractMethod_artMethod; 94 static jfieldID java_lang_reflect_Field_artField; 95 static jfieldID java_lang_reflect_Proxy_h; 96 static jfieldID java_lang_Thread_daemon; 97 static jfieldID java_lang_Thread_group; 98 static jfieldID java_lang_Thread_lock; 99 static jfieldID java_lang_Thread_name; 100 static jfieldID java_lang_Thread_priority; 101 static jfieldID java_lang_Thread_uncaughtHandler; 102 static jfieldID java_lang_Thread_nativePeer; 103 static jfieldID java_lang_ThreadGroup_mainThreadGroup; 104 static jfieldID java_lang_ThreadGroup_name; 105 static jfieldID java_lang_ThreadGroup_systemThreadGroup; 106 static jfieldID java_nio_DirectByteBuffer_capacity; 107 static jfieldID java_nio_DirectByteBuffer_effectiveDirectAddress; 108 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_data; 109 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_length; 110 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_offset; 111 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_type; 112 }; 113 114 } // namespace art 115 116 #endif // ART_RUNTIME_WELL_KNOWN_CLASSES_H_ 117