well_known_classes.h revision 0f45f22eb3c52f0ece4c56989180e79c6680d825
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 23namespace art { 24namespace mirror { 25class 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 32jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, const char* name, const char* signature); 33 34struct 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_String; 58 static jclass java_lang_System; 59 static jclass java_lang_Thread; 60 static jclass java_lang_ThreadGroup; 61 static jclass java_lang_Thread$UncaughtExceptionHandler; 62 static jclass java_lang_Throwable; 63 static jclass java_util_Collections; 64 static jclass java_nio_DirectByteBuffer; 65 static jclass libcore_util_EmptyArray; 66 static jclass org_apache_harmony_dalvik_ddmc_Chunk; 67 static jclass org_apache_harmony_dalvik_ddmc_DdmServer; 68 69 static jmethodID com_android_dex_Dex_create; 70 static jmethodID java_lang_Boolean_valueOf; 71 static jmethodID java_lang_Byte_valueOf; 72 static jmethodID java_lang_Character_valueOf; 73 static jmethodID java_lang_ClassLoader_loadClass; 74 static jmethodID java_lang_ClassNotFoundException_init; 75 static jmethodID java_lang_Daemons_requestGC; 76 static jmethodID java_lang_Daemons_requestHeapTrim; 77 static jmethodID java_lang_Daemons_start; 78 static jmethodID java_lang_Double_valueOf; 79 static jmethodID java_lang_Float_valueOf; 80 static jmethodID java_lang_Integer_valueOf; 81 static jmethodID java_lang_Long_valueOf; 82 static jmethodID java_lang_ref_FinalizerReference_add; 83 static jmethodID java_lang_ref_ReferenceQueue_add; 84 static jmethodID java_lang_reflect_Proxy_invoke; 85 static jmethodID java_lang_Runtime_nativeLoad; 86 static jmethodID java_lang_Short_valueOf; 87 static jmethodID java_lang_System_runFinalization; 88 static jmethodID java_lang_Thread_init; 89 static jmethodID java_lang_Thread_run; 90 static jmethodID java_lang_Thread$UncaughtExceptionHandler_uncaughtException; 91 static jmethodID java_lang_ThreadGroup_removeThread; 92 static jmethodID java_nio_DirectByteBuffer_init; 93 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; 94 static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; 95 96 static jfieldID java_lang_reflect_AbstractMethod_artMethod; 97 static jfieldID java_lang_reflect_Field_artField; 98 static jfieldID java_lang_reflect_Proxy_h; 99 static jfieldID java_lang_Thread_daemon; 100 static jfieldID java_lang_Thread_group; 101 static jfieldID java_lang_Thread_lock; 102 static jfieldID java_lang_Thread_name; 103 static jfieldID java_lang_Thread_priority; 104 static jfieldID java_lang_Thread_uncaughtHandler; 105 static jfieldID java_lang_Thread_nativePeer; 106 static jfieldID java_lang_ThreadGroup_mainThreadGroup; 107 static jfieldID java_lang_ThreadGroup_name; 108 static jfieldID java_lang_ThreadGroup_systemThreadGroup; 109 static jfieldID java_nio_DirectByteBuffer_capacity; 110 static jfieldID java_nio_DirectByteBuffer_effectiveDirectAddress; 111 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_data; 112 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_length; 113 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_offset; 114 static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_type; 115}; 116 117} // namespace art 118 119#endif // ART_RUNTIME_WELL_KNOWN_CLASSES_H_ 120