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 | |
| 17 | #include "well_known_classes.h" |
| 18 | |
| 19 | #include <stdlib.h> |
| 20 | |
Ian Rogers | c7dd295 | 2014-10-21 23:31:19 -0700 | [diff] [blame] | 21 | #include <sstream> |
| 22 | |
Elliott Hughes | 07ed66b | 2012-12-12 18:34:25 -0800 | [diff] [blame] | 23 | #include "base/logging.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 24 | #include "mirror/class.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 25 | #include "ScopedLocalRef.h" |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 26 | #include "scoped_thread_state_change.h" |
Brian Carlstrom | a3d2718 | 2013-11-05 23:22:27 -0800 | [diff] [blame] | 27 | #include "thread-inl.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 28 | |
| 29 | namespace art { |
| 30 | |
| 31 | jclass WellKnownClasses::com_android_dex_Dex; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 32 | jclass WellKnownClasses::dalvik_system_DexFile; |
| 33 | jclass WellKnownClasses::dalvik_system_DexPathList; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 34 | jclass WellKnownClasses::dalvik_system_DexPathList__Element; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 35 | jclass WellKnownClasses::dalvik_system_PathClassLoader; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 36 | jclass WellKnownClasses::java_lang_BootClassLoader; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 37 | jclass WellKnownClasses::java_lang_ClassLoader; |
| 38 | jclass WellKnownClasses::java_lang_ClassNotFoundException; |
| 39 | jclass WellKnownClasses::java_lang_Daemons; |
| 40 | jclass WellKnownClasses::java_lang_Error; |
Ian Rogers | af6e67a | 2013-01-16 08:38:37 -0800 | [diff] [blame] | 41 | jclass WellKnownClasses::java_lang_Object; |
Mathieu Chartier | 66f1925 | 2012-09-18 08:57:04 -0700 | [diff] [blame] | 42 | jclass WellKnownClasses::java_lang_reflect_AbstractMethod; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 43 | jclass WellKnownClasses::java_lang_reflect_ArtMethod; |
| 44 | jclass WellKnownClasses::java_lang_reflect_Constructor; |
| 45 | jclass WellKnownClasses::java_lang_reflect_Field; |
| 46 | jclass WellKnownClasses::java_lang_reflect_Method; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 47 | jclass WellKnownClasses::java_lang_reflect_Proxy; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 48 | jclass WellKnownClasses::java_lang_RuntimeException; |
Ian Rogers | 120f1c7 | 2012-09-28 17:17:10 -0700 | [diff] [blame] | 49 | jclass WellKnownClasses::java_lang_StackOverflowError; |
Ian Rogers | dd157d7 | 2014-05-15 14:47:50 -0700 | [diff] [blame] | 50 | jclass WellKnownClasses::java_lang_String; |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 51 | jclass WellKnownClasses::java_lang_System; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 52 | jclass WellKnownClasses::java_lang_Thread; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 53 | jclass WellKnownClasses::java_lang_Thread__UncaughtExceptionHandler; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 54 | jclass WellKnownClasses::java_lang_ThreadGroup; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 55 | jclass WellKnownClasses::java_lang_Throwable; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 56 | jclass WellKnownClasses::java_nio_DirectByteBuffer; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 57 | jclass WellKnownClasses::java_util_ArrayList; |
Andreas Gampe | 7ea6f79 | 2014-07-14 16:21:44 -0700 | [diff] [blame] | 58 | jclass WellKnownClasses::java_util_Collections; |
| 59 | jclass WellKnownClasses::libcore_util_EmptyArray; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 60 | jclass WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk; |
| 61 | jclass WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer; |
| 62 | |
| 63 | jmethodID WellKnownClasses::com_android_dex_Dex_create; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 64 | jmethodID WellKnownClasses::java_lang_Boolean_valueOf; |
| 65 | jmethodID WellKnownClasses::java_lang_Byte_valueOf; |
| 66 | jmethodID WellKnownClasses::java_lang_Character_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 67 | jmethodID WellKnownClasses::java_lang_ClassLoader_loadClass; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 68 | jmethodID WellKnownClasses::java_lang_ClassNotFoundException_init; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 69 | jmethodID WellKnownClasses::java_lang_Daemons_requestHeapTrim; |
| 70 | jmethodID WellKnownClasses::java_lang_Daemons_start; |
Mathieu Chartier | cef50f0 | 2014-12-09 17:38:52 -0800 | [diff] [blame] | 71 | jmethodID WellKnownClasses::java_lang_Daemons_stop; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 72 | jmethodID WellKnownClasses::java_lang_Double_valueOf; |
| 73 | jmethodID WellKnownClasses::java_lang_Float_valueOf; |
| 74 | jmethodID WellKnownClasses::java_lang_Integer_valueOf; |
| 75 | jmethodID WellKnownClasses::java_lang_Long_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 76 | jmethodID WellKnownClasses::java_lang_ref_FinalizerReference_add; |
| 77 | jmethodID WellKnownClasses::java_lang_ref_ReferenceQueue_add; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 78 | jmethodID WellKnownClasses::java_lang_reflect_Proxy_invoke; |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 79 | jmethodID WellKnownClasses::java_lang_Runtime_nativeLoad; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 80 | jmethodID WellKnownClasses::java_lang_Short_valueOf; |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 81 | jmethodID WellKnownClasses::java_lang_System_runFinalization = NULL; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 82 | jmethodID WellKnownClasses::java_lang_Thread_init; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 83 | jmethodID WellKnownClasses::java_lang_Thread_run; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 84 | jmethodID WellKnownClasses::java_lang_Thread__UncaughtExceptionHandler_uncaughtException; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 85 | jmethodID WellKnownClasses::java_lang_ThreadGroup_removeThread; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 86 | jmethodID WellKnownClasses::java_nio_DirectByteBuffer_init; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 87 | jmethodID WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; |
| 88 | jmethodID WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; |
| 89 | |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 90 | jfieldID WellKnownClasses::dalvik_system_DexFile_cookie; |
| 91 | jfieldID WellKnownClasses::dalvik_system_PathClassLoader_pathList; |
| 92 | jfieldID WellKnownClasses::dalvik_system_DexPathList_dexElements; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 93 | jfieldID WellKnownClasses::dalvik_system_DexPathList__Element_dexFile; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 94 | jfieldID WellKnownClasses::java_lang_Thread_daemon; |
| 95 | jfieldID WellKnownClasses::java_lang_Thread_group; |
| 96 | jfieldID WellKnownClasses::java_lang_Thread_lock; |
| 97 | jfieldID WellKnownClasses::java_lang_Thread_name; |
| 98 | jfieldID WellKnownClasses::java_lang_Thread_priority; |
| 99 | jfieldID WellKnownClasses::java_lang_Thread_uncaughtHandler; |
Anwar Ghuloum | 3c50a4b | 2013-06-21 13:05:23 -0700 | [diff] [blame] | 100 | jfieldID WellKnownClasses::java_lang_Thread_nativePeer; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 101 | jfieldID WellKnownClasses::java_lang_ThreadGroup_groups; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 102 | jfieldID WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup; |
| 103 | jfieldID WellKnownClasses::java_lang_ThreadGroup_name; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 104 | jfieldID WellKnownClasses::java_lang_ThreadGroup_parent; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 105 | jfieldID WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup; |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 106 | jfieldID WellKnownClasses::java_lang_Throwable_cause; |
| 107 | jfieldID WellKnownClasses::java_lang_Throwable_detailMessage; |
| 108 | jfieldID WellKnownClasses::java_lang_Throwable_stackTrace; |
| 109 | jfieldID WellKnownClasses::java_lang_Throwable_stackState; |
| 110 | jfieldID WellKnownClasses::java_lang_Throwable_suppressedExceptions; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 111 | jfieldID WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod; |
| 112 | jfieldID WellKnownClasses::java_lang_reflect_Field_artField; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 113 | jfieldID WellKnownClasses::java_lang_reflect_Proxy_h; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 114 | jfieldID WellKnownClasses::java_nio_DirectByteBuffer_capacity; |
| 115 | jfieldID WellKnownClasses::java_nio_DirectByteBuffer_effectiveDirectAddress; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 116 | jfieldID WellKnownClasses::java_util_ArrayList_array; |
| 117 | jfieldID WellKnownClasses::java_util_ArrayList_size; |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 118 | jfieldID WellKnownClasses::java_util_Collections_EMPTY_LIST; |
| 119 | jfieldID WellKnownClasses::libcore_util_EmptyArray_STACK_TRACE_ELEMENT; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 120 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_data; |
| 121 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_length; |
| 122 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_offset; |
| 123 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_type; |
| 124 | |
| 125 | static jclass CacheClass(JNIEnv* env, const char* jni_class_name) { |
| 126 | ScopedLocalRef<jclass> c(env, env->FindClass(jni_class_name)); |
| 127 | if (c.get() == NULL) { |
| 128 | LOG(FATAL) << "Couldn't find class: " << jni_class_name; |
| 129 | } |
| 130 | return reinterpret_cast<jclass>(env->NewGlobalRef(c.get())); |
| 131 | } |
| 132 | |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 133 | static jfieldID CacheField(JNIEnv* env, jclass c, bool is_static, |
| 134 | const char* name, const char* signature) { |
| 135 | jfieldID fid = (is_static ? |
| 136 | env->GetStaticFieldID(c, name, signature) : |
| 137 | env->GetFieldID(c, name, signature)); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 138 | if (fid == NULL) { |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 139 | ScopedObjectAccess soa(env); |
| 140 | std::ostringstream os; |
| 141 | WellKnownClasses::ToClass(c)->DumpClass(os, mirror::Class::kDumpClassFullDetail); |
| 142 | LOG(FATAL) << "Couldn't find field \"" << name << "\" with signature \"" << signature << "\": " |
| 143 | << os.str(); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 144 | } |
| 145 | return fid; |
| 146 | } |
| 147 | |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 148 | jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, |
| 149 | const char* name, const char* signature) { |
| 150 | jmethodID mid = (is_static ? |
| 151 | env->GetStaticMethodID(c, name, signature) : |
| 152 | env->GetMethodID(c, name, signature)); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 153 | if (mid == NULL) { |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 154 | ScopedObjectAccess soa(env); |
| 155 | std::ostringstream os; |
| 156 | WellKnownClasses::ToClass(c)->DumpClass(os, mirror::Class::kDumpClassFullDetail); |
| 157 | LOG(FATAL) << "Couldn't find method \"" << name << "\" with signature \"" << signature << "\": " |
| 158 | << os.str(); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 159 | } |
| 160 | return mid; |
| 161 | } |
| 162 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 163 | static jmethodID CachePrimitiveBoxingMethod(JNIEnv* env, char prim_name, const char* boxed_name) { |
| 164 | ScopedLocalRef<jclass> boxed_class(env, env->FindClass(boxed_name)); |
| 165 | return CacheMethod(env, boxed_class.get(), true, "valueOf", |
| 166 | StringPrintf("(%c)L%s;", prim_name, boxed_name).c_str()); |
| 167 | } |
| 168 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 169 | void WellKnownClasses::Init(JNIEnv* env) { |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 170 | com_android_dex_Dex = CacheClass(env, "com/android/dex/Dex"); |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 171 | dalvik_system_DexFile = CacheClass(env, "dalvik/system/DexFile"); |
| 172 | dalvik_system_DexPathList = CacheClass(env, "dalvik/system/DexPathList"); |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 173 | dalvik_system_DexPathList__Element = CacheClass(env, "dalvik/system/DexPathList$Element"); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 174 | dalvik_system_PathClassLoader = CacheClass(env, "dalvik/system/PathClassLoader"); |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 175 | java_lang_BootClassLoader = CacheClass(env, "java/lang/BootClassLoader"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 176 | java_lang_ClassLoader = CacheClass(env, "java/lang/ClassLoader"); |
| 177 | java_lang_ClassNotFoundException = CacheClass(env, "java/lang/ClassNotFoundException"); |
| 178 | java_lang_Daemons = CacheClass(env, "java/lang/Daemons"); |
Ian Rogers | af6e67a | 2013-01-16 08:38:37 -0800 | [diff] [blame] | 179 | java_lang_Object = CacheClass(env, "java/lang/Object"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 180 | java_lang_Error = CacheClass(env, "java/lang/Error"); |
Mathieu Chartier | 66f1925 | 2012-09-18 08:57:04 -0700 | [diff] [blame] | 181 | java_lang_reflect_AbstractMethod = CacheClass(env, "java/lang/reflect/AbstractMethod"); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 182 | java_lang_reflect_ArtMethod = CacheClass(env, "java/lang/reflect/ArtMethod"); |
| 183 | java_lang_reflect_Constructor = CacheClass(env, "java/lang/reflect/Constructor"); |
| 184 | java_lang_reflect_Field = CacheClass(env, "java/lang/reflect/Field"); |
| 185 | java_lang_reflect_Method = CacheClass(env, "java/lang/reflect/Method"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 186 | java_lang_reflect_Proxy = CacheClass(env, "java/lang/reflect/Proxy"); |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 187 | java_lang_RuntimeException = CacheClass(env, "java/lang/RuntimeException"); |
Ian Rogers | 120f1c7 | 2012-09-28 17:17:10 -0700 | [diff] [blame] | 188 | java_lang_StackOverflowError = CacheClass(env, "java/lang/StackOverflowError"); |
Ian Rogers | dd157d7 | 2014-05-15 14:47:50 -0700 | [diff] [blame] | 189 | java_lang_String = CacheClass(env, "java/lang/String"); |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 190 | java_lang_System = CacheClass(env, "java/lang/System"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 191 | java_lang_Thread = CacheClass(env, "java/lang/Thread"); |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 192 | java_lang_Thread__UncaughtExceptionHandler = CacheClass(env, |
| 193 | "java/lang/Thread$UncaughtExceptionHandler"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 194 | java_lang_ThreadGroup = CacheClass(env, "java/lang/ThreadGroup"); |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 195 | java_lang_Throwable = CacheClass(env, "java/lang/Throwable"); |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 196 | java_nio_DirectByteBuffer = CacheClass(env, "java/nio/DirectByteBuffer"); |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 197 | java_util_ArrayList = CacheClass(env, "java/util/ArrayList"); |
Andreas Gampe | 7ea6f79 | 2014-07-14 16:21:44 -0700 | [diff] [blame] | 198 | java_util_Collections = CacheClass(env, "java/util/Collections"); |
| 199 | libcore_util_EmptyArray = CacheClass(env, "libcore/util/EmptyArray"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 200 | org_apache_harmony_dalvik_ddmc_Chunk = CacheClass(env, "org/apache/harmony/dalvik/ddmc/Chunk"); |
| 201 | org_apache_harmony_dalvik_ddmc_DdmServer = CacheClass(env, "org/apache/harmony/dalvik/ddmc/DdmServer"); |
| 202 | |
| 203 | com_android_dex_Dex_create = CacheMethod(env, com_android_dex_Dex, true, "create", "(Ljava/nio/ByteBuffer;)Lcom/android/dex/Dex;"); |
| 204 | java_lang_ClassNotFoundException_init = CacheMethod(env, java_lang_ClassNotFoundException, false, "<init>", "(Ljava/lang/String;Ljava/lang/Throwable;)V"); |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 205 | java_lang_ClassLoader_loadClass = CacheMethod(env, java_lang_ClassLoader, false, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"); |
Mathieu Chartier | 7664f5c | 2012-06-08 18:15:32 -0700 | [diff] [blame] | 206 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 207 | java_lang_Daemons_requestHeapTrim = CacheMethod(env, java_lang_Daemons, true, "requestHeapTrim", "()V"); |
| 208 | java_lang_Daemons_start = CacheMethod(env, java_lang_Daemons, true, "start", "()V"); |
Mathieu Chartier | cef50f0 | 2014-12-09 17:38:52 -0800 | [diff] [blame] | 209 | java_lang_Daemons_stop = CacheMethod(env, java_lang_Daemons, true, "stop", "()V"); |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 210 | |
| 211 | ScopedLocalRef<jclass> java_lang_ref_FinalizerReference(env, env->FindClass("java/lang/ref/FinalizerReference")); |
| 212 | java_lang_ref_FinalizerReference_add = CacheMethod(env, java_lang_ref_FinalizerReference.get(), true, "add", "(Ljava/lang/Object;)V"); |
| 213 | ScopedLocalRef<jclass> java_lang_ref_ReferenceQueue(env, env->FindClass("java/lang/ref/ReferenceQueue")); |
| 214 | java_lang_ref_ReferenceQueue_add = CacheMethod(env, java_lang_ref_ReferenceQueue.get(), true, "add", "(Ljava/lang/ref/Reference;)V"); |
| 215 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 216 | java_lang_reflect_Proxy_invoke = CacheMethod(env, java_lang_reflect_Proxy, true, "invoke", "(Ljava/lang/reflect/Proxy;Ljava/lang/reflect/ArtMethod;[Ljava/lang/Object;)Ljava/lang/Object;"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 217 | java_lang_Thread_init = CacheMethod(env, java_lang_Thread, false, "<init>", "(Ljava/lang/ThreadGroup;Ljava/lang/String;IZ)V"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 218 | java_lang_Thread_run = CacheMethod(env, java_lang_Thread, false, "run", "()V"); |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 219 | java_lang_Thread__UncaughtExceptionHandler_uncaughtException = CacheMethod(env, java_lang_Thread__UncaughtExceptionHandler, false, "uncaughtException", "(Ljava/lang/Thread;Ljava/lang/Throwable;)V"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 220 | java_lang_ThreadGroup_removeThread = CacheMethod(env, java_lang_ThreadGroup, false, "removeThread", "(Ljava/lang/Thread;)V"); |
Elliott Hughes | b568121 | 2013-03-29 17:29:22 -0700 | [diff] [blame] | 221 | java_nio_DirectByteBuffer_init = CacheMethod(env, java_nio_DirectByteBuffer, false, "<init>", "(JI)V"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 222 | org_apache_harmony_dalvik_ddmc_DdmServer_broadcast = CacheMethod(env, org_apache_harmony_dalvik_ddmc_DdmServer, true, "broadcast", "(I)V"); |
| 223 | org_apache_harmony_dalvik_ddmc_DdmServer_dispatch = CacheMethod(env, org_apache_harmony_dalvik_ddmc_DdmServer, true, "dispatch", "(I[BII)Lorg/apache/harmony/dalvik/ddmc/Chunk;"); |
| 224 | |
Andreas Gampe | 324b9bb | 2015-02-23 16:33:22 -0800 | [diff] [blame] | 225 | dalvik_system_DexFile_cookie = CacheField(env, dalvik_system_DexFile, false, "mCookie", "Ljava/lang/Object;"); |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 226 | dalvik_system_PathClassLoader_pathList = CacheField(env, dalvik_system_PathClassLoader, false, "pathList", "Ldalvik/system/DexPathList;"); |
| 227 | dalvik_system_DexPathList_dexElements = CacheField(env, dalvik_system_DexPathList, false, "dexElements", "[Ldalvik/system/DexPathList$Element;"); |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 228 | dalvik_system_DexPathList__Element_dexFile = CacheField(env, dalvik_system_DexPathList__Element, false, "dexFile", "Ldalvik/system/DexFile;"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 229 | java_lang_Thread_daemon = CacheField(env, java_lang_Thread, false, "daemon", "Z"); |
| 230 | java_lang_Thread_group = CacheField(env, java_lang_Thread, false, "group", "Ljava/lang/ThreadGroup;"); |
Elliott Hughes | c5dc2ff | 2013-01-09 13:44:30 -0800 | [diff] [blame] | 231 | java_lang_Thread_lock = CacheField(env, java_lang_Thread, false, "lock", "Ljava/lang/Object;"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 232 | java_lang_Thread_name = CacheField(env, java_lang_Thread, false, "name", "Ljava/lang/String;"); |
| 233 | java_lang_Thread_priority = CacheField(env, java_lang_Thread, false, "priority", "I"); |
| 234 | java_lang_Thread_uncaughtHandler = CacheField(env, java_lang_Thread, false, "uncaughtHandler", "Ljava/lang/Thread$UncaughtExceptionHandler;"); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 235 | java_lang_Thread_nativePeer = CacheField(env, java_lang_Thread, false, "nativePeer", "J"); |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 236 | java_lang_ThreadGroup_groups = CacheField(env, java_lang_ThreadGroup, false, "groups", "Ljava/util/List;"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 237 | java_lang_ThreadGroup_mainThreadGroup = CacheField(env, java_lang_ThreadGroup, true, "mainThreadGroup", "Ljava/lang/ThreadGroup;"); |
| 238 | java_lang_ThreadGroup_name = CacheField(env, java_lang_ThreadGroup, false, "name", "Ljava/lang/String;"); |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 239 | java_lang_ThreadGroup_parent = CacheField(env, java_lang_ThreadGroup, false, "parent", "Ljava/lang/ThreadGroup;"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 240 | java_lang_ThreadGroup_systemThreadGroup = CacheField(env, java_lang_ThreadGroup, true, "systemThreadGroup", "Ljava/lang/ThreadGroup;"); |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 241 | java_lang_Throwable_cause = CacheField(env, java_lang_Throwable, false, "cause", "Ljava/lang/Throwable;"); |
| 242 | java_lang_Throwable_detailMessage = CacheField(env, java_lang_Throwable, false, "detailMessage", "Ljava/lang/String;"); |
| 243 | java_lang_Throwable_stackTrace = CacheField(env, java_lang_Throwable, false, "stackTrace", "[Ljava/lang/StackTraceElement;"); |
| 244 | java_lang_Throwable_stackState = CacheField(env, java_lang_Throwable, false, "stackState", "Ljava/lang/Object;"); |
| 245 | java_lang_Throwable_suppressedExceptions = CacheField(env, java_lang_Throwable, false, "suppressedExceptions", "Ljava/util/List;"); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 246 | java_lang_reflect_AbstractMethod_artMethod = CacheField(env, java_lang_reflect_AbstractMethod, false, "artMethod", "Ljava/lang/reflect/ArtMethod;"); |
| 247 | java_lang_reflect_Field_artField = CacheField(env, java_lang_reflect_Field, false, "artField", "Ljava/lang/reflect/ArtField;"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 248 | java_lang_reflect_Proxy_h = CacheField(env, java_lang_reflect_Proxy, false, "h", "Ljava/lang/reflect/InvocationHandler;"); |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 249 | java_nio_DirectByteBuffer_capacity = CacheField(env, java_nio_DirectByteBuffer, false, "capacity", "I"); |
Elliott Hughes | 2e8a4fc | 2013-03-29 16:33:52 -0700 | [diff] [blame] | 250 | java_nio_DirectByteBuffer_effectiveDirectAddress = CacheField(env, java_nio_DirectByteBuffer, false, "effectiveDirectAddress", "J"); |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 251 | java_util_ArrayList_array = CacheField(env, java_util_ArrayList, false, "array", "[Ljava/lang/Object;"); |
| 252 | java_util_ArrayList_size = CacheField(env, java_util_ArrayList, false, "size", "I"); |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 253 | java_util_Collections_EMPTY_LIST = CacheField(env, java_util_Collections, true, "EMPTY_LIST", "Ljava/util/List;"); |
| 254 | libcore_util_EmptyArray_STACK_TRACE_ELEMENT = CacheField(env, libcore_util_EmptyArray, true, "STACK_TRACE_ELEMENT", "[Ljava/lang/StackTraceElement;"); |
Sebastien Hertz | b30e0c6 | 2014-09-11 16:23:44 +0200 | [diff] [blame] | 255 | org_apache_harmony_dalvik_ddmc_Chunk_data = CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "data", "[B"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 256 | org_apache_harmony_dalvik_ddmc_Chunk_length = CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "length", "I"); |
| 257 | org_apache_harmony_dalvik_ddmc_Chunk_offset = CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "offset", "I"); |
| 258 | org_apache_harmony_dalvik_ddmc_Chunk_type = CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "type", "I"); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 259 | |
| 260 | java_lang_Boolean_valueOf = CachePrimitiveBoxingMethod(env, 'Z', "java/lang/Boolean"); |
| 261 | java_lang_Byte_valueOf = CachePrimitiveBoxingMethod(env, 'B', "java/lang/Byte"); |
| 262 | java_lang_Character_valueOf = CachePrimitiveBoxingMethod(env, 'C', "java/lang/Character"); |
| 263 | java_lang_Double_valueOf = CachePrimitiveBoxingMethod(env, 'D', "java/lang/Double"); |
| 264 | java_lang_Float_valueOf = CachePrimitiveBoxingMethod(env, 'F', "java/lang/Float"); |
| 265 | java_lang_Integer_valueOf = CachePrimitiveBoxingMethod(env, 'I', "java/lang/Integer"); |
| 266 | java_lang_Long_valueOf = CachePrimitiveBoxingMethod(env, 'J', "java/lang/Long"); |
| 267 | java_lang_Short_valueOf = CachePrimitiveBoxingMethod(env, 'S', "java/lang/Short"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 268 | } |
| 269 | |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 270 | void WellKnownClasses::LateInit(JNIEnv* env) { |
| 271 | ScopedLocalRef<jclass> java_lang_Runtime(env, env->FindClass("java/lang/Runtime")); |
Dmitriy Ivanov | 785049f | 2014-07-18 10:08:57 -0700 | [diff] [blame] | 272 | java_lang_Runtime_nativeLoad = CacheMethod(env, java_lang_Runtime.get(), true, "nativeLoad", "(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 273 | } |
| 274 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 275 | mirror::Class* WellKnownClasses::ToClass(jclass global_jclass) { |
| 276 | return reinterpret_cast<mirror::Class*>(Thread::Current()->DecodeJObject(global_jclass)); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | } // namespace art |