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" |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 25 | #include "mirror/throwable.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 26 | #include "ScopedLocalRef.h" |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 27 | #include "scoped_thread_state_change.h" |
Brian Carlstrom | a3d2718 | 2013-11-05 23:22:27 -0800 | [diff] [blame] | 28 | #include "thread-inl.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 29 | |
| 30 | namespace art { |
| 31 | |
| 32 | jclass WellKnownClasses::com_android_dex_Dex; |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame^] | 33 | jclass WellKnownClasses::dalvik_annotation_optimization_FastNative; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 34 | jclass WellKnownClasses::dalvik_system_DexFile; |
| 35 | jclass WellKnownClasses::dalvik_system_DexPathList; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 36 | jclass WellKnownClasses::dalvik_system_DexPathList__Element; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 37 | jclass WellKnownClasses::dalvik_system_PathClassLoader; |
Mathieu Chartier | b5de3bb | 2015-06-05 13:21:05 -0700 | [diff] [blame] | 38 | jclass WellKnownClasses::dalvik_system_VMRuntime; |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 39 | jclass WellKnownClasses::java_lang_annotation_Annotation__array; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 40 | jclass WellKnownClasses::java_lang_BootClassLoader; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 41 | jclass WellKnownClasses::java_lang_ClassLoader; |
| 42 | jclass WellKnownClasses::java_lang_ClassNotFoundException; |
| 43 | jclass WellKnownClasses::java_lang_Daemons; |
| 44 | jclass WellKnownClasses::java_lang_Error; |
Jeff Hao | c92a7a1 | 2016-06-06 11:09:20 -0700 | [diff] [blame] | 45 | jclass WellKnownClasses::java_lang_ExceptionInInitializerError; |
| 46 | jclass WellKnownClasses::java_lang_IllegalAccessError; |
| 47 | jclass WellKnownClasses::java_lang_NoClassDefFoundError; |
Ian Rogers | af6e67a | 2013-01-16 08:38:37 -0800 | [diff] [blame] | 48 | jclass WellKnownClasses::java_lang_Object; |
Mathieu Chartier | a61894d | 2015-04-23 16:32:54 -0700 | [diff] [blame] | 49 | jclass WellKnownClasses::java_lang_OutOfMemoryError; |
Mathieu Chartier | 66f1925 | 2012-09-18 08:57:04 -0700 | [diff] [blame] | 50 | jclass WellKnownClasses::java_lang_reflect_AbstractMethod; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 51 | jclass WellKnownClasses::java_lang_reflect_Constructor; |
| 52 | jclass WellKnownClasses::java_lang_reflect_Field; |
| 53 | jclass WellKnownClasses::java_lang_reflect_Method; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 54 | jclass WellKnownClasses::java_lang_reflect_Proxy; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 55 | jclass WellKnownClasses::java_lang_RuntimeException; |
Ian Rogers | 120f1c7 | 2012-09-28 17:17:10 -0700 | [diff] [blame] | 56 | jclass WellKnownClasses::java_lang_StackOverflowError; |
Ian Rogers | dd157d7 | 2014-05-15 14:47:50 -0700 | [diff] [blame] | 57 | jclass WellKnownClasses::java_lang_String; |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 58 | jclass WellKnownClasses::java_lang_StringFactory; |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 59 | jclass WellKnownClasses::java_lang_System; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 60 | jclass WellKnownClasses::java_lang_Thread; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 61 | jclass WellKnownClasses::java_lang_ThreadGroup; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 62 | jclass WellKnownClasses::java_lang_Throwable; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 63 | jclass WellKnownClasses::java_nio_DirectByteBuffer; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 64 | jclass WellKnownClasses::java_util_ArrayList; |
Andreas Gampe | 7ea6f79 | 2014-07-14 16:21:44 -0700 | [diff] [blame] | 65 | jclass WellKnownClasses::java_util_Collections; |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 66 | jclass WellKnownClasses::libcore_reflect_AnnotationFactory; |
| 67 | jclass WellKnownClasses::libcore_reflect_AnnotationMember; |
Andreas Gampe | 7ea6f79 | 2014-07-14 16:21:44 -0700 | [diff] [blame] | 68 | jclass WellKnownClasses::libcore_util_EmptyArray; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 69 | jclass WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk; |
| 70 | jclass WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer; |
| 71 | |
| 72 | jmethodID WellKnownClasses::com_android_dex_Dex_create; |
Mathieu Chartier | b5de3bb | 2015-06-05 13:21:05 -0700 | [diff] [blame] | 73 | jmethodID WellKnownClasses::dalvik_system_VMRuntime_runFinalization; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 74 | jmethodID WellKnownClasses::java_lang_Boolean_valueOf; |
| 75 | jmethodID WellKnownClasses::java_lang_Byte_valueOf; |
| 76 | jmethodID WellKnownClasses::java_lang_Character_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 77 | jmethodID WellKnownClasses::java_lang_ClassLoader_loadClass; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 78 | jmethodID WellKnownClasses::java_lang_ClassNotFoundException_init; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 79 | jmethodID WellKnownClasses::java_lang_Daemons_requestHeapTrim; |
| 80 | jmethodID WellKnownClasses::java_lang_Daemons_start; |
Mathieu Chartier | cef50f0 | 2014-12-09 17:38:52 -0800 | [diff] [blame] | 81 | jmethodID WellKnownClasses::java_lang_Daemons_stop; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 82 | jmethodID WellKnownClasses::java_lang_Double_valueOf; |
| 83 | jmethodID WellKnownClasses::java_lang_Float_valueOf; |
| 84 | jmethodID WellKnownClasses::java_lang_Integer_valueOf; |
| 85 | jmethodID WellKnownClasses::java_lang_Long_valueOf; |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 86 | jmethodID WellKnownClasses::java_lang_ref_FinalizerReference_add; |
| 87 | jmethodID WellKnownClasses::java_lang_ref_ReferenceQueue_add; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 88 | jmethodID WellKnownClasses::java_lang_reflect_Proxy_invoke; |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 89 | jmethodID WellKnownClasses::java_lang_Runtime_nativeLoad; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 90 | jmethodID WellKnownClasses::java_lang_Short_valueOf; |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 91 | jmethodID WellKnownClasses::java_lang_String_init; |
| 92 | jmethodID WellKnownClasses::java_lang_String_init_B; |
| 93 | jmethodID WellKnownClasses::java_lang_String_init_BI; |
| 94 | jmethodID WellKnownClasses::java_lang_String_init_BII; |
| 95 | jmethodID WellKnownClasses::java_lang_String_init_BIII; |
| 96 | jmethodID WellKnownClasses::java_lang_String_init_BIIString; |
| 97 | jmethodID WellKnownClasses::java_lang_String_init_BString; |
| 98 | jmethodID WellKnownClasses::java_lang_String_init_BIICharset; |
| 99 | jmethodID WellKnownClasses::java_lang_String_init_BCharset; |
| 100 | jmethodID WellKnownClasses::java_lang_String_init_C; |
| 101 | jmethodID WellKnownClasses::java_lang_String_init_CII; |
| 102 | jmethodID WellKnownClasses::java_lang_String_init_IIC; |
| 103 | jmethodID WellKnownClasses::java_lang_String_init_String; |
| 104 | jmethodID WellKnownClasses::java_lang_String_init_StringBuffer; |
| 105 | jmethodID WellKnownClasses::java_lang_String_init_III; |
| 106 | jmethodID WellKnownClasses::java_lang_String_init_StringBuilder; |
| 107 | jmethodID WellKnownClasses::java_lang_StringFactory_newEmptyString; |
| 108 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromBytes_B; |
| 109 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromBytes_BI; |
| 110 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromBytes_BII; |
| 111 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromBytes_BIII; |
| 112 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromBytes_BIIString; |
| 113 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromBytes_BString; |
| 114 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromBytes_BIICharset; |
| 115 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromBytes_BCharset; |
| 116 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromChars_C; |
| 117 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromChars_CII; |
| 118 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromChars_IIC; |
| 119 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromString; |
| 120 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromStringBuffer; |
| 121 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromCodePoints; |
| 122 | jmethodID WellKnownClasses::java_lang_StringFactory_newStringFromStringBuilder; |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 123 | jmethodID WellKnownClasses::java_lang_System_runFinalization = nullptr; |
Tobias Thierer | 5cbe65d | 2016-07-22 18:37:59 +0100 | [diff] [blame] | 124 | jmethodID WellKnownClasses::java_lang_Thread_dispatchUncaughtException; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 125 | jmethodID WellKnownClasses::java_lang_Thread_init; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 126 | jmethodID WellKnownClasses::java_lang_Thread_run; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 127 | jmethodID WellKnownClasses::java_lang_ThreadGroup_removeThread; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 128 | jmethodID WellKnownClasses::java_nio_DirectByteBuffer_init; |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 129 | jmethodID WellKnownClasses::libcore_reflect_AnnotationFactory_createAnnotation; |
| 130 | jmethodID WellKnownClasses::libcore_reflect_AnnotationMember_init; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 131 | jmethodID WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; |
| 132 | jmethodID WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; |
| 133 | |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 134 | jfieldID WellKnownClasses::dalvik_system_DexFile_cookie; |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 135 | jfieldID WellKnownClasses::dalvik_system_DexFile_fileName; |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 136 | jfieldID WellKnownClasses::dalvik_system_PathClassLoader_pathList; |
| 137 | jfieldID WellKnownClasses::dalvik_system_DexPathList_dexElements; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 138 | jfieldID WellKnownClasses::dalvik_system_DexPathList__Element_dexFile; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 139 | jfieldID WellKnownClasses::java_lang_Thread_daemon; |
| 140 | jfieldID WellKnownClasses::java_lang_Thread_group; |
| 141 | jfieldID WellKnownClasses::java_lang_Thread_lock; |
| 142 | jfieldID WellKnownClasses::java_lang_Thread_name; |
| 143 | jfieldID WellKnownClasses::java_lang_Thread_priority; |
Anwar Ghuloum | 3c50a4b | 2013-06-21 13:05:23 -0700 | [diff] [blame] | 144 | jfieldID WellKnownClasses::java_lang_Thread_nativePeer; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 145 | jfieldID WellKnownClasses::java_lang_ThreadGroup_groups; |
Przemyslaw Szczepaniak | 464595f | 2015-11-24 11:59:59 +0000 | [diff] [blame] | 146 | jfieldID WellKnownClasses::java_lang_ThreadGroup_ngroups; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 147 | jfieldID WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup; |
| 148 | jfieldID WellKnownClasses::java_lang_ThreadGroup_name; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 149 | jfieldID WellKnownClasses::java_lang_ThreadGroup_parent; |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 150 | jfieldID WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup; |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 151 | jfieldID WellKnownClasses::java_lang_Throwable_cause; |
| 152 | jfieldID WellKnownClasses::java_lang_Throwable_detailMessage; |
| 153 | jfieldID WellKnownClasses::java_lang_Throwable_stackTrace; |
| 154 | jfieldID WellKnownClasses::java_lang_Throwable_stackState; |
| 155 | jfieldID WellKnownClasses::java_lang_Throwable_suppressedExceptions; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 156 | jfieldID WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 157 | jfieldID WellKnownClasses::java_lang_reflect_Proxy_h; |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 158 | jfieldID WellKnownClasses::java_nio_DirectByteBuffer_capacity; |
| 159 | jfieldID WellKnownClasses::java_nio_DirectByteBuffer_effectiveDirectAddress; |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 160 | jfieldID WellKnownClasses::java_util_ArrayList_array; |
| 161 | jfieldID WellKnownClasses::java_util_ArrayList_size; |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 162 | jfieldID WellKnownClasses::java_util_Collections_EMPTY_LIST; |
| 163 | jfieldID WellKnownClasses::libcore_util_EmptyArray_STACK_TRACE_ELEMENT; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 164 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_data; |
| 165 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_length; |
| 166 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_offset; |
| 167 | jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_type; |
| 168 | |
| 169 | static jclass CacheClass(JNIEnv* env, const char* jni_class_name) { |
| 170 | ScopedLocalRef<jclass> c(env, env->FindClass(jni_class_name)); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 171 | if (c.get() == nullptr) { |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 172 | LOG(FATAL) << "Couldn't find class: " << jni_class_name; |
| 173 | } |
| 174 | return reinterpret_cast<jclass>(env->NewGlobalRef(c.get())); |
| 175 | } |
| 176 | |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 177 | static jfieldID CacheField(JNIEnv* env, jclass c, bool is_static, |
| 178 | const char* name, const char* signature) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 179 | jfieldID fid = is_static ? env->GetStaticFieldID(c, name, signature) : |
| 180 | env->GetFieldID(c, name, signature); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 181 | if (fid == nullptr) { |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 182 | ScopedObjectAccess soa(env); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 183 | if (soa.Self()->IsExceptionPending()) { |
| 184 | LOG(INTERNAL_FATAL) << soa.Self()->GetException()->Dump() << '\n'; |
| 185 | } |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 186 | std::ostringstream os; |
| 187 | WellKnownClasses::ToClass(c)->DumpClass(os, mirror::Class::kDumpClassFullDetail); |
| 188 | LOG(FATAL) << "Couldn't find field \"" << name << "\" with signature \"" << signature << "\": " |
| 189 | << os.str(); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 190 | } |
| 191 | return fid; |
| 192 | } |
| 193 | |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 194 | jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, |
| 195 | const char* name, const char* signature) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 196 | jmethodID mid = is_static ? env->GetStaticMethodID(c, name, signature) : |
| 197 | env->GetMethodID(c, name, signature); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 198 | if (mid == nullptr) { |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 199 | ScopedObjectAccess soa(env); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 200 | if (soa.Self()->IsExceptionPending()) { |
| 201 | LOG(INTERNAL_FATAL) << soa.Self()->GetException()->Dump() << '\n'; |
| 202 | } |
Brian Carlstrom | 3c821c6 | 2014-09-10 10:08:37 -0700 | [diff] [blame] | 203 | std::ostringstream os; |
| 204 | WellKnownClasses::ToClass(c)->DumpClass(os, mirror::Class::kDumpClassFullDetail); |
| 205 | LOG(FATAL) << "Couldn't find method \"" << name << "\" with signature \"" << signature << "\": " |
| 206 | << os.str(); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 207 | } |
| 208 | return mid; |
| 209 | } |
| 210 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 211 | static jmethodID CachePrimitiveBoxingMethod(JNIEnv* env, char prim_name, const char* boxed_name) { |
| 212 | ScopedLocalRef<jclass> boxed_class(env, env->FindClass(boxed_name)); |
| 213 | return CacheMethod(env, boxed_class.get(), true, "valueOf", |
| 214 | StringPrintf("(%c)L%s;", prim_name, boxed_name).c_str()); |
| 215 | } |
| 216 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 217 | void WellKnownClasses::Init(JNIEnv* env) { |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 218 | com_android_dex_Dex = CacheClass(env, "com/android/dex/Dex"); |
Igor Murashkin | 9d4b6da | 2016-07-29 09:51:58 -0700 | [diff] [blame^] | 219 | dalvik_annotation_optimization_FastNative = CacheClass(env, "dalvik/annotation/optimization/FastNative"); |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 220 | dalvik_system_DexFile = CacheClass(env, "dalvik/system/DexFile"); |
| 221 | dalvik_system_DexPathList = CacheClass(env, "dalvik/system/DexPathList"); |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 222 | dalvik_system_DexPathList__Element = CacheClass(env, "dalvik/system/DexPathList$Element"); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 223 | dalvik_system_PathClassLoader = CacheClass(env, "dalvik/system/PathClassLoader"); |
Mathieu Chartier | b5de3bb | 2015-06-05 13:21:05 -0700 | [diff] [blame] | 224 | dalvik_system_VMRuntime = CacheClass(env, "dalvik/system/VMRuntime"); |
| 225 | |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 226 | java_lang_annotation_Annotation__array = CacheClass(env, "[Ljava/lang/annotation/Annotation;"); |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 227 | java_lang_BootClassLoader = CacheClass(env, "java/lang/BootClassLoader"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 228 | java_lang_ClassLoader = CacheClass(env, "java/lang/ClassLoader"); |
| 229 | java_lang_ClassNotFoundException = CacheClass(env, "java/lang/ClassNotFoundException"); |
| 230 | java_lang_Daemons = CacheClass(env, "java/lang/Daemons"); |
Ian Rogers | af6e67a | 2013-01-16 08:38:37 -0800 | [diff] [blame] | 231 | java_lang_Object = CacheClass(env, "java/lang/Object"); |
Mathieu Chartier | a61894d | 2015-04-23 16:32:54 -0700 | [diff] [blame] | 232 | java_lang_OutOfMemoryError = CacheClass(env, "java/lang/OutOfMemoryError"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 233 | java_lang_Error = CacheClass(env, "java/lang/Error"); |
Jeff Hao | c92a7a1 | 2016-06-06 11:09:20 -0700 | [diff] [blame] | 234 | java_lang_ExceptionInInitializerError = CacheClass(env, "java/lang/ExceptionInInitializerError"); |
| 235 | java_lang_IllegalAccessError = CacheClass(env, "java/lang/IllegalAccessError"); |
| 236 | java_lang_NoClassDefFoundError = CacheClass(env, "java/lang/NoClassDefFoundError"); |
Mathieu Chartier | 66f1925 | 2012-09-18 08:57:04 -0700 | [diff] [blame] | 237 | java_lang_reflect_AbstractMethod = CacheClass(env, "java/lang/reflect/AbstractMethod"); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 238 | java_lang_reflect_Constructor = CacheClass(env, "java/lang/reflect/Constructor"); |
| 239 | java_lang_reflect_Field = CacheClass(env, "java/lang/reflect/Field"); |
| 240 | java_lang_reflect_Method = CacheClass(env, "java/lang/reflect/Method"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 241 | java_lang_reflect_Proxy = CacheClass(env, "java/lang/reflect/Proxy"); |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 242 | java_lang_RuntimeException = CacheClass(env, "java/lang/RuntimeException"); |
Ian Rogers | 120f1c7 | 2012-09-28 17:17:10 -0700 | [diff] [blame] | 243 | java_lang_StackOverflowError = CacheClass(env, "java/lang/StackOverflowError"); |
Ian Rogers | dd157d7 | 2014-05-15 14:47:50 -0700 | [diff] [blame] | 244 | java_lang_String = CacheClass(env, "java/lang/String"); |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 245 | java_lang_StringFactory = CacheClass(env, "java/lang/StringFactory"); |
Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 246 | java_lang_System = CacheClass(env, "java/lang/System"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 247 | java_lang_Thread = CacheClass(env, "java/lang/Thread"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 248 | java_lang_ThreadGroup = CacheClass(env, "java/lang/ThreadGroup"); |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 249 | java_lang_Throwable = CacheClass(env, "java/lang/Throwable"); |
Elliott Hughes | aecb5f3 | 2013-03-28 08:27:38 -0700 | [diff] [blame] | 250 | java_nio_DirectByteBuffer = CacheClass(env, "java/nio/DirectByteBuffer"); |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 251 | java_util_ArrayList = CacheClass(env, "java/util/ArrayList"); |
Andreas Gampe | 7ea6f79 | 2014-07-14 16:21:44 -0700 | [diff] [blame] | 252 | java_util_Collections = CacheClass(env, "java/util/Collections"); |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 253 | libcore_reflect_AnnotationFactory = CacheClass(env, "libcore/reflect/AnnotationFactory"); |
| 254 | libcore_reflect_AnnotationMember = CacheClass(env, "libcore/reflect/AnnotationMember"); |
Andreas Gampe | 7ea6f79 | 2014-07-14 16:21:44 -0700 | [diff] [blame] | 255 | libcore_util_EmptyArray = CacheClass(env, "libcore/util/EmptyArray"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 256 | org_apache_harmony_dalvik_ddmc_Chunk = CacheClass(env, "org/apache/harmony/dalvik/ddmc/Chunk"); |
| 257 | org_apache_harmony_dalvik_ddmc_DdmServer = CacheClass(env, "org/apache/harmony/dalvik/ddmc/DdmServer"); |
| 258 | |
Mathieu Chartier | b5de3bb | 2015-06-05 13:21:05 -0700 | [diff] [blame] | 259 | dalvik_system_VMRuntime_runFinalization = CacheMethod(env, dalvik_system_VMRuntime, true, "runFinalization", "(J)V"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 260 | com_android_dex_Dex_create = CacheMethod(env, com_android_dex_Dex, true, "create", "(Ljava/nio/ByteBuffer;)Lcom/android/dex/Dex;"); |
| 261 | 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] | 262 | 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] | 263 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 264 | java_lang_Daemons_requestHeapTrim = CacheMethod(env, java_lang_Daemons, true, "requestHeapTrim", "()V"); |
| 265 | java_lang_Daemons_start = CacheMethod(env, java_lang_Daemons, true, "start", "()V"); |
Mathieu Chartier | cef50f0 | 2014-12-09 17:38:52 -0800 | [diff] [blame] | 266 | java_lang_Daemons_stop = CacheMethod(env, java_lang_Daemons, true, "stop", "()V"); |
Elliott Hughes | a4f9474 | 2012-05-29 16:28:38 -0700 | [diff] [blame] | 267 | |
| 268 | ScopedLocalRef<jclass> java_lang_ref_FinalizerReference(env, env->FindClass("java/lang/ref/FinalizerReference")); |
| 269 | java_lang_ref_FinalizerReference_add = CacheMethod(env, java_lang_ref_FinalizerReference.get(), true, "add", "(Ljava/lang/Object;)V"); |
| 270 | ScopedLocalRef<jclass> java_lang_ref_ReferenceQueue(env, env->FindClass("java/lang/ref/ReferenceQueue")); |
| 271 | java_lang_ref_ReferenceQueue_add = CacheMethod(env, java_lang_ref_ReferenceQueue.get(), true, "add", "(Ljava/lang/ref/Reference;)V"); |
| 272 | |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 273 | java_lang_reflect_Proxy_invoke = CacheMethod(env, java_lang_reflect_Proxy, true, "invoke", "(Ljava/lang/reflect/Proxy;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;"); |
Tobias Thierer | 5cbe65d | 2016-07-22 18:37:59 +0100 | [diff] [blame] | 274 | java_lang_Thread_dispatchUncaughtException = CacheMethod(env, java_lang_Thread, false, "dispatchUncaughtException", "(Ljava/lang/Throwable;)V"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 275 | 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] | 276 | java_lang_Thread_run = CacheMethod(env, java_lang_Thread, false, "run", "()V"); |
Piotr Jastrzebski | e6cd3b5 | 2015-05-07 09:41:00 +0100 | [diff] [blame] | 277 | java_lang_ThreadGroup_removeThread = CacheMethod(env, java_lang_ThreadGroup, false, "threadTerminated", "(Ljava/lang/Thread;)V"); |
Elliott Hughes | b568121 | 2013-03-29 17:29:22 -0700 | [diff] [blame] | 278 | java_nio_DirectByteBuffer_init = CacheMethod(env, java_nio_DirectByteBuffer, false, "<init>", "(JI)V"); |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 279 | libcore_reflect_AnnotationFactory_createAnnotation = CacheMethod(env, libcore_reflect_AnnotationFactory, true, "createAnnotation", "(Ljava/lang/Class;[Llibcore/reflect/AnnotationMember;)Ljava/lang/annotation/Annotation;"); |
| 280 | libcore_reflect_AnnotationMember_init = CacheMethod(env, libcore_reflect_AnnotationMember, false, "<init>", "(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/reflect/Method;)V"); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 281 | org_apache_harmony_dalvik_ddmc_DdmServer_broadcast = CacheMethod(env, org_apache_harmony_dalvik_ddmc_DdmServer, true, "broadcast", "(I)V"); |
| 282 | 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;"); |
| 283 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 284 | java_lang_String_init = CacheMethod(env, java_lang_String, false, "<init>", "()V"); |
| 285 | java_lang_String_init_B = CacheMethod(env, java_lang_String, false, "<init>", "([B)V"); |
| 286 | java_lang_String_init_BI = CacheMethod(env, java_lang_String, false, "<init>", "([BI)V"); |
| 287 | java_lang_String_init_BII = CacheMethod(env, java_lang_String, false, "<init>", "([BII)V"); |
| 288 | java_lang_String_init_BIII = CacheMethod(env, java_lang_String, false, "<init>", "([BIII)V"); |
| 289 | java_lang_String_init_BIIString = CacheMethod(env, java_lang_String, false, "<init>", |
| 290 | "([BIILjava/lang/String;)V"); |
| 291 | java_lang_String_init_BString = CacheMethod(env, java_lang_String, false, "<init>", |
| 292 | "([BLjava/lang/String;)V"); |
| 293 | java_lang_String_init_BIICharset = CacheMethod(env, java_lang_String, false, "<init>", |
| 294 | "([BIILjava/nio/charset/Charset;)V"); |
| 295 | java_lang_String_init_BCharset = CacheMethod(env, java_lang_String, false, "<init>", |
| 296 | "([BLjava/nio/charset/Charset;)V"); |
| 297 | java_lang_String_init_C = CacheMethod(env, java_lang_String, false, "<init>", "([C)V"); |
| 298 | java_lang_String_init_CII = CacheMethod(env, java_lang_String, false, "<init>", "([CII)V"); |
| 299 | java_lang_String_init_IIC = CacheMethod(env, java_lang_String, false, "<init>", "(II[C)V"); |
| 300 | java_lang_String_init_String = CacheMethod(env, java_lang_String, false, "<init>", |
| 301 | "(Ljava/lang/String;)V"); |
| 302 | java_lang_String_init_StringBuffer = CacheMethod(env, java_lang_String, false, "<init>", |
| 303 | "(Ljava/lang/StringBuffer;)V"); |
| 304 | java_lang_String_init_III = CacheMethod(env, java_lang_String, false, "<init>", "([III)V"); |
| 305 | java_lang_String_init_StringBuilder = CacheMethod(env, java_lang_String, false, "<init>", |
| 306 | "(Ljava/lang/StringBuilder;)V"); |
| 307 | java_lang_StringFactory_newEmptyString = CacheMethod(env, java_lang_StringFactory, true, |
| 308 | "newEmptyString", "()Ljava/lang/String;"); |
| 309 | java_lang_StringFactory_newStringFromBytes_B = CacheMethod(env, java_lang_StringFactory, true, |
| 310 | "newStringFromBytes", "([B)Ljava/lang/String;"); |
| 311 | java_lang_StringFactory_newStringFromBytes_BI = CacheMethod(env, java_lang_StringFactory, true, |
| 312 | "newStringFromBytes", "([BI)Ljava/lang/String;"); |
| 313 | java_lang_StringFactory_newStringFromBytes_BII = CacheMethod(env, java_lang_StringFactory, true, |
| 314 | "newStringFromBytes", "([BII)Ljava/lang/String;"); |
| 315 | java_lang_StringFactory_newStringFromBytes_BIII = CacheMethod(env, java_lang_StringFactory, true, |
| 316 | "newStringFromBytes", "([BIII)Ljava/lang/String;"); |
| 317 | java_lang_StringFactory_newStringFromBytes_BIIString = CacheMethod(env, java_lang_StringFactory, |
| 318 | true, "newStringFromBytes", "([BIILjava/lang/String;)Ljava/lang/String;"); |
| 319 | java_lang_StringFactory_newStringFromBytes_BString = CacheMethod(env, java_lang_StringFactory, |
| 320 | true, "newStringFromBytes", "([BLjava/lang/String;)Ljava/lang/String;"); |
| 321 | java_lang_StringFactory_newStringFromBytes_BIICharset = CacheMethod(env, java_lang_StringFactory, |
| 322 | true, "newStringFromBytes", "([BIILjava/nio/charset/Charset;)Ljava/lang/String;"); |
| 323 | java_lang_StringFactory_newStringFromBytes_BCharset = CacheMethod(env, java_lang_StringFactory, |
| 324 | true, "newStringFromBytes", "([BLjava/nio/charset/Charset;)Ljava/lang/String;"); |
| 325 | java_lang_StringFactory_newStringFromChars_C = CacheMethod(env, java_lang_StringFactory, true, |
| 326 | "newStringFromChars", "([C)Ljava/lang/String;"); |
| 327 | java_lang_StringFactory_newStringFromChars_CII = CacheMethod(env, java_lang_StringFactory, true, |
| 328 | "newStringFromChars", "([CII)Ljava/lang/String;"); |
| 329 | java_lang_StringFactory_newStringFromChars_IIC = CacheMethod(env, java_lang_StringFactory, true, |
| 330 | "newStringFromChars", "(II[C)Ljava/lang/String;"); |
| 331 | java_lang_StringFactory_newStringFromString = CacheMethod(env, java_lang_StringFactory, true, |
| 332 | "newStringFromString", "(Ljava/lang/String;)Ljava/lang/String;"); |
| 333 | java_lang_StringFactory_newStringFromStringBuffer = CacheMethod(env, java_lang_StringFactory, |
| 334 | true, "newStringFromStringBuffer", "(Ljava/lang/StringBuffer;)Ljava/lang/String;"); |
| 335 | java_lang_StringFactory_newStringFromCodePoints = CacheMethod(env, java_lang_StringFactory, |
| 336 | true, "newStringFromCodePoints", "([III)Ljava/lang/String;"); |
| 337 | java_lang_StringFactory_newStringFromStringBuilder = CacheMethod(env, java_lang_StringFactory, |
| 338 | true, "newStringFromStringBuilder", "(Ljava/lang/StringBuilder;)Ljava/lang/String;"); |
| 339 | |
Andreas Gampe | 324b9bb | 2015-02-23 16:33:22 -0800 | [diff] [blame] | 340 | dalvik_system_DexFile_cookie = CacheField(env, dalvik_system_DexFile, false, "mCookie", "Ljava/lang/Object;"); |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 341 | dalvik_system_DexFile_fileName = CacheField(env, dalvik_system_DexFile, false, "mFileName", "Ljava/lang/String;"); |
Mathieu Chartier | 6bcae8f | 2014-09-04 18:33:17 -0700 | [diff] [blame] | 342 | dalvik_system_PathClassLoader_pathList = CacheField(env, dalvik_system_PathClassLoader, false, "pathList", "Ldalvik/system/DexPathList;"); |
| 343 | 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] | 344 | 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] | 345 | java_lang_Thread_daemon = CacheField(env, java_lang_Thread, false, "daemon", "Z"); |
| 346 | 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] | 347 | 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] | 348 | java_lang_Thread_name = CacheField(env, java_lang_Thread, false, "name", "Ljava/lang/String;"); |
| 349 | java_lang_Thread_priority = CacheField(env, java_lang_Thread, false, "priority", "I"); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 350 | java_lang_Thread_nativePeer = CacheField(env, java_lang_Thread, false, "nativePeer", "J"); |
Narayan Kamath | d1ef436 | 2015-11-12 11:49:06 +0000 | [diff] [blame] | 351 | java_lang_ThreadGroup_groups = CacheField(env, java_lang_ThreadGroup, false, "groups", "[Ljava/lang/ThreadGroup;"); |
Przemyslaw Szczepaniak | 464595f | 2015-11-24 11:59:59 +0000 | [diff] [blame] | 352 | java_lang_ThreadGroup_ngroups = CacheField(env, java_lang_ThreadGroup, false, "ngroups", "I"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 353 | java_lang_ThreadGroup_mainThreadGroup = CacheField(env, java_lang_ThreadGroup, true, "mainThreadGroup", "Ljava/lang/ThreadGroup;"); |
| 354 | 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] | 355 | 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] | 356 | 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] | 357 | java_lang_Throwable_cause = CacheField(env, java_lang_Throwable, false, "cause", "Ljava/lang/Throwable;"); |
| 358 | java_lang_Throwable_detailMessage = CacheField(env, java_lang_Throwable, false, "detailMessage", "Ljava/lang/String;"); |
| 359 | java_lang_Throwable_stackTrace = CacheField(env, java_lang_Throwable, false, "stackTrace", "[Ljava/lang/StackTraceElement;"); |
Piotr Jastrzebski | c16a50f | 2015-05-07 09:41:00 +0100 | [diff] [blame] | 360 | java_lang_Throwable_stackState = CacheField(env, java_lang_Throwable, false, "backtrace", "Ljava/lang/Object;"); |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 361 | java_lang_Throwable_suppressedExceptions = CacheField(env, java_lang_Throwable, false, "suppressedExceptions", "Ljava/util/List;"); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 362 | java_lang_reflect_AbstractMethod_artMethod = CacheField(env, java_lang_reflect_AbstractMethod, false, "artMethod", "J"); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 363 | 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] | 364 | java_nio_DirectByteBuffer_capacity = CacheField(env, java_nio_DirectByteBuffer, false, "capacity", "I"); |
Piotr Jastrzebski | 8c145b9 | 2015-05-05 12:54:00 +0100 | [diff] [blame] | 365 | java_nio_DirectByteBuffer_effectiveDirectAddress = CacheField(env, java_nio_DirectByteBuffer, false, "address", "J"); |
Narayan Kamath | d1ef436 | 2015-11-12 11:49:06 +0000 | [diff] [blame] | 366 | java_util_ArrayList_array = CacheField(env, java_util_ArrayList, false, "elementData", "[Ljava/lang/Object;"); |
Sebastien Hertz | e49e195 | 2014-10-13 11:27:13 +0200 | [diff] [blame] | 367 | java_util_ArrayList_size = CacheField(env, java_util_ArrayList, false, "size", "I"); |
Brian Carlstrom | 3437531 | 2014-09-10 23:10:47 -0700 | [diff] [blame] | 368 | java_util_Collections_EMPTY_LIST = CacheField(env, java_util_Collections, true, "EMPTY_LIST", "Ljava/util/List;"); |
| 369 | 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] | 370 | 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] | 371 | org_apache_harmony_dalvik_ddmc_Chunk_length = CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "length", "I"); |
| 372 | org_apache_harmony_dalvik_ddmc_Chunk_offset = CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "offset", "I"); |
| 373 | 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] | 374 | |
| 375 | java_lang_Boolean_valueOf = CachePrimitiveBoxingMethod(env, 'Z', "java/lang/Boolean"); |
| 376 | java_lang_Byte_valueOf = CachePrimitiveBoxingMethod(env, 'B', "java/lang/Byte"); |
| 377 | java_lang_Character_valueOf = CachePrimitiveBoxingMethod(env, 'C', "java/lang/Character"); |
| 378 | java_lang_Double_valueOf = CachePrimitiveBoxingMethod(env, 'D', "java/lang/Double"); |
| 379 | java_lang_Float_valueOf = CachePrimitiveBoxingMethod(env, 'F', "java/lang/Float"); |
| 380 | java_lang_Integer_valueOf = CachePrimitiveBoxingMethod(env, 'I', "java/lang/Integer"); |
| 381 | java_lang_Long_valueOf = CachePrimitiveBoxingMethod(env, 'J', "java/lang/Long"); |
| 382 | java_lang_Short_valueOf = CachePrimitiveBoxingMethod(env, 'S', "java/lang/Short"); |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 383 | |
| 384 | Thread::Current()->InitStringEntryPoints(); |
Elliott Hughes | af8d15a | 2012-05-29 09:12:18 -0700 | [diff] [blame] | 385 | } |
| 386 | |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 387 | void WellKnownClasses::LateInit(JNIEnv* env) { |
| 388 | ScopedLocalRef<jclass> java_lang_Runtime(env, env->FindClass("java/lang/Runtime")); |
Dmitriy Ivanov | 44409d3 | 2015-11-11 14:18:55 -0800 | [diff] [blame] | 389 | java_lang_Runtime_nativeLoad = |
| 390 | CacheMethod(env, java_lang_Runtime.get(), true, "nativeLoad", |
Dimitry Ivanov | 942dc298 | 2016-02-24 13:33:33 -0800 | [diff] [blame] | 391 | "(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/String;)" |
Dmitriy Ivanov | 44409d3 | 2015-11-11 14:18:55 -0800 | [diff] [blame] | 392 | "Ljava/lang/String;"); |
Ian Rogers | ef28b14 | 2012-11-30 14:22:18 -0800 | [diff] [blame] | 393 | } |
| 394 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 395 | mirror::Class* WellKnownClasses::ToClass(jclass global_jclass) { |
| 396 | return reinterpret_cast<mirror::Class*>(Thread::Current()->DecodeJObject(global_jclass)); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 397 | } |
| 398 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 399 | jmethodID WellKnownClasses::StringInitToStringFactoryMethodID(jmethodID string_init) { |
| 400 | // TODO: Prioritize ordering. |
| 401 | if (string_init == java_lang_String_init) { |
| 402 | return java_lang_StringFactory_newEmptyString; |
| 403 | } else if (string_init == java_lang_String_init_B) { |
| 404 | return java_lang_StringFactory_newStringFromBytes_B; |
| 405 | } else if (string_init == java_lang_String_init_BI) { |
| 406 | return java_lang_StringFactory_newStringFromBytes_BI; |
| 407 | } else if (string_init == java_lang_String_init_BII) { |
| 408 | return java_lang_StringFactory_newStringFromBytes_BII; |
| 409 | } else if (string_init == java_lang_String_init_BIII) { |
| 410 | return java_lang_StringFactory_newStringFromBytes_BIII; |
| 411 | } else if (string_init == java_lang_String_init_BIIString) { |
| 412 | return java_lang_StringFactory_newStringFromBytes_BIIString; |
| 413 | } else if (string_init == java_lang_String_init_BString) { |
| 414 | return java_lang_StringFactory_newStringFromBytes_BString; |
| 415 | } else if (string_init == java_lang_String_init_BIICharset) { |
| 416 | return java_lang_StringFactory_newStringFromBytes_BIICharset; |
| 417 | } else if (string_init == java_lang_String_init_BCharset) { |
| 418 | return java_lang_StringFactory_newStringFromBytes_BCharset; |
| 419 | } else if (string_init == java_lang_String_init_C) { |
| 420 | return java_lang_StringFactory_newStringFromChars_C; |
| 421 | } else if (string_init == java_lang_String_init_CII) { |
| 422 | return java_lang_StringFactory_newStringFromChars_CII; |
| 423 | } else if (string_init == java_lang_String_init_IIC) { |
| 424 | return java_lang_StringFactory_newStringFromChars_IIC; |
| 425 | } else if (string_init == java_lang_String_init_String) { |
| 426 | return java_lang_StringFactory_newStringFromString; |
| 427 | } else if (string_init == java_lang_String_init_StringBuffer) { |
| 428 | return java_lang_StringFactory_newStringFromStringBuffer; |
| 429 | } else if (string_init == java_lang_String_init_III) { |
| 430 | return java_lang_StringFactory_newStringFromCodePoints; |
| 431 | } else if (string_init == java_lang_String_init_StringBuilder) { |
| 432 | return java_lang_StringFactory_newStringFromStringBuilder; |
| 433 | } |
| 434 | LOG(FATAL) << "Could not find StringFactory method for String.<init>"; |
| 435 | return nullptr; |
| 436 | } |
| 437 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 438 | } // namespace art |