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" |
Mathieu Chartier | c4f3925 | 2016-10-05 18:32:08 -0700 | [diff] [blame] | 22 | #include "obj_ptr.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 23 | |
| 24 | namespace art { |
Nicolas Geoffray | da079bb | 2016-09-26 17:56:07 +0100 | [diff] [blame] | 25 | |
| 26 | class ArtMethod; |
| 27 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 28 | namespace mirror { |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 29 | class Class; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 30 | } // namespace mirror |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 31 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 32 | // Various classes used in JNI. We cache them so we don't have to keep looking |
| 33 | // them up. Similar to libcore's JniConstants (except there's no overlap, so |
| 34 | // we keep them separate). |
| 35 | |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 36 | jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, const char* name, const char* signature); |
| 37 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 38 | struct WellKnownClasses { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 39 | public: |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 40 | static void Init(JNIEnv* env); // Run before native methods are registered. |
| 41 | static void LateInit(JNIEnv* env); // Run after native methods are registered. |
Nicolas Geoffray | da079bb | 2016-09-26 17:56:07 +0100 | [diff] [blame] | 42 | static ArtMethod* StringInitToStringFactory(ArtMethod* method); |
| 43 | static uint32_t StringInitToEntryPoint(ArtMethod* method); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 44 | |
Mathieu Chartier | c4f3925 | 2016-10-05 18:32:08 -0700 | [diff] [blame] | 45 | static ObjPtr<mirror::Class> ToClass(jclass global_jclass) REQUIRES_SHARED(Locks::mutator_lock_); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 46 | |
Igor Murashkin | 367f3dd | 2016-09-01 17:00:24 -0700 | [diff] [blame] | 47 | static jclass dalvik_annotation_optimization_CriticalNative; |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame] | 48 | static jclass dalvik_annotation_optimization_FastNative; |
Andreas Gampe | 46aba36 | 2016-10-28 14:33:28 -0700 | [diff] [blame] | 49 | static jclass dalvik_system_BaseDexClassLoader; |
Nicolas Geoffray | 7d8d8ff | 2016-11-02 12:38:05 +0000 | [diff] [blame] | 50 | static jclass dalvik_system_DexClassLoader; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 51 | static jclass dalvik_system_DexFile; |
| 52 | static jclass dalvik_system_DexPathList; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 53 | static jclass dalvik_system_DexPathList__Element; |
Narayan Kamath | c3b7f1a | 2016-10-19 11:05:04 +0100 | [diff] [blame] | 54 | static jclass dalvik_system_EmulatedStackFrame; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 55 | static jclass dalvik_system_PathClassLoader; |
Mathieu Chartier | b5de3bb | 2015-06-05 13:21:05 -0700 | [diff] [blame] | 56 | static jclass dalvik_system_VMRuntime; |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 57 | static jclass java_lang_annotation_Annotation__array; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 58 | static jclass java_lang_BootClassLoader; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 59 | static jclass java_lang_ClassLoader; |
| 60 | static jclass java_lang_ClassNotFoundException; |
| 61 | static jclass java_lang_Daemons; |
| 62 | static jclass java_lang_Error; |
Jeff Hao | c92a7a1 | 2016-06-06 11:09:20 -0700 | [diff] [blame] | 63 | static jclass java_lang_IllegalAccessError; |
Orion Hodson | 811bd5f | 2016-12-07 11:35:37 +0000 | [diff] [blame] | 64 | static jclass java_lang_invoke_MethodHandle; |
Jeff Hao | c92a7a1 | 2016-06-06 11:09:20 -0700 | [diff] [blame] | 65 | static jclass java_lang_NoClassDefFoundError; |
Ian Rogers | af6e67a | 2013-01-16 08:38:37 -0800 | [diff] [blame] | 66 | static jclass java_lang_Object; |
Mathieu Chartier | a61894d | 2015-04-23 16:32:54 -0700 | [diff] [blame] | 67 | static jclass java_lang_OutOfMemoryError; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 68 | static jclass java_lang_reflect_Constructor; |
Neil Fuller | 0e84439 | 2016-09-08 13:43:31 +0100 | [diff] [blame] | 69 | static jclass java_lang_reflect_Executable; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 70 | static jclass java_lang_reflect_Field; |
| 71 | static jclass java_lang_reflect_Method; |
Neil Fuller | 79a21e7 | 2016-09-09 14:24:51 +0100 | [diff] [blame] | 72 | static jclass java_lang_reflect_Parameter; |
| 73 | static jclass java_lang_reflect_Parameter__array; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 74 | static jclass java_lang_reflect_Proxy; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 75 | static jclass java_lang_RuntimeException; |
Ian Rogers | 120f1c7 | 2012-09-28 17:17:10 -0700 | [diff] [blame] | 76 | static jclass java_lang_StackOverflowError; |
Ian Rogers | dd157d7 | 2014-05-15 14:47:50 -0700 | [diff] [blame] | 77 | static jclass java_lang_String; |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 78 | static jclass java_lang_StringFactory; |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 79 | static jclass java_lang_System; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 80 | static jclass java_lang_Thread; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 81 | static jclass java_lang_ThreadGroup; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 82 | static jclass java_lang_Throwable; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 83 | static jclass java_util_ArrayList; |
Andreas Gampe | 7ea6f79 | 2014-07-14 16:21:44 -0700 | [diff] [blame] | 84 | static jclass java_util_Collections; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 85 | static jclass java_nio_DirectByteBuffer; |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 86 | static jclass libcore_reflect_AnnotationFactory; |
| 87 | static jclass libcore_reflect_AnnotationMember; |
Andreas Gampe | 7ea6f79 | 2014-07-14 16:21:44 -0700 | [diff] [blame] | 88 | static jclass libcore_util_EmptyArray; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 89 | static jclass org_apache_harmony_dalvik_ddmc_Chunk; |
| 90 | static jclass org_apache_harmony_dalvik_ddmc_DdmServer; |
| 91 | |
Mathieu Chartier | b5de3bb | 2015-06-05 13:21:05 -0700 | [diff] [blame] | 92 | static jmethodID dalvik_system_VMRuntime_runFinalization; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 93 | static jmethodID java_lang_Boolean_valueOf; |
| 94 | static jmethodID java_lang_Byte_valueOf; |
| 95 | static jmethodID java_lang_Character_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 96 | static jmethodID java_lang_ClassLoader_loadClass; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 97 | static jmethodID java_lang_ClassNotFoundException_init; |
| 98 | static jmethodID java_lang_Daemons_requestHeapTrim; |
| 99 | static jmethodID java_lang_Daemons_start; |
Mathieu Chartier | cef50f0 | 2014-12-09 17:38:52 -0800 | [diff] [blame] | 100 | static jmethodID java_lang_Daemons_stop; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 101 | static jmethodID java_lang_Double_valueOf; |
| 102 | static jmethodID java_lang_Float_valueOf; |
| 103 | static jmethodID java_lang_Integer_valueOf; |
Orion Hodson | 811bd5f | 2016-12-07 11:35:37 +0000 | [diff] [blame] | 104 | static jmethodID java_lang_invoke_MethodHandle_invoke; |
| 105 | static jmethodID java_lang_invoke_MethodHandle_invokeExact; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 106 | static jmethodID java_lang_Long_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 107 | static jmethodID java_lang_ref_FinalizerReference_add; |
| 108 | static jmethodID java_lang_ref_ReferenceQueue_add; |
Neil Fuller | 79a21e7 | 2016-09-09 14:24:51 +0100 | [diff] [blame] | 109 | static jmethodID java_lang_reflect_Parameter_init; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 110 | static jmethodID java_lang_reflect_Proxy_invoke; |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 111 | static jmethodID java_lang_Runtime_nativeLoad; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 112 | static jmethodID java_lang_Short_valueOf; |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 113 | static jmethodID java_lang_String_charAt; |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 114 | static jmethodID java_lang_System_runFinalization; |
Tobias Thierer | 5cbe65d | 2016-07-22 18:37:59 +0100 | [diff] [blame] | 115 | static jmethodID java_lang_Thread_dispatchUncaughtException; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 116 | static jmethodID java_lang_Thread_init; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 117 | static jmethodID java_lang_Thread_run; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 118 | static jmethodID java_lang_ThreadGroup_removeThread; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 119 | static jmethodID java_nio_DirectByteBuffer_init; |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 120 | static jmethodID libcore_reflect_AnnotationFactory_createAnnotation; |
| 121 | static jmethodID libcore_reflect_AnnotationMember_init; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 122 | static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; |
| 123 | static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; |
| 124 | |
Andreas Gampe | 46aba36 | 2016-10-28 14:33:28 -0700 | [diff] [blame] | 125 | static jfieldID dalvik_system_BaseDexClassLoader_pathList; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 126 | static jfieldID dalvik_system_DexFile_cookie; |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 127 | static jfieldID dalvik_system_DexFile_fileName; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 128 | static jfieldID dalvik_system_DexPathList_dexElements; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 129 | static jfieldID dalvik_system_DexPathList__Element_dexFile; |
Neil Fuller | 0e84439 | 2016-09-08 13:43:31 +0100 | [diff] [blame] | 130 | static jfieldID java_lang_reflect_Executable_artMethod; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 131 | static jfieldID java_lang_reflect_Proxy_h; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 132 | static jfieldID java_lang_Thread_daemon; |
| 133 | static jfieldID java_lang_Thread_group; |
| 134 | static jfieldID java_lang_Thread_lock; |
| 135 | static jfieldID java_lang_Thread_name; |
| 136 | static jfieldID java_lang_Thread_priority; |
Anwar Ghuloum | 3c50a4b | 2013-06-21 13:05:23 -0700 | [diff] [blame] | 137 | static jfieldID java_lang_Thread_nativePeer; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 138 | static jfieldID java_lang_ThreadGroup_groups; |
Przemyslaw Szczepaniak | 464595f | 2015-11-24 11:59:59 +0000 | [diff] [blame] | 139 | static jfieldID java_lang_ThreadGroup_ngroups; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 140 | static jfieldID java_lang_ThreadGroup_mainThreadGroup; |
| 141 | static jfieldID java_lang_ThreadGroup_name; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 142 | static jfieldID java_lang_ThreadGroup_parent; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 143 | static jfieldID java_lang_ThreadGroup_systemThreadGroup; |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 144 | static jfieldID java_lang_Throwable_cause; |
| 145 | static jfieldID java_lang_Throwable_detailMessage; |
| 146 | static jfieldID java_lang_Throwable_stackTrace; |
| 147 | static jfieldID java_lang_Throwable_stackState; |
| 148 | static jfieldID java_lang_Throwable_suppressedExceptions; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 149 | static jfieldID java_nio_DirectByteBuffer_capacity; |
| 150 | static jfieldID java_nio_DirectByteBuffer_effectiveDirectAddress; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 151 | static jfieldID java_util_ArrayList_array; |
| 152 | static jfieldID java_util_ArrayList_size; |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 153 | static jfieldID java_util_Collections_EMPTY_LIST; |
| 154 | static jfieldID libcore_util_EmptyArray_STACK_TRACE_ELEMENT; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 155 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_data; |
| 156 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_length; |
| 157 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_offset; |
| 158 | static jfieldID org_apache_harmony_dalvik_ddmc_Chunk_type; |
Nicolas Geoffray | da079bb | 2016-09-26 17:56:07 +0100 | [diff] [blame] | 159 | |
| 160 | private: |
| 161 | static void InitStringInit(JNIEnv* env); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 162 | }; |
| 163 | |
| 164 | } // namespace art |
| 165 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 166 | #endif // ART_RUNTIME_WELL_KNOWN_CLASSES_H_ |