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
21 #include <sstream>
22
23 #include <android-base/logging.h>
24 #include <android-base/stringprintf.h>
25
26 #include "base/enums.h"
27 #include "class_linker.h"
28 #include "entrypoints/quick/quick_entrypoints_enum.h"
29 #include "entrypoints/runtime_asm_entrypoints.h"
30 #include "hidden_api.h"
31 #include "jni/jni_internal.h"
32 #include "jni_id_type.h"
33 #include "mirror/class.h"
34 #include "mirror/throwable.h"
35 #include "nativehelper/scoped_local_ref.h"
36 #include "obj_ptr-inl.h"
37 #include "runtime.h"
38 #include "scoped_thread_state_change-inl.h"
39 #include "scoped_thread_state_change.h"
40 #include "thread-current-inl.h"
41
42 namespace art {
43
44 jclass WellKnownClasses::dalvik_annotation_optimization_CriticalNative;
45 jclass WellKnownClasses::dalvik_annotation_optimization_FastNative;
46 jclass WellKnownClasses::dalvik_annotation_optimization_NeverCompile;
47 jclass WellKnownClasses::dalvik_system_BaseDexClassLoader;
48 jclass WellKnownClasses::dalvik_system_DelegateLastClassLoader;
49 jclass WellKnownClasses::dalvik_system_DexClassLoader;
50 jclass WellKnownClasses::dalvik_system_DexFile;
51 jclass WellKnownClasses::dalvik_system_DexPathList;
52 jclass WellKnownClasses::dalvik_system_DexPathList__Element;
53 jclass WellKnownClasses::dalvik_system_EmulatedStackFrame;
54 jclass WellKnownClasses::dalvik_system_InMemoryDexClassLoader;
55 jclass WellKnownClasses::dalvik_system_PathClassLoader;
56 jclass WellKnownClasses::dalvik_system_VMRuntime;
57 jclass WellKnownClasses::java_lang_annotation_Annotation__array;
58 jclass WellKnownClasses::java_lang_BootClassLoader;
59 jclass WellKnownClasses::java_lang_ClassLoader;
60 jclass WellKnownClasses::java_lang_ClassNotFoundException;
61 jclass WellKnownClasses::java_lang_Daemons;
62 jclass WellKnownClasses::java_lang_Error;
63 jclass WellKnownClasses::java_lang_IllegalAccessError;
64 jclass WellKnownClasses::java_lang_NoClassDefFoundError;
65 jclass WellKnownClasses::java_lang_Object;
66 jclass WellKnownClasses::java_lang_OutOfMemoryError;
67 jclass WellKnownClasses::java_lang_reflect_InvocationTargetException;
68 jclass WellKnownClasses::java_lang_reflect_Parameter;
69 jclass WellKnownClasses::java_lang_reflect_Parameter__array;
70 jclass WellKnownClasses::java_lang_reflect_Proxy;
71 jclass WellKnownClasses::java_lang_RuntimeException;
72 jclass WellKnownClasses::java_lang_StackOverflowError;
73 jclass WellKnownClasses::java_lang_String;
74 jclass WellKnownClasses::java_lang_StringFactory;
75 jclass WellKnownClasses::java_lang_System;
76 jclass WellKnownClasses::java_lang_Thread;
77 jclass WellKnownClasses::java_lang_ThreadGroup;
78 jclass WellKnownClasses::java_lang_Throwable;
79 jclass WellKnownClasses::java_lang_Void;
80 jclass WellKnownClasses::java_nio_Buffer;
81 jclass WellKnownClasses::java_nio_ByteBuffer;
82 jclass WellKnownClasses::java_nio_DirectByteBuffer;
83 jclass WellKnownClasses::java_util_Collections;
84 jclass WellKnownClasses::java_util_function_Consumer;
85 jclass WellKnownClasses::libcore_reflect_AnnotationFactory;
86 jclass WellKnownClasses::libcore_reflect_AnnotationMember;
87 jclass WellKnownClasses::libcore_util_EmptyArray;
88 jclass WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk;
89 jclass WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer;
90
91 jmethodID WellKnownClasses::dalvik_system_BaseDexClassLoader_getLdLibraryPath;
92 jmethodID WellKnownClasses::dalvik_system_VMRuntime_runFinalization;
93 jmethodID WellKnownClasses::dalvik_system_VMRuntime_hiddenApiUsed;
94 jmethodID WellKnownClasses::java_lang_Boolean_valueOf;
95 jmethodID WellKnownClasses::java_lang_Byte_valueOf;
96 jmethodID WellKnownClasses::java_lang_Character_valueOf;
97 jmethodID WellKnownClasses::java_lang_ClassLoader_loadClass;
98 jmethodID WellKnownClasses::java_lang_ClassNotFoundException_init;
99 jmethodID WellKnownClasses::java_lang_Daemons_start;
100 jmethodID WellKnownClasses::java_lang_Daemons_stop;
101 jmethodID WellKnownClasses::java_lang_Daemons_waitForDaemonStart;
102 jmethodID WellKnownClasses::java_lang_Double_doubleToRawLongBits;
103 jmethodID WellKnownClasses::java_lang_Double_valueOf;
104 jmethodID WellKnownClasses::java_lang_Float_floatToRawIntBits;
105 jmethodID WellKnownClasses::java_lang_Float_valueOf;
106 jmethodID WellKnownClasses::java_lang_Integer_valueOf;
107 jmethodID WellKnownClasses::java_lang_invoke_MethodHandle_asType;
108 jmethodID WellKnownClasses::java_lang_invoke_MethodHandle_invokeExact;
109 jmethodID WellKnownClasses::java_lang_invoke_MethodHandles_lookup;
110 jmethodID WellKnownClasses::java_lang_invoke_MethodHandles_Lookup_findConstructor;
111 jmethodID WellKnownClasses::java_lang_Long_valueOf;
112 jmethodID WellKnownClasses::java_lang_ref_FinalizerReference_add;
113 jmethodID WellKnownClasses::java_lang_ref_ReferenceQueue_add;
114 jmethodID WellKnownClasses::java_lang_reflect_InvocationTargetException_init;
115 jmethodID WellKnownClasses::java_lang_reflect_Parameter_init;
116 jmethodID WellKnownClasses::java_lang_reflect_Proxy_init;
117 jmethodID WellKnownClasses::java_lang_reflect_Proxy_invoke;
118 jmethodID WellKnownClasses::java_lang_Runtime_nativeLoad;
119 jmethodID WellKnownClasses::java_lang_Short_valueOf;
120 jmethodID WellKnownClasses::java_lang_String_charAt;
121 jmethodID WellKnownClasses::java_lang_Thread_dispatchUncaughtException;
122 jmethodID WellKnownClasses::java_lang_Thread_init;
123 jmethodID WellKnownClasses::java_lang_Thread_run;
124 jmethodID WellKnownClasses::java_lang_ThreadGroup_add;
125 jmethodID WellKnownClasses::java_lang_ThreadGroup_removeThread;
126 jmethodID WellKnownClasses::java_nio_Buffer_isDirect;
127 jmethodID WellKnownClasses::java_nio_DirectByteBuffer_init;
128 jmethodID WellKnownClasses::java_util_function_Consumer_accept;
129 jmethodID WellKnownClasses::libcore_reflect_AnnotationFactory_createAnnotation;
130 jmethodID WellKnownClasses::libcore_reflect_AnnotationMember_init;
131 jmethodID WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer_broadcast;
132 jmethodID WellKnownClasses::org_apache_harmony_dalvik_ddmc_DdmServer_dispatch;
133
134 jfieldID WellKnownClasses::dalvik_system_DexFile_cookie;
135 jfieldID WellKnownClasses::dalvik_system_DexFile_fileName;
136 jfieldID WellKnownClasses::dalvik_system_BaseDexClassLoader_pathList;
137 jfieldID WellKnownClasses::dalvik_system_BaseDexClassLoader_sharedLibraryLoaders;
138 jfieldID WellKnownClasses::dalvik_system_BaseDexClassLoader_sharedLibraryLoadersAfter;
139 jfieldID WellKnownClasses::dalvik_system_DexPathList_dexElements;
140 jfieldID WellKnownClasses::dalvik_system_DexPathList__Element_dexFile;
141 jfieldID WellKnownClasses::dalvik_system_VMRuntime_nonSdkApiUsageConsumer;
142 jfieldID WellKnownClasses::java_io_FileDescriptor_descriptor;
143 jfieldID WellKnownClasses::java_lang_ClassLoader_parent;
144 jfieldID WellKnownClasses::java_lang_Thread_parkBlocker;
145 jfieldID WellKnownClasses::java_lang_Thread_daemon;
146 jfieldID WellKnownClasses::java_lang_Thread_group;
147 jfieldID WellKnownClasses::java_lang_Thread_lock;
148 jfieldID WellKnownClasses::java_lang_Thread_name;
149 jfieldID WellKnownClasses::java_lang_Thread_priority;
150 jfieldID WellKnownClasses::java_lang_Thread_nativePeer;
151 jfieldID WellKnownClasses::java_lang_Thread_systemDaemon;
152 jfieldID WellKnownClasses::java_lang_Thread_unparkedBeforeStart;
153 jfieldID WellKnownClasses::java_lang_ThreadGroup_groups;
154 jfieldID WellKnownClasses::java_lang_ThreadGroup_ngroups;
155 jfieldID WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup;
156 jfieldID WellKnownClasses::java_lang_ThreadGroup_name;
157 jfieldID WellKnownClasses::java_lang_ThreadGroup_parent;
158 jfieldID WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup;
159 jfieldID WellKnownClasses::java_lang_Throwable_cause;
160 jfieldID WellKnownClasses::java_lang_Throwable_detailMessage;
161 jfieldID WellKnownClasses::java_lang_Throwable_stackTrace;
162 jfieldID WellKnownClasses::java_lang_Throwable_stackState;
163 jfieldID WellKnownClasses::java_lang_Throwable_suppressedExceptions;
164 jfieldID WellKnownClasses::java_nio_Buffer_address;
165 jfieldID WellKnownClasses::java_nio_Buffer_capacity;
166 jfieldID WellKnownClasses::java_nio_Buffer_elementSizeShift;
167 jfieldID WellKnownClasses::java_nio_Buffer_limit;
168 jfieldID WellKnownClasses::java_nio_Buffer_position;
169 jfieldID WellKnownClasses::java_nio_ByteBuffer_address;
170 jfieldID WellKnownClasses::java_nio_ByteBuffer_hb;
171 jfieldID WellKnownClasses::java_nio_ByteBuffer_isReadOnly;
172 jfieldID WellKnownClasses::java_nio_ByteBuffer_limit;
173 jfieldID WellKnownClasses::java_nio_ByteBuffer_offset;
174 jfieldID WellKnownClasses::java_util_Collections_EMPTY_LIST;
175 jfieldID WellKnownClasses::libcore_util_EmptyArray_STACK_TRACE_ELEMENT;
176 jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_data;
177 jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_length;
178 jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_offset;
179 jfieldID WellKnownClasses::org_apache_harmony_dalvik_ddmc_Chunk_type;
180
CacheClass(JNIEnv * env,const char * jni_class_name)181 static jclass CacheClass(JNIEnv* env, const char* jni_class_name) {
182 ScopedLocalRef<jclass> c(env, env->FindClass(jni_class_name));
183 if (c.get() == nullptr) {
184 LOG(FATAL) << "Couldn't find class: " << jni_class_name;
185 }
186 return reinterpret_cast<jclass>(env->NewGlobalRef(c.get()));
187 }
188
CacheField(JNIEnv * env,jclass c,bool is_static,const char * name,const char * signature)189 static jfieldID CacheField(JNIEnv* env, jclass c, bool is_static,
190 const char* name, const char* signature) {
191 jfieldID fid;
192 {
193 ScopedObjectAccess soa(env);
194 if (Runtime::Current()->GetJniIdType() != JniIdType::kSwapablePointer) {
195 fid = jni::EncodeArtField</*kEnableIndexIds*/ true>(
196 FindFieldJNI(soa, c, name, signature, is_static));
197 } else {
198 fid = jni::EncodeArtField</*kEnableIndexIds*/ false>(
199 FindFieldJNI(soa, c, name, signature, is_static));
200 }
201 }
202 if (fid == nullptr) {
203 ScopedObjectAccess soa(env);
204 if (soa.Self()->IsExceptionPending()) {
205 LOG(FATAL_WITHOUT_ABORT) << soa.Self()->GetException()->Dump();
206 }
207 std::ostringstream os;
208 WellKnownClasses::ToClass(c)->DumpClass(os, mirror::Class::kDumpClassFullDetail);
209 LOG(FATAL) << "Couldn't find field \"" << name << "\" with signature \"" << signature << "\": "
210 << os.str();
211 }
212 return fid;
213 }
214
CacheMethod(JNIEnv * env,jclass c,bool is_static,const char * name,const char * signature)215 static jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static,
216 const char* name, const char* signature) {
217 jmethodID mid;
218 {
219 ScopedObjectAccess soa(env);
220 if (Runtime::Current()->GetJniIdType() != JniIdType::kSwapablePointer) {
221 mid = jni::EncodeArtMethod</*kEnableIndexIds*/ true>(
222 FindMethodJNI(soa, c, name, signature, is_static));
223 } else {
224 mid = jni::EncodeArtMethod</*kEnableIndexIds*/ false>(
225 FindMethodJNI(soa, c, name, signature, is_static));
226 }
227 }
228 if (mid == nullptr) {
229 ScopedObjectAccess soa(env);
230 if (soa.Self()->IsExceptionPending()) {
231 LOG(FATAL_WITHOUT_ABORT) << soa.Self()->GetException()->Dump();
232 }
233 std::ostringstream os;
234 WellKnownClasses::ToClass(c)->DumpClass(os, mirror::Class::kDumpClassFullDetail);
235 LOG(FATAL) << "Couldn't find method \"" << name << "\" with signature \"" << signature << "\": "
236 << os.str();
237 }
238 return mid;
239 }
240
CacheMethod(JNIEnv * env,const char * klass,bool is_static,const char * name,const char * signature)241 static jmethodID CacheMethod(JNIEnv* env, const char* klass, bool is_static,
242 const char* name, const char* signature) {
243 ScopedLocalRef<jclass> java_class(env, env->FindClass(klass));
244 return CacheMethod(env, java_class.get(), is_static, name, signature);
245 }
246
CachePrimitiveBoxingMethod(JNIEnv * env,char prim_name,const char * boxed_name)247 static jmethodID CachePrimitiveBoxingMethod(JNIEnv* env, char prim_name, const char* boxed_name) {
248 ScopedLocalRef<jclass> boxed_class(env, env->FindClass(boxed_name));
249 return CacheMethod(env, boxed_class.get(), true, "valueOf",
250 android::base::StringPrintf("(%c)L%s;", prim_name, boxed_name).c_str());
251 }
252
253 #define STRING_INIT_LIST(V) \
254 V(java_lang_String_init, "()V", newEmptyString, "newEmptyString", "()Ljava/lang/String;", NewEmptyString) \
255 V(java_lang_String_init_B, "([B)V", newStringFromBytes_B, "newStringFromBytes", "([B)Ljava/lang/String;", NewStringFromBytes_B) \
256 V(java_lang_String_init_BI, "([BI)V", newStringFromBytes_BI, "newStringFromBytes", "([BI)Ljava/lang/String;", NewStringFromBytes_BI) \
257 V(java_lang_String_init_BII, "([BII)V", newStringFromBytes_BII, "newStringFromBytes", "([BII)Ljava/lang/String;", NewStringFromBytes_BII) \
258 V(java_lang_String_init_BIII, "([BIII)V", newStringFromBytes_BIII, "newStringFromBytes", "([BIII)Ljava/lang/String;", NewStringFromBytes_BIII) \
259 V(java_lang_String_init_BIIString, "([BIILjava/lang/String;)V", newStringFromBytes_BIIString, "newStringFromBytes", "([BIILjava/lang/String;)Ljava/lang/String;", NewStringFromBytes_BIIString) \
260 V(java_lang_String_init_BString, "([BLjava/lang/String;)V", newStringFromBytes_BString, "newStringFromBytes", "([BLjava/lang/String;)Ljava/lang/String;", NewStringFromBytes_BString) \
261 V(java_lang_String_init_BIICharset, "([BIILjava/nio/charset/Charset;)V", newStringFromBytes_BIICharset, "newStringFromBytes", "([BIILjava/nio/charset/Charset;)Ljava/lang/String;", NewStringFromBytes_BIICharset) \
262 V(java_lang_String_init_BCharset, "([BLjava/nio/charset/Charset;)V", newStringFromBytes_BCharset, "newStringFromBytes", "([BLjava/nio/charset/Charset;)Ljava/lang/String;", NewStringFromBytes_BCharset) \
263 V(java_lang_String_init_C, "([C)V", newStringFromChars_C, "newStringFromChars", "([C)Ljava/lang/String;", NewStringFromChars_C) \
264 V(java_lang_String_init_CII, "([CII)V", newStringFromChars_CII, "newStringFromChars", "([CII)Ljava/lang/String;", NewStringFromChars_CII) \
265 V(java_lang_String_init_IIC, "(II[C)V", newStringFromChars_IIC, "newStringFromChars", "(II[C)Ljava/lang/String;", NewStringFromChars_IIC) \
266 V(java_lang_String_init_String, "(Ljava/lang/String;)V", newStringFromString, "newStringFromString", "(Ljava/lang/String;)Ljava/lang/String;", NewStringFromString) \
267 V(java_lang_String_init_StringBuffer, "(Ljava/lang/StringBuffer;)V", newStringFromStringBuffer, "newStringFromStringBuffer", "(Ljava/lang/StringBuffer;)Ljava/lang/String;", NewStringFromStringBuffer) \
268 V(java_lang_String_init_III, "([III)V", newStringFromCodePoints, "newStringFromCodePoints", "([III)Ljava/lang/String;", NewStringFromCodePoints) \
269 V(java_lang_String_init_StringBuilder, "(Ljava/lang/StringBuilder;)V", newStringFromStringBuilder, "newStringFromStringBuilder", "(Ljava/lang/StringBuilder;)Ljava/lang/String;", NewStringFromStringBuilder) \
270
271 #define STATIC_STRING_INIT(init_runtime_name, init_signature, new_runtime_name, ...) \
272 static ArtMethod* init_runtime_name = nullptr; \
273 static ArtMethod* new_runtime_name = nullptr;
STRING_INIT_LIST(STATIC_STRING_INIT)274 STRING_INIT_LIST(STATIC_STRING_INIT)
275 #undef STATIC_STRING_INIT
276
277 void WellKnownClasses::InitStringInit(ObjPtr<mirror::Class> string_class,
278 ObjPtr<mirror::Class> string_builder_class) {
279 PointerSize p_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
280 auto find_method = [p_size](ObjPtr<mirror::Class> klass,
281 const char* name,
282 const char* sig,
283 bool expext_static) REQUIRES_SHARED(Locks::mutator_lock_) {
284 ArtMethod* ret = klass->FindClassMethod(name, sig, p_size);
285 CHECK(ret != nullptr);
286 CHECK_EQ(expext_static, ret->IsStatic());
287 return ret;
288 };
289
290 #define LOAD_STRING_INIT(init_runtime_name, init_signature, new_runtime_name, \
291 new_java_name, new_signature, ...) \
292 init_runtime_name = find_method(string_class, "<init>", init_signature, false); \
293 new_runtime_name = find_method(string_builder_class, new_java_name, new_signature, true);
294 STRING_INIT_LIST(LOAD_STRING_INIT)
295 #undef LOAD_STRING_INIT
296 }
297
InitStringEntryPoints()298 void Thread::InitStringEntryPoints() {
299 QuickEntryPoints* qpoints = &tlsPtr_.quick_entrypoints;
300 #define SET_ENTRY_POINT(init_runtime_name, \
301 init_signature, \
302 new_runtime_name, \
303 new_java_name, \
304 new_signature, \
305 entry_point_name) \
306 DCHECK_IMPLIES(Runtime::Current()->IsStarted(), (new_runtime_name) != nullptr); \
307 qpoints->p##entry_point_name = reinterpret_cast<void*>(new_runtime_name);
308 STRING_INIT_LIST(SET_ENTRY_POINT)
309 #undef SET_ENTRY_POINT
310 }
311
StringInitToStringFactory(ArtMethod * string_init)312 ArtMethod* WellKnownClasses::StringInitToStringFactory(ArtMethod* string_init) {
313 #define TO_STRING_FACTORY(init_runtime_name, init_signature, new_runtime_name, \
314 new_java_name, new_signature, entry_point_name) \
315 DCHECK((init_runtime_name) != nullptr); \
316 if (string_init == (init_runtime_name)) { \
317 DCHECK((new_runtime_name) != nullptr); \
318 return (new_runtime_name); \
319 }
320 STRING_INIT_LIST(TO_STRING_FACTORY)
321 #undef TO_STRING_FACTORY
322 LOG(FATAL) << "Could not find StringFactory method for String.<init>";
323 UNREACHABLE();
324 }
325
StringInitToEntryPoint(ArtMethod * string_init)326 uint32_t WellKnownClasses::StringInitToEntryPoint(ArtMethod* string_init) {
327 #define TO_ENTRY_POINT(init_runtime_name, init_signature, new_runtime_name, \
328 new_java_name, new_signature, entry_point_name) \
329 if (string_init == (init_runtime_name)) { \
330 return kQuick ## entry_point_name; \
331 }
332 STRING_INIT_LIST(TO_ENTRY_POINT)
333 #undef TO_ENTRY_POINT
334 LOG(FATAL) << "Could not find StringFactory method for String.<init>";
335 UNREACHABLE();
336 }
337 #undef STRING_INIT_LIST
338
Init(JNIEnv * env)339 void WellKnownClasses::Init(JNIEnv* env) {
340 hiddenapi::ScopedHiddenApiEnforcementPolicySetting hiddenapi_exemption(
341 hiddenapi::EnforcementPolicy::kDisabled);
342
343 dalvik_annotation_optimization_CriticalNative =
344 CacheClass(env, "dalvik/annotation/optimization/CriticalNative");
345 dalvik_annotation_optimization_FastNative = CacheClass(env, "dalvik/annotation/optimization/FastNative");
346 dalvik_annotation_optimization_NeverCompile =
347 CacheClass(env, "dalvik/annotation/optimization/NeverCompile");
348 dalvik_system_BaseDexClassLoader = CacheClass(env, "dalvik/system/BaseDexClassLoader");
349 dalvik_system_DelegateLastClassLoader = CacheClass(env, "dalvik/system/DelegateLastClassLoader");
350 dalvik_system_DexClassLoader = CacheClass(env, "dalvik/system/DexClassLoader");
351 dalvik_system_DexFile = CacheClass(env, "dalvik/system/DexFile");
352 dalvik_system_DexPathList = CacheClass(env, "dalvik/system/DexPathList");
353 dalvik_system_DexPathList__Element = CacheClass(env, "dalvik/system/DexPathList$Element");
354 dalvik_system_EmulatedStackFrame = CacheClass(env, "dalvik/system/EmulatedStackFrame");
355 dalvik_system_InMemoryDexClassLoader = CacheClass(env, "dalvik/system/InMemoryDexClassLoader");
356 dalvik_system_PathClassLoader = CacheClass(env, "dalvik/system/PathClassLoader");
357 dalvik_system_VMRuntime = CacheClass(env, "dalvik/system/VMRuntime");
358
359 java_lang_annotation_Annotation__array = CacheClass(env, "[Ljava/lang/annotation/Annotation;");
360 java_lang_BootClassLoader = CacheClass(env, "java/lang/BootClassLoader");
361 java_lang_ClassLoader = CacheClass(env, "java/lang/ClassLoader");
362 java_lang_ClassNotFoundException = CacheClass(env, "java/lang/ClassNotFoundException");
363 java_lang_Daemons = CacheClass(env, "java/lang/Daemons");
364 java_lang_Object = CacheClass(env, "java/lang/Object");
365 java_lang_OutOfMemoryError = CacheClass(env, "java/lang/OutOfMemoryError");
366 java_lang_Error = CacheClass(env, "java/lang/Error");
367 java_lang_IllegalAccessError = CacheClass(env, "java/lang/IllegalAccessError");
368 java_lang_NoClassDefFoundError = CacheClass(env, "java/lang/NoClassDefFoundError");
369 java_lang_reflect_InvocationTargetException = CacheClass(env, "java/lang/reflect/InvocationTargetException");
370 java_lang_reflect_Parameter = CacheClass(env, "java/lang/reflect/Parameter");
371 java_lang_reflect_Parameter__array = CacheClass(env, "[Ljava/lang/reflect/Parameter;");
372 java_lang_reflect_Proxy = CacheClass(env, "java/lang/reflect/Proxy");
373 java_lang_RuntimeException = CacheClass(env, "java/lang/RuntimeException");
374 java_lang_StackOverflowError = CacheClass(env, "java/lang/StackOverflowError");
375 java_lang_String = CacheClass(env, "java/lang/String");
376 java_lang_StringFactory = CacheClass(env, "java/lang/StringFactory");
377 java_lang_System = CacheClass(env, "java/lang/System");
378 java_lang_Thread = CacheClass(env, "java/lang/Thread");
379 java_lang_ThreadGroup = CacheClass(env, "java/lang/ThreadGroup");
380 java_lang_Throwable = CacheClass(env, "java/lang/Throwable");
381 java_lang_Void = CacheClass(env, "java/lang/Void");
382 java_nio_Buffer = CacheClass(env, "java/nio/Buffer");
383 java_nio_ByteBuffer = CacheClass(env, "java/nio/ByteBuffer");
384 java_nio_DirectByteBuffer = CacheClass(env, "java/nio/DirectByteBuffer");
385 java_util_Collections = CacheClass(env, "java/util/Collections");
386 java_util_function_Consumer = CacheClass(env, "java/util/function/Consumer");
387 libcore_reflect_AnnotationFactory = CacheClass(env, "libcore/reflect/AnnotationFactory");
388 libcore_reflect_AnnotationMember = CacheClass(env, "libcore/reflect/AnnotationMember");
389 libcore_util_EmptyArray = CacheClass(env, "libcore/util/EmptyArray");
390 org_apache_harmony_dalvik_ddmc_Chunk = CacheClass(env, "org/apache/harmony/dalvik/ddmc/Chunk");
391 org_apache_harmony_dalvik_ddmc_DdmServer = CacheClass(env, "org/apache/harmony/dalvik/ddmc/DdmServer");
392
393 InitFieldsAndMethodsOnly(env);
394 }
395
InitFieldsAndMethodsOnly(JNIEnv * env)396 void WellKnownClasses::InitFieldsAndMethodsOnly(JNIEnv* env) {
397 hiddenapi::ScopedHiddenApiEnforcementPolicySetting hiddenapi_exemption(
398 hiddenapi::EnforcementPolicy::kDisabled);
399
400 dalvik_system_BaseDexClassLoader_getLdLibraryPath = CacheMethod(env, dalvik_system_BaseDexClassLoader, false, "getLdLibraryPath", "()Ljava/lang/String;");
401 dalvik_system_VMRuntime_runFinalization = CacheMethod(env, dalvik_system_VMRuntime, true, "runFinalization", "(J)V");
402 dalvik_system_VMRuntime_hiddenApiUsed = CacheMethod(env, dalvik_system_VMRuntime, true, "hiddenApiUsed", "(ILjava/lang/String;Ljava/lang/String;IZ)V");
403
404 java_lang_ClassNotFoundException_init = CacheMethod(env, java_lang_ClassNotFoundException, false, "<init>", "(Ljava/lang/String;Ljava/lang/Throwable;)V");
405 java_lang_ClassLoader_loadClass = CacheMethod(env, java_lang_ClassLoader, false, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
406
407 java_lang_Daemons_start = CacheMethod(env, java_lang_Daemons, true, "start", "()V");
408 java_lang_Daemons_stop = CacheMethod(env, java_lang_Daemons, true, "stop", "()V");
409 java_lang_Daemons_waitForDaemonStart = CacheMethod(env, java_lang_Daemons, true, "waitForDaemonStart", "()V");
410 java_lang_invoke_MethodHandle_asType = CacheMethod(env, "java/lang/invoke/MethodHandle", false, "asType", "(Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MethodHandle;");
411 java_lang_invoke_MethodHandle_invokeExact = CacheMethod(env, "java/lang/invoke/MethodHandle", false, "invokeExact", "([Ljava/lang/Object;)Ljava/lang/Object;");
412 java_lang_invoke_MethodHandles_lookup = CacheMethod(env, "java/lang/invoke/MethodHandles", true, "lookup", "()Ljava/lang/invoke/MethodHandles$Lookup;");
413 java_lang_invoke_MethodHandles_Lookup_findConstructor = CacheMethod(env, "java/lang/invoke/MethodHandles$Lookup", false, "findConstructor", "(Ljava/lang/Class;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MethodHandle;");
414
415 java_lang_ref_FinalizerReference_add = CacheMethod(env, "java/lang/ref/FinalizerReference", true, "add", "(Ljava/lang/Object;)V");
416 java_lang_ref_ReferenceQueue_add = CacheMethod(env, "java/lang/ref/ReferenceQueue", true, "add", "(Ljava/lang/ref/Reference;)V");
417
418 java_lang_reflect_InvocationTargetException_init = CacheMethod(env, java_lang_reflect_InvocationTargetException, false, "<init>", "(Ljava/lang/Throwable;)V");
419 java_lang_reflect_Parameter_init = CacheMethod(env, java_lang_reflect_Parameter, false, "<init>", "(Ljava/lang/String;ILjava/lang/reflect/Executable;I)V");
420 java_lang_String_charAt = CacheMethod(env, java_lang_String, false, "charAt", "(I)C");
421 java_lang_Thread_dispatchUncaughtException = CacheMethod(env, java_lang_Thread, false, "dispatchUncaughtException", "(Ljava/lang/Throwable;)V");
422 java_lang_Thread_init = CacheMethod(env, java_lang_Thread, false, "<init>", "(Ljava/lang/ThreadGroup;Ljava/lang/String;IZ)V");
423 java_lang_Thread_run = CacheMethod(env, java_lang_Thread, false, "run", "()V");
424 java_lang_ThreadGroup_add = CacheMethod(env, java_lang_ThreadGroup, false, "add", "(Ljava/lang/Thread;)V");
425 java_lang_ThreadGroup_removeThread = CacheMethod(env, java_lang_ThreadGroup, false, "threadTerminated", "(Ljava/lang/Thread;)V");
426 java_nio_Buffer_isDirect = CacheMethod(env, java_nio_Buffer, false, "isDirect", "()Z");
427 java_nio_DirectByteBuffer_init = CacheMethod(env, java_nio_DirectByteBuffer, false, "<init>", "(JI)V");
428 java_util_function_Consumer_accept = CacheMethod(env, java_util_function_Consumer, false, "accept", "(Ljava/lang/Object;)V");
429 libcore_reflect_AnnotationFactory_createAnnotation = CacheMethod(env, libcore_reflect_AnnotationFactory, true, "createAnnotation", "(Ljava/lang/Class;[Llibcore/reflect/AnnotationMember;)Ljava/lang/annotation/Annotation;");
430 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");
431 org_apache_harmony_dalvik_ddmc_DdmServer_broadcast = CacheMethod(env, org_apache_harmony_dalvik_ddmc_DdmServer, true, "broadcast", "(I)V");
432 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;");
433
434 dalvik_system_BaseDexClassLoader_pathList = CacheField(env, dalvik_system_BaseDexClassLoader, false, "pathList", "Ldalvik/system/DexPathList;");
435 dalvik_system_BaseDexClassLoader_sharedLibraryLoaders = CacheField(env, dalvik_system_BaseDexClassLoader, false, "sharedLibraryLoaders", "[Ljava/lang/ClassLoader;");
436 dalvik_system_BaseDexClassLoader_sharedLibraryLoadersAfter = CacheField(env, dalvik_system_BaseDexClassLoader, false, "sharedLibraryLoadersAfter", "[Ljava/lang/ClassLoader;");
437 dalvik_system_DexFile_cookie = CacheField(env, dalvik_system_DexFile, false, "mCookie", "Ljava/lang/Object;");
438 dalvik_system_DexFile_fileName = CacheField(env, dalvik_system_DexFile, false, "mFileName", "Ljava/lang/String;");
439 dalvik_system_DexPathList_dexElements = CacheField(env, dalvik_system_DexPathList, false, "dexElements", "[Ldalvik/system/DexPathList$Element;");
440 dalvik_system_DexPathList__Element_dexFile = CacheField(env, dalvik_system_DexPathList__Element, false, "dexFile", "Ldalvik/system/DexFile;");
441 dalvik_system_VMRuntime_nonSdkApiUsageConsumer = CacheField(env, dalvik_system_VMRuntime, true, "nonSdkApiUsageConsumer", "Ljava/util/function/Consumer;");
442
443 ScopedLocalRef<jclass> java_io_FileDescriptor(env, env->FindClass("java/io/FileDescriptor"));
444 java_io_FileDescriptor_descriptor = CacheField(env, java_io_FileDescriptor.get(), false, "descriptor", "I");
445
446 java_lang_ClassLoader_parent =
447 CacheField(env, java_lang_ClassLoader, false, "parent", "Ljava/lang/ClassLoader;");
448 java_lang_Thread_parkBlocker =
449 CacheField(env, java_lang_Thread, false, "parkBlocker", "Ljava/lang/Object;");
450 java_lang_Thread_daemon = CacheField(env, java_lang_Thread, false, "daemon", "Z");
451 java_lang_Thread_group =
452 CacheField(env, java_lang_Thread, false, "group", "Ljava/lang/ThreadGroup;");
453 java_lang_Thread_lock = CacheField(env, java_lang_Thread, false, "lock", "Ljava/lang/Object;");
454 java_lang_Thread_name = CacheField(env, java_lang_Thread, false, "name", "Ljava/lang/String;");
455 java_lang_Thread_priority = CacheField(env, java_lang_Thread, false, "priority", "I");
456 java_lang_Thread_nativePeer = CacheField(env, java_lang_Thread, false, "nativePeer", "J");
457 java_lang_Thread_systemDaemon = CacheField(env, java_lang_Thread, false, "systemDaemon", "Z");
458 java_lang_Thread_unparkedBeforeStart =
459 CacheField(env, java_lang_Thread, false, "unparkedBeforeStart", "Z");
460 java_lang_ThreadGroup_groups =
461 CacheField(env, java_lang_ThreadGroup, false, "groups", "[Ljava/lang/ThreadGroup;");
462 java_lang_ThreadGroup_ngroups = CacheField(env, java_lang_ThreadGroup, false, "ngroups", "I");
463 java_lang_ThreadGroup_mainThreadGroup =
464 CacheField(env, java_lang_ThreadGroup, true, "mainThreadGroup", "Ljava/lang/ThreadGroup;");
465 java_lang_ThreadGroup_name =
466 CacheField(env, java_lang_ThreadGroup, false, "name", "Ljava/lang/String;");
467 java_lang_ThreadGroup_parent =
468 CacheField(env, java_lang_ThreadGroup, false, "parent", "Ljava/lang/ThreadGroup;");
469 java_lang_ThreadGroup_systemThreadGroup =
470 CacheField(env, java_lang_ThreadGroup, true, "systemThreadGroup", "Ljava/lang/ThreadGroup;");
471 java_lang_Throwable_cause =
472 CacheField(env, java_lang_Throwable, false, "cause", "Ljava/lang/Throwable;");
473 java_lang_Throwable_detailMessage =
474 CacheField(env, java_lang_Throwable, false, "detailMessage", "Ljava/lang/String;");
475 java_lang_Throwable_stackTrace =
476 CacheField(env, java_lang_Throwable, false, "stackTrace", "[Ljava/lang/StackTraceElement;");
477 java_lang_Throwable_stackState =
478 CacheField(env, java_lang_Throwable, false, "backtrace", "Ljava/lang/Object;");
479 java_lang_Throwable_suppressedExceptions =
480 CacheField(env, java_lang_Throwable, false, "suppressedExceptions", "Ljava/util/List;");
481
482 java_nio_Buffer_address = CacheField(env, java_nio_Buffer, false, "address", "J");
483 java_nio_Buffer_capacity = CacheField(env, java_nio_Buffer, false, "capacity", "I");
484 java_nio_Buffer_elementSizeShift =
485 CacheField(env, java_nio_Buffer, false, "_elementSizeShift", "I");
486 java_nio_Buffer_limit = CacheField(env, java_nio_Buffer, false, "limit", "I");
487 java_nio_Buffer_position = CacheField(env, java_nio_Buffer, false, "position", "I");
488
489 java_nio_ByteBuffer_address = CacheField(env, java_nio_ByteBuffer, false, "address", "J");
490 java_nio_ByteBuffer_hb = CacheField(env, java_nio_ByteBuffer, false, "hb", "[B");
491 java_nio_ByteBuffer_isReadOnly = CacheField(env, java_nio_ByteBuffer, false, "isReadOnly", "Z");
492 java_nio_ByteBuffer_limit = CacheField(env, java_nio_ByteBuffer, false, "limit", "I");
493 java_nio_ByteBuffer_offset = CacheField(env, java_nio_ByteBuffer, false, "offset", "I");
494 java_util_Collections_EMPTY_LIST =
495 CacheField(env, java_util_Collections, true, "EMPTY_LIST", "Ljava/util/List;");
496 libcore_util_EmptyArray_STACK_TRACE_ELEMENT = CacheField(
497 env, libcore_util_EmptyArray, true, "STACK_TRACE_ELEMENT", "[Ljava/lang/StackTraceElement;");
498 org_apache_harmony_dalvik_ddmc_Chunk_data =
499 CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "data", "[B");
500 org_apache_harmony_dalvik_ddmc_Chunk_length =
501 CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "length", "I");
502 org_apache_harmony_dalvik_ddmc_Chunk_offset =
503 CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "offset", "I");
504 org_apache_harmony_dalvik_ddmc_Chunk_type =
505 CacheField(env, org_apache_harmony_dalvik_ddmc_Chunk, false, "type", "I");
506
507 java_lang_Boolean_valueOf = CachePrimitiveBoxingMethod(env, 'Z', "java/lang/Boolean");
508 java_lang_Byte_valueOf = CachePrimitiveBoxingMethod(env, 'B', "java/lang/Byte");
509 java_lang_Character_valueOf = CachePrimitiveBoxingMethod(env, 'C', "java/lang/Character");
510 java_lang_Double_valueOf = CachePrimitiveBoxingMethod(env, 'D', "java/lang/Double");
511 java_lang_Float_valueOf = CachePrimitiveBoxingMethod(env, 'F', "java/lang/Float");
512 java_lang_Integer_valueOf = CachePrimitiveBoxingMethod(env, 'I', "java/lang/Integer");
513 java_lang_Long_valueOf = CachePrimitiveBoxingMethod(env, 'J', "java/lang/Long");
514 java_lang_Short_valueOf = CachePrimitiveBoxingMethod(env, 'S', "java/lang/Short");
515
516 java_lang_Double_doubleToRawLongBits =
517 CacheMethod(env, "java/lang/Double", /*is_static=*/ true, "doubleToRawLongBits", "(D)J");
518 java_lang_Float_floatToRawIntBits =
519 CacheMethod(env, "java/lang/Float", /*is_static=*/ true, "floatToRawIntBits", "(F)I");
520 }
521
LateInit(JNIEnv * env)522 void WellKnownClasses::LateInit(JNIEnv* env) {
523 // CacheField and CacheMethod will initialize their classes. Classes below
524 // have clinit sections that call JNI methods. Late init is required
525 // to make sure these JNI methods are available.
526 ScopedLocalRef<jclass> java_lang_Runtime(env, env->FindClass("java/lang/Runtime"));
527 java_lang_Runtime_nativeLoad =
528 CacheMethod(env, java_lang_Runtime.get(), true, "nativeLoad",
529 "(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/Class;)"
530 "Ljava/lang/String;");
531 java_lang_reflect_Proxy_init =
532 CacheMethod(env, java_lang_reflect_Proxy, false, "<init>",
533 "(Ljava/lang/reflect/InvocationHandler;)V");
534 // This invariant is important since otherwise we will have the entire proxy invoke system
535 // confused.
536 DCHECK_NE(
537 jni::DecodeArtMethod(java_lang_reflect_Proxy_init)->GetEntryPointFromQuickCompiledCode(),
538 GetQuickInstrumentationEntryPoint());
539 java_lang_reflect_Proxy_invoke =
540 CacheMethod(env, java_lang_reflect_Proxy, true, "invoke",
541 "(Ljava/lang/reflect/Proxy;Ljava/lang/reflect/Method;"
542 "[Ljava/lang/Object;)Ljava/lang/Object;");
543 }
544
HandleJniIdTypeChange(JNIEnv * env)545 void WellKnownClasses::HandleJniIdTypeChange(JNIEnv* env) {
546 WellKnownClasses::InitFieldsAndMethodsOnly(env);
547 WellKnownClasses::LateInit(env);
548 }
549
Clear()550 void WellKnownClasses::Clear() {
551 dalvik_annotation_optimization_CriticalNative = nullptr;
552 dalvik_annotation_optimization_FastNative = nullptr;
553 dalvik_annotation_optimization_NeverCompile = nullptr;
554 dalvik_system_BaseDexClassLoader = nullptr;
555 dalvik_system_DelegateLastClassLoader = nullptr;
556 dalvik_system_DexClassLoader = nullptr;
557 dalvik_system_DexFile = nullptr;
558 dalvik_system_DexPathList = nullptr;
559 dalvik_system_DexPathList__Element = nullptr;
560 dalvik_system_EmulatedStackFrame = nullptr;
561 dalvik_system_PathClassLoader = nullptr;
562 dalvik_system_VMRuntime = nullptr;
563 java_lang_annotation_Annotation__array = nullptr;
564 java_lang_BootClassLoader = nullptr;
565 java_lang_ClassLoader = nullptr;
566 java_lang_ClassNotFoundException = nullptr;
567 java_lang_Daemons = nullptr;
568 java_lang_Error = nullptr;
569 java_lang_IllegalAccessError = nullptr;
570 java_lang_NoClassDefFoundError = nullptr;
571 java_lang_Object = nullptr;
572 java_lang_OutOfMemoryError = nullptr;
573 java_lang_reflect_InvocationTargetException = nullptr;
574 java_lang_reflect_Parameter = nullptr;
575 java_lang_reflect_Parameter__array = nullptr;
576 java_lang_reflect_Proxy = nullptr;
577 java_lang_RuntimeException = nullptr;
578 java_lang_StackOverflowError = nullptr;
579 java_lang_String = nullptr;
580 java_lang_StringFactory = nullptr;
581 java_lang_System = nullptr;
582 java_lang_Thread = nullptr;
583 java_lang_ThreadGroup = nullptr;
584 java_lang_Throwable = nullptr;
585 java_lang_Void = nullptr;
586 java_util_Collections = nullptr;
587 java_nio_Buffer = nullptr;
588 java_nio_ByteBuffer = nullptr;
589 java_nio_DirectByteBuffer = nullptr;
590 libcore_reflect_AnnotationFactory = nullptr;
591 libcore_reflect_AnnotationMember = nullptr;
592 libcore_util_EmptyArray = nullptr;
593 org_apache_harmony_dalvik_ddmc_Chunk = nullptr;
594 org_apache_harmony_dalvik_ddmc_DdmServer = nullptr;
595
596 dalvik_system_BaseDexClassLoader_getLdLibraryPath = nullptr;
597 dalvik_system_VMRuntime_runFinalization = nullptr;
598 dalvik_system_VMRuntime_hiddenApiUsed = nullptr;
599 java_io_FileDescriptor_descriptor = nullptr;
600 java_lang_Boolean_valueOf = nullptr;
601 java_lang_Byte_valueOf = nullptr;
602 java_lang_Character_valueOf = nullptr;
603 java_lang_ClassLoader_loadClass = nullptr;
604 java_lang_ClassNotFoundException_init = nullptr;
605 java_lang_Daemons_start = nullptr;
606 java_lang_Daemons_stop = nullptr;
607 java_lang_Double_doubleToRawLongBits = nullptr;
608 java_lang_Double_valueOf = nullptr;
609 java_lang_Float_floatToRawIntBits = nullptr;
610 java_lang_Float_valueOf = nullptr;
611 java_lang_Integer_valueOf = nullptr;
612 java_lang_invoke_MethodHandle_asType = nullptr;
613 java_lang_invoke_MethodHandle_invokeExact = nullptr;
614 java_lang_invoke_MethodHandles_lookup = nullptr;
615 java_lang_invoke_MethodHandles_Lookup_findConstructor = nullptr;
616 java_lang_Long_valueOf = nullptr;
617 java_lang_ref_FinalizerReference_add = nullptr;
618 java_lang_ref_ReferenceQueue_add = nullptr;
619 java_lang_reflect_InvocationTargetException_init = nullptr;
620 java_lang_reflect_Parameter_init = nullptr;
621 java_lang_reflect_Proxy_init = nullptr;
622 java_lang_reflect_Proxy_invoke = nullptr;
623 java_lang_Runtime_nativeLoad = nullptr;
624 java_lang_Short_valueOf = nullptr;
625 java_lang_String_charAt = nullptr;
626 java_lang_Thread_dispatchUncaughtException = nullptr;
627 java_lang_Thread_init = nullptr;
628 java_lang_Thread_run = nullptr;
629 java_lang_ThreadGroup_add = nullptr;
630 java_lang_ThreadGroup_removeThread = nullptr;
631 java_nio_Buffer_isDirect = nullptr;
632 java_nio_DirectByteBuffer_init = nullptr;
633 libcore_reflect_AnnotationFactory_createAnnotation = nullptr;
634 libcore_reflect_AnnotationMember_init = nullptr;
635 org_apache_harmony_dalvik_ddmc_DdmServer_broadcast = nullptr;
636 org_apache_harmony_dalvik_ddmc_DdmServer_dispatch = nullptr;
637
638 dalvik_system_BaseDexClassLoader_pathList = nullptr;
639 dalvik_system_DexFile_cookie = nullptr;
640 dalvik_system_DexFile_fileName = nullptr;
641 dalvik_system_DexPathList_dexElements = nullptr;
642 dalvik_system_DexPathList__Element_dexFile = nullptr;
643 dalvik_system_VMRuntime_nonSdkApiUsageConsumer = nullptr;
644 java_lang_ClassLoader_parent = nullptr;
645 java_lang_Thread_parkBlocker = nullptr;
646 java_lang_Thread_daemon = nullptr;
647 java_lang_Thread_group = nullptr;
648 java_lang_Thread_lock = nullptr;
649 java_lang_Thread_name = nullptr;
650 java_lang_Thread_priority = nullptr;
651 java_lang_Thread_nativePeer = nullptr;
652 java_lang_ThreadGroup_groups = nullptr;
653 java_lang_ThreadGroup_ngroups = nullptr;
654 java_lang_ThreadGroup_mainThreadGroup = nullptr;
655 java_lang_ThreadGroup_name = nullptr;
656 java_lang_ThreadGroup_parent = nullptr;
657 java_lang_ThreadGroup_systemThreadGroup = nullptr;
658 java_lang_Throwable_cause = nullptr;
659 java_lang_Throwable_detailMessage = nullptr;
660 java_lang_Throwable_stackTrace = nullptr;
661 java_lang_Throwable_stackState = nullptr;
662 java_lang_Throwable_suppressedExceptions = nullptr;
663 java_nio_Buffer_address = nullptr;
664 java_nio_Buffer_elementSizeShift = nullptr;
665 java_nio_Buffer_limit = nullptr;
666 java_nio_Buffer_position = nullptr;
667 java_nio_ByteBuffer_address = nullptr;
668 java_nio_ByteBuffer_hb = nullptr;
669 java_nio_ByteBuffer_isReadOnly = nullptr;
670 java_nio_ByteBuffer_limit = nullptr;
671 java_nio_ByteBuffer_offset = nullptr;
672 java_util_Collections_EMPTY_LIST = nullptr;
673 libcore_util_EmptyArray_STACK_TRACE_ELEMENT = nullptr;
674 org_apache_harmony_dalvik_ddmc_Chunk_data = nullptr;
675 org_apache_harmony_dalvik_ddmc_Chunk_length = nullptr;
676 org_apache_harmony_dalvik_ddmc_Chunk_offset = nullptr;
677 org_apache_harmony_dalvik_ddmc_Chunk_type = nullptr;
678 }
679
ToClass(jclass global_jclass)680 ObjPtr<mirror::Class> WellKnownClasses::ToClass(jclass global_jclass) {
681 auto ret = ObjPtr<mirror::Class>::DownCast(Thread::Current()->DecodeJObject(global_jclass));
682 DCHECK(!ret.IsNull());
683 return ret;
684 }
685
686 } // namespace art
687