Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_WELL_KNOWN_CLASSES_H_ |
| 18 | #define ART_RUNTIME_WELL_KNOWN_CLASSES_H_ |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 19 | |
Elliott Hughes | 76b6167 | 2012-12-12 17:47:30 -0800 | [diff] [blame] | 20 | #include "base/mutex.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 21 | #include "jni.h" |
| 22 | |
| 23 | namespace art { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 24 | namespace mirror { |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 25 | class Class; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 26 | } // namespace mirror |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 27 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 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 | |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 32 | jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, const char* name, const char* signature); |
| 33 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 34 | struct WellKnownClasses { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 35 | public: |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 36 | static void Init(JNIEnv* env); // Run before native methods are registered. |
| 37 | static void LateInit(JNIEnv* env); // Run after native methods are registered. |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 38 | static jmethodID StringInitToStringFactoryMethodID(jmethodID string_init); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 39 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 40 | static mirror::Class* ToClass(jclass global_jclass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 41 | SHARED_REQUIRES(Locks::mutator_lock_); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 42 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 43 | static jclass com_android_dex_Dex; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 44 | static jclass dalvik_system_DexFile; |
| 45 | static jclass dalvik_system_DexPathList; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 46 | static jclass dalvik_system_DexPathList__Element; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 47 | static jclass dalvik_system_PathClassLoader; |
Mathieu Chartier | b5de3bb | 2015-06-05 13:21:05 -0700 | [diff] [blame] | 48 | static jclass dalvik_system_VMRuntime; |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 49 | static jclass java_lang_annotation_Annotation__array; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 50 | static jclass java_lang_BootClassLoader; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 51 | static jclass java_lang_ClassLoader; |
| 52 | static jclass java_lang_ClassNotFoundException; |
| 53 | static jclass java_lang_Daemons; |
| 54 | static jclass java_lang_Error; |
Ian Rogers | af6e67a | 2013-01-16 08:38:37 -0800 | [diff] [blame] | 55 | static jclass java_lang_Object; |
Mathieu Chartier | a61894d | 2015-04-23 16:32:54 -0700 | [diff] [blame] | 56 | static jclass java_lang_OutOfMemoryError; |
Mathieu Chartier | 66f1925 | 2012-09-18 08:57:04 -0700 | [diff] [blame] | 57 | static jclass java_lang_reflect_AbstractMethod; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 58 | static jclass java_lang_reflect_Constructor; |
| 59 | static jclass java_lang_reflect_Field; |
| 60 | static jclass java_lang_reflect_Method; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 61 | static jclass java_lang_reflect_Proxy; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 62 | static jclass java_lang_RuntimeException; |
Ian Rogers | 120f1c7 | 2012-09-28 17:17:10 -0700 | [diff] [blame] | 63 | static jclass java_lang_StackOverflowError; |
Ian Rogers | dd157d7 | 2014-05-15 14:47:50 -0700 | [diff] [blame] | 64 | static jclass java_lang_String; |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 65 | static jclass java_lang_StringFactory; |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 66 | static jclass java_lang_System; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 67 | static jclass java_lang_Thread; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 68 | static jclass java_lang_ThreadGroup; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 69 | static jclass java_lang_Thread__UncaughtExceptionHandler; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 70 | static jclass java_lang_Throwable; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 71 | static jclass java_util_ArrayList; |
Andreas Gampe | 7ea6f79 | 2014-07-14 16:21:44 -0700 | [diff] [blame] | 72 | static jclass java_util_Collections; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 73 | static jclass java_nio_DirectByteBuffer; |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 74 | static jclass libcore_reflect_AnnotationFactory; |
| 75 | static jclass libcore_reflect_AnnotationMember; |
Andreas Gampe | 7ea6f79 | 2014-07-14 16:21:44 -0700 | [diff] [blame] | 76 | static jclass libcore_util_EmptyArray; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 77 | static jclass org_apache_harmony_dalvik_ddmc_Chunk; |
| 78 | static jclass org_apache_harmony_dalvik_ddmc_DdmServer; |
| 79 | |
| 80 | static jmethodID com_android_dex_Dex_create; |
Mathieu Chartier | b5de3bb | 2015-06-05 13:21:05 -0700 | [diff] [blame] | 81 | static jmethodID dalvik_system_VMRuntime_runFinalization; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 82 | static jmethodID java_lang_Boolean_valueOf; |
| 83 | static jmethodID java_lang_Byte_valueOf; |
| 84 | static jmethodID java_lang_Character_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 85 | static jmethodID java_lang_ClassLoader_loadClass; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 86 | static jmethodID java_lang_ClassNotFoundException_init; |
| 87 | static jmethodID java_lang_Daemons_requestHeapTrim; |
| 88 | static jmethodID java_lang_Daemons_start; |
Mathieu Chartier | cef50f0 | 2014-12-09 17:38:52 -0800 | [diff] [blame] | 89 | static jmethodID java_lang_Daemons_stop; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 90 | static jmethodID java_lang_Double_valueOf; |
| 91 | static jmethodID java_lang_Float_valueOf; |
| 92 | static jmethodID java_lang_Integer_valueOf; |
| 93 | static jmethodID java_lang_Long_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 94 | static jmethodID java_lang_ref_FinalizerReference_add; |
| 95 | static jmethodID java_lang_ref_ReferenceQueue_add; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 96 | static jmethodID java_lang_reflect_Proxy_invoke; |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 97 | static jmethodID java_lang_Runtime_nativeLoad; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 98 | static jmethodID java_lang_Short_valueOf; |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 99 | static jmethodID java_lang_String_init; |
| 100 | static jmethodID java_lang_String_init_B; |
| 101 | static jmethodID java_lang_String_init_BI; |
| 102 | static jmethodID java_lang_String_init_BII; |
| 103 | static jmethodID java_lang_String_init_BIII; |
| 104 | static jmethodID java_lang_String_init_BIIString; |
| 105 | static jmethodID java_lang_String_init_BString; |
| 106 | static jmethodID java_lang_String_init_BIICharset; |
| 107 | static jmethodID java_lang_String_init_BCharset; |
| 108 | static jmethodID java_lang_String_init_C; |
| 109 | static jmethodID java_lang_String_init_CII; |
| 110 | static jmethodID java_lang_String_init_IIC; |
| 111 | static jmethodID java_lang_String_init_String; |
| 112 | static jmethodID java_lang_String_init_StringBuffer; |
| 113 | static jmethodID java_lang_String_init_III; |
| 114 | static jmethodID java_lang_String_init_StringBuilder; |
| 115 | static jmethodID java_lang_StringFactory_newEmptyString; |
| 116 | static jmethodID java_lang_StringFactory_newStringFromBytes_B; |
| 117 | static jmethodID java_lang_StringFactory_newStringFromBytes_BI; |
| 118 | static jmethodID java_lang_StringFactory_newStringFromBytes_BII; |
| 119 | static jmethodID java_lang_StringFactory_newStringFromBytes_BIII; |
| 120 | static jmethodID java_lang_StringFactory_newStringFromBytes_BIIString; |
| 121 | static jmethodID java_lang_StringFactory_newStringFromBytes_BString; |
| 122 | static jmethodID java_lang_StringFactory_newStringFromBytes_BIICharset; |
| 123 | static jmethodID java_lang_StringFactory_newStringFromBytes_BCharset; |
| 124 | static jmethodID java_lang_StringFactory_newStringFromChars_C; |
| 125 | static jmethodID java_lang_StringFactory_newStringFromChars_CII; |
| 126 | static jmethodID java_lang_StringFactory_newStringFromChars_IIC; |
| 127 | static jmethodID java_lang_StringFactory_newStringFromString; |
| 128 | static jmethodID java_lang_StringFactory_newStringFromStringBuffer; |
| 129 | static jmethodID java_lang_StringFactory_newStringFromCodePoints; |
| 130 | static jmethodID java_lang_StringFactory_newStringFromStringBuilder; |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 131 | static jmethodID java_lang_System_runFinalization; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 132 | static jmethodID java_lang_Thread_init; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 133 | static jmethodID java_lang_Thread_run; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 134 | static jmethodID java_lang_Thread__UncaughtExceptionHandler_uncaughtException; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 135 | static jmethodID java_lang_ThreadGroup_removeThread; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 136 | static jmethodID java_nio_DirectByteBuffer_init; |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 137 | static jmethodID libcore_reflect_AnnotationFactory_createAnnotation; |
| 138 | static jmethodID libcore_reflect_AnnotationMember_init; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 139 | static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; |
| 140 | static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; |
| 141 | |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 142 | static jfieldID dalvik_system_DexFile_cookie; |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 143 | static jfieldID dalvik_system_DexFile_fileName; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 144 | static jfieldID dalvik_system_DexPathList_dexElements; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 145 | static jfieldID dalvik_system_DexPathList__Element_dexFile; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 146 | static jfieldID dalvik_system_PathClassLoader_pathList; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 147 | static jfieldID java_lang_reflect_AbstractMethod_artMethod; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 148 | static jfieldID java_lang_reflect_Proxy_h; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 149 | static jfieldID java_lang_Thread_daemon; |
| 150 | static jfieldID java_lang_Thread_group; |
| 151 | static jfieldID java_lang_Thread_lock; |
| 152 | static jfieldID java_lang_Thread_name; |
| 153 | static jfieldID java_lang_Thread_priority; |
| 154 | static jfieldID java_lang_Thread_uncaughtHandler; |
Anwar Ghuloum | 3c50a4b | 2013-06-21 13:05:23 -0700 | [diff] [blame] | 155 | static jfieldID java_lang_Thread_nativePeer; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 156 | static jfieldID java_lang_ThreadGroup_groups; |
Przemyslaw Szczepaniak | 464595f | 2015-11-24 11:59:59 +0000 | [diff] [blame] | 157 | static jfieldID java_lang_ThreadGroup_ngroups; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 158 | static jfieldID java_lang_ThreadGroup_mainThreadGroup; |
| 159 | static jfieldID java_lang_ThreadGroup_name; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 160 | static jfieldID java_lang_ThreadGroup_parent; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 161 | static jfieldID java_lang_ThreadGroup_systemThreadGroup; |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 162 | static jfieldID java_lang_Throwable_cause; |
| 163 | static jfieldID java_lang_Throwable_detailMessage; |
| 164 | static jfieldID java_lang_Throwable_stackTrace; |
| 165 | static jfieldID java_lang_Throwable_stackState; |
| 166 | static jfieldID java_lang_Throwable_suppressedExceptions; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 167 | static jfieldID java_nio_DirectByteBuffer_capacity; |
| 168 | static jfieldID java_nio_DirectByteBuffer_effectiveDirectAddress; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 169 | static jfieldID java_util_ArrayList_array; |
| 170 | static jfieldID java_util_ArrayList_size; |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 171 | static jfieldID java_util_Collections_EMPTY_LIST; |
| 172 | static jfieldID libcore_util_EmptyArray_STACK_TRACE_ELEMENT; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 173 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_data; |
| 174 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_length; |
| 175 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_offset; |
| 176 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_type; |
| 177 | }; |
| 178 | |
| 179 | } // namespace art |
| 180 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 181 | #endif // ART_RUNTIME_WELL_KNOWN_CLASSES_H_ |