2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ART_RUNTIME_MIRROR_CLASS_H_
18 #define ART_RUNTIME_MIRROR_CLASS_H_
20 #include "base/iteration_range.h"
22 #include "class_flags.h"
24 #include "gc/allocator_type.h"
26 #include "invoke_type.h"
27 #include "modifiers.h"
29 #include "object_array.h"
30 #include "object_callbacks.h"
31 #include "primitive.h"
32 #include "read_barrier_option.h"
33 #include "stride_iterator.h"
42 template<class T> class Handle;
43 template<typename T> class LengthPrefixedArray;
44 template<typename T> class ArraySlice;
47 template<size_t kNumReferences> class PACKED(4) StackHandleScope;
57 // C++ mirror of java.lang.Class
58 class MANAGED Class FINAL : public Object {
60 // A magic value for reference_instance_offsets_. Ignore the bits and walk the super chain when
62 // [This is an unlikely "natural" value, since it would be 30 non-ref instance fields followed by
63 // 2 ref instance fields.]
64 static constexpr uint32_t kClassWalkSuper = 0xC0000000;
68 // kStatusRetired: Class that's temporarily used till class linking time
69 // has its (vtable) size figured out and has been cloned to one with the
70 // right size which will be the one used later. The old one is retired and
71 // will be gc'ed once all refs to the class point to the newly
74 // kStatusNotReady: If a Class cannot be found in the class table by
75 // FindClass, it allocates an new one with AllocClass in the
76 // kStatusNotReady and calls LoadClass. Note if it does find a
77 // class, it may not be kStatusResolved and it will try to push it
78 // forward toward kStatusResolved.
80 // kStatusIdx: LoadClass populates with Class with information from
81 // the DexFile, moving the status to kStatusIdx, indicating that the
82 // Class value in super_class_ has not been populated. The new Class
83 // can then be inserted into the classes table.
85 // kStatusLoaded: After taking a lock on Class, the ClassLinker will
86 // attempt to move a kStatusIdx class forward to kStatusLoaded by
87 // using ResolveClass to initialize the super_class_ and ensuring the
88 // interfaces are resolved.
90 // kStatusResolving: Class is just cloned with the right size from
91 // temporary class that's acting as a placeholder for linking. The old
92 // class will be retired. New class is set to this status first before
93 // moving on to being resolved.
95 // kStatusResolved: Still holding the lock on Class, the ClassLinker
96 // shows linking is complete and fields of the Class populated by making
97 // it kStatusResolved. Java allows circularities of the form where a super
98 // class has a field that is of the type of the sub class. We need to be able
99 // to fully resolve super classes while resolving types for fields.
101 // kStatusRetryVerificationAtRuntime: The verifier sets a class to
102 // this state if it encounters a soft failure at compile time. This
103 // often happens when there are unresolved classes in other dex
104 // files, and this status marks a class as needing to be verified
107 // TODO: Explain the other states
109 kStatusRetired = -2, // Retired, should not be used. Use the newly cloned one instead.
112 kStatusIdx = 1, // Loaded, DEX idx in super_class_type_idx_ and interfaces_type_idx_.
113 kStatusLoaded = 2, // DEX idx values resolved.
114 kStatusResolving = 3, // Just cloned from temporary class object.
115 kStatusResolved = 4, // Part of linking.
116 kStatusVerifying = 5, // In the process of being verified.
117 kStatusRetryVerificationAtRuntime = 6, // Compile time verification failed, retry at runtime.
118 kStatusVerifyingAtRuntime = 7, // Retrying verification at runtime.
119 kStatusVerified = 8, // Logically part of linking; done pre-init.
120 kStatusInitializing = 9, // Class init in progress.
121 kStatusInitialized = 10, // Ready to go.
125 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
126 Status GetStatus() SHARED_REQUIRES(Locks::mutator_lock_) {
127 static_assert(sizeof(Status) == sizeof(uint32_t), "Size of status not equal to uint32");
128 return static_cast<Status>(
129 GetField32Volatile<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, status_)));
132 // This is static because 'this' may be moved by GC.
133 static void SetStatus(Handle<Class> h_this, Status new_status, Thread* self)
134 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
136 static MemberOffset StatusOffset() {
137 return OFFSET_OF_OBJECT_MEMBER(Class, status_);
140 // Returns true if the class has been retired.
141 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
142 bool IsRetired() SHARED_REQUIRES(Locks::mutator_lock_) {
143 return GetStatus<kVerifyFlags>() == kStatusRetired;
146 // Returns true if the class has failed to link.
147 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
148 bool IsErroneous() SHARED_REQUIRES(Locks::mutator_lock_) {
149 return GetStatus<kVerifyFlags>() == kStatusError;
152 // Returns true if the class has been loaded.
153 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
154 bool IsIdxLoaded() SHARED_REQUIRES(Locks::mutator_lock_) {
155 return GetStatus<kVerifyFlags>() >= kStatusIdx;
158 // Returns true if the class has been loaded.
159 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
160 bool IsLoaded() SHARED_REQUIRES(Locks::mutator_lock_) {
161 return GetStatus<kVerifyFlags>() >= kStatusLoaded;
164 // Returns true if the class has been linked.
165 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
166 bool IsResolved() SHARED_REQUIRES(Locks::mutator_lock_) {
167 return GetStatus<kVerifyFlags>() >= kStatusResolved;
170 // Returns true if the class was compile-time verified.
171 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
172 bool IsCompileTimeVerified() SHARED_REQUIRES(Locks::mutator_lock_) {
173 return GetStatus<kVerifyFlags>() >= kStatusRetryVerificationAtRuntime;
176 // Returns true if the class has been verified.
177 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
178 bool IsVerified() SHARED_REQUIRES(Locks::mutator_lock_) {
179 return GetStatus<kVerifyFlags>() >= kStatusVerified;
182 // Returns true if the class is initializing.
183 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
184 bool IsInitializing() SHARED_REQUIRES(Locks::mutator_lock_) {
185 return GetStatus<kVerifyFlags>() >= kStatusInitializing;
188 // Returns true if the class is initialized.
189 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
190 bool IsInitialized() SHARED_REQUIRES(Locks::mutator_lock_) {
191 return GetStatus<kVerifyFlags>() == kStatusInitialized;
194 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
195 ALWAYS_INLINE uint32_t GetAccessFlags() SHARED_REQUIRES(Locks::mutator_lock_);
196 static MemberOffset AccessFlagsOffset() {
197 return OFFSET_OF_OBJECT_MEMBER(Class, access_flags_);
200 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
201 ALWAYS_INLINE uint32_t GetClassFlags() SHARED_REQUIRES(Locks::mutator_lock_) {
202 return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_flags_));
204 void SetClassFlags(uint32_t new_flags) SHARED_REQUIRES(Locks::mutator_lock_);
206 void SetAccessFlags(uint32_t new_access_flags) SHARED_REQUIRES(Locks::mutator_lock_);
208 // Returns true if the class is an interface.
209 ALWAYS_INLINE bool IsInterface() SHARED_REQUIRES(Locks::mutator_lock_) {
210 return (GetAccessFlags() & kAccInterface) != 0;
213 // Returns true if the class is declared public.
214 ALWAYS_INLINE bool IsPublic() SHARED_REQUIRES(Locks::mutator_lock_) {
215 return (GetAccessFlags() & kAccPublic) != 0;
218 // Returns true if the class is declared final.
219 ALWAYS_INLINE bool IsFinal() SHARED_REQUIRES(Locks::mutator_lock_) {
220 return (GetAccessFlags() & kAccFinal) != 0;
223 ALWAYS_INLINE bool IsFinalizable() SHARED_REQUIRES(Locks::mutator_lock_) {
224 return (GetAccessFlags() & kAccClassIsFinalizable) != 0;
227 ALWAYS_INLINE void SetRecursivelyInitialized() SHARED_REQUIRES(Locks::mutator_lock_) {
228 DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId());
229 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
230 SetAccessFlags(flags | kAccRecursivelyInitialized);
233 ALWAYS_INLINE void SetHasDefaultMethods() SHARED_REQUIRES(Locks::mutator_lock_) {
234 DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId());
235 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
236 SetAccessFlags(flags | kAccHasDefaultMethod);
239 ALWAYS_INLINE void SetFinalizable() SHARED_REQUIRES(Locks::mutator_lock_) {
240 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
241 SetAccessFlags(flags | kAccClassIsFinalizable);
244 ALWAYS_INLINE bool IsStringClass() SHARED_REQUIRES(Locks::mutator_lock_) {
245 return (GetClassFlags() & kClassFlagString) != 0;
248 ALWAYS_INLINE void SetStringClass() SHARED_REQUIRES(Locks::mutator_lock_) {
249 SetClassFlags(kClassFlagString | kClassFlagNoReferenceFields);
252 ALWAYS_INLINE bool IsClassLoaderClass() SHARED_REQUIRES(Locks::mutator_lock_) {
253 return GetClassFlags() == kClassFlagClassLoader;
256 ALWAYS_INLINE void SetClassLoaderClass() SHARED_REQUIRES(Locks::mutator_lock_) {
257 SetClassFlags(kClassFlagClassLoader);
260 ALWAYS_INLINE bool IsDexCacheClass() SHARED_REQUIRES(Locks::mutator_lock_) {
261 return (GetClassFlags() & kClassFlagDexCache) != 0;
264 ALWAYS_INLINE void SetDexCacheClass() SHARED_REQUIRES(Locks::mutator_lock_) {
265 SetClassFlags(GetClassFlags() | kClassFlagDexCache);
268 // Returns true if the class is abstract.
269 ALWAYS_INLINE bool IsAbstract() SHARED_REQUIRES(Locks::mutator_lock_) {
270 return (GetAccessFlags() & kAccAbstract) != 0;
273 // Returns true if the class is an annotation.
274 ALWAYS_INLINE bool IsAnnotation() SHARED_REQUIRES(Locks::mutator_lock_) {
275 return (GetAccessFlags() & kAccAnnotation) != 0;
278 // Returns true if the class is synthetic.
279 ALWAYS_INLINE bool IsSynthetic() SHARED_REQUIRES(Locks::mutator_lock_) {
280 return (GetAccessFlags() & kAccSynthetic) != 0;
283 // Return whether the class had run the verifier at least once.
284 // This does not necessarily mean that access checks are avoidable,
285 // since the class methods might still need to be run with access checks.
286 bool WasVerificationAttempted() SHARED_REQUIRES(Locks::mutator_lock_) {
287 return (GetAccessFlags() & kAccSkipAccessChecks) != 0;
290 // Mark the class as having gone through a verification attempt.
291 // Mutually exclusive from whether or not each method is allowed to skip access checks.
292 void SetVerificationAttempted() SHARED_REQUIRES(Locks::mutator_lock_) {
293 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
294 if ((flags & kAccVerificationAttempted) == 0) {
295 SetAccessFlags(flags | kAccVerificationAttempted);
299 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
300 bool IsTypeOfReferenceClass() SHARED_REQUIRES(Locks::mutator_lock_) {
301 return (GetClassFlags<kVerifyFlags>() & kClassFlagReference) != 0;
304 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
305 bool IsWeakReferenceClass() SHARED_REQUIRES(Locks::mutator_lock_) {
306 return GetClassFlags<kVerifyFlags>() == kClassFlagWeakReference;
309 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
310 bool IsSoftReferenceClass() SHARED_REQUIRES(Locks::mutator_lock_) {
311 return GetClassFlags<kVerifyFlags>() == kClassFlagSoftReference;
314 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
315 bool IsFinalizerReferenceClass() SHARED_REQUIRES(Locks::mutator_lock_) {
316 return GetClassFlags<kVerifyFlags>() == kClassFlagFinalizerReference;
319 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
320 bool IsPhantomReferenceClass() SHARED_REQUIRES(Locks::mutator_lock_) {
321 return GetClassFlags<kVerifyFlags>() == kClassFlagPhantomReference;
324 // Can references of this type be assigned to by things of another type? For non-array types
325 // this is a matter of whether sub-classes may exist - which they can't if the type is final.
326 // For array classes, where all the classes are final due to there being no sub-classes, an
327 // Object[] may be assigned to by a String[] but a String[] may not be assigned to by other
328 // types as the component is final.
329 bool CannotBeAssignedFromOtherTypes() SHARED_REQUIRES(Locks::mutator_lock_) {
330 if (!IsArrayClass()) {
333 Class* component = GetComponentType();
334 if (component->IsPrimitive()) {
337 return component->CannotBeAssignedFromOtherTypes();
342 // Returns true if this class is the placeholder and should retire and
343 // be replaced with a class with the right size for embedded imt/vtable.
344 bool IsTemp() SHARED_REQUIRES(Locks::mutator_lock_) {
345 Status s = GetStatus();
346 return s < Status::kStatusResolving && ShouldHaveEmbeddedVTable();
349 String* GetName() SHARED_REQUIRES(Locks::mutator_lock_); // Returns the cached name.
350 void SetName(String* name) SHARED_REQUIRES(Locks::mutator_lock_); // Sets the cached name.
351 // Computes the name, then sets the cached value.
352 static String* ComputeName(Handle<Class> h_this) SHARED_REQUIRES(Locks::mutator_lock_)
353 REQUIRES(!Roles::uninterruptible_);
355 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
356 bool IsProxyClass() SHARED_REQUIRES(Locks::mutator_lock_) {
357 // Read access flags without using getter as whether something is a proxy can be check in
359 // TODO: switch to a check if the super class is java.lang.reflect.Proxy?
360 uint32_t access_flags = GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
361 return (access_flags & kAccClassIsProxy) != 0;
364 static MemberOffset PrimitiveTypeOffset() {
365 return OFFSET_OF_OBJECT_MEMBER(Class, primitive_type_);
368 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
369 Primitive::Type GetPrimitiveType() ALWAYS_INLINE SHARED_REQUIRES(Locks::mutator_lock_);
371 void SetPrimitiveType(Primitive::Type new_type) SHARED_REQUIRES(Locks::mutator_lock_) {
372 DCHECK_EQ(sizeof(Primitive::Type), sizeof(int32_t));
373 int32_t v32 = static_cast<int32_t>(new_type);
374 DCHECK_EQ(v32 & 0xFFFF, v32) << "upper 16 bits aren't zero";
375 // Store the component size shift in the upper 16 bits.
376 v32 |= Primitive::ComponentSizeShift(new_type) << 16;
377 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, primitive_type_), v32);
380 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
381 size_t GetPrimitiveTypeSizeShift() ALWAYS_INLINE SHARED_REQUIRES(Locks::mutator_lock_);
383 // Returns true if the class is a primitive type.
384 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
385 bool IsPrimitive() SHARED_REQUIRES(Locks::mutator_lock_) {
386 return GetPrimitiveType<kVerifyFlags>() != Primitive::kPrimNot;
389 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
390 bool IsPrimitiveBoolean() SHARED_REQUIRES(Locks::mutator_lock_) {
391 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimBoolean;
394 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
395 bool IsPrimitiveByte() SHARED_REQUIRES(Locks::mutator_lock_) {
396 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimByte;
399 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
400 bool IsPrimitiveChar() SHARED_REQUIRES(Locks::mutator_lock_) {
401 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimChar;
404 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
405 bool IsPrimitiveShort() SHARED_REQUIRES(Locks::mutator_lock_) {
406 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimShort;
409 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
410 bool IsPrimitiveInt() SHARED_REQUIRES(Locks::mutator_lock_) {
411 return GetPrimitiveType() == Primitive::kPrimInt;
414 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
415 bool IsPrimitiveLong() SHARED_REQUIRES(Locks::mutator_lock_) {
416 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimLong;
419 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
420 bool IsPrimitiveFloat() SHARED_REQUIRES(Locks::mutator_lock_) {
421 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimFloat;
424 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
425 bool IsPrimitiveDouble() SHARED_REQUIRES(Locks::mutator_lock_) {
426 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimDouble;
429 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
430 bool IsPrimitiveVoid() SHARED_REQUIRES(Locks::mutator_lock_) {
431 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimVoid;
434 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
435 bool IsPrimitiveArray() SHARED_REQUIRES(Locks::mutator_lock_) {
436 return IsArrayClass<kVerifyFlags>() &&
437 GetComponentType<static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis)>()->
441 // Depth of class from java.lang.Object
442 uint32_t Depth() SHARED_REQUIRES(Locks::mutator_lock_);
444 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
445 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
446 bool IsArrayClass() SHARED_REQUIRES(Locks::mutator_lock_);
448 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
449 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
450 bool IsClassClass() SHARED_REQUIRES(Locks::mutator_lock_);
452 bool IsThrowableClass() SHARED_REQUIRES(Locks::mutator_lock_);
454 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
455 bool IsReferenceClass() const SHARED_REQUIRES(Locks::mutator_lock_);
457 static MemberOffset ComponentTypeOffset() {
458 return OFFSET_OF_OBJECT_MEMBER(Class, component_type_);
461 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
462 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
463 Class* GetComponentType() SHARED_REQUIRES(Locks::mutator_lock_);
465 void SetComponentType(Class* new_component_type) SHARED_REQUIRES(Locks::mutator_lock_) {
466 DCHECK(GetComponentType() == nullptr);
467 DCHECK(new_component_type != nullptr);
468 // Component type is invariant: use non-transactional mode without check.
469 SetFieldObject<false, false>(ComponentTypeOffset(), new_component_type);
472 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
473 size_t GetComponentSize() SHARED_REQUIRES(Locks::mutator_lock_) {
474 return 1U << GetComponentSizeShift();
477 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
478 size_t GetComponentSizeShift() SHARED_REQUIRES(Locks::mutator_lock_) {
479 return GetComponentType<kDefaultVerifyFlags, kReadBarrierOption>()->GetPrimitiveTypeSizeShift();
482 bool IsObjectClass() SHARED_REQUIRES(Locks::mutator_lock_) {
483 return !IsPrimitive() && GetSuperClass() == nullptr;
486 bool IsInstantiableNonArray() SHARED_REQUIRES(Locks::mutator_lock_) {
487 return !IsPrimitive() && !IsInterface() && !IsAbstract() && !IsArrayClass();
490 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
491 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
492 bool IsInstantiable() SHARED_REQUIRES(Locks::mutator_lock_) {
493 return (!IsPrimitive() && !IsInterface() && !IsAbstract()) ||
494 (IsAbstract() && IsArrayClass<kVerifyFlags, kReadBarrierOption>());
497 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
498 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
499 bool IsObjectArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) {
500 mirror::Class* const component_type = GetComponentType<kVerifyFlags, kReadBarrierOption>();
501 return component_type != nullptr && !component_type->IsPrimitive();
504 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
505 bool IsIntArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) {
506 constexpr auto kNewFlags = static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis);
507 auto* component_type = GetComponentType<kVerifyFlags>();
508 return component_type != nullptr && component_type->template IsPrimitiveInt<kNewFlags>();
511 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
512 bool IsLongArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) {
513 constexpr auto kNewFlags = static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis);
514 auto* component_type = GetComponentType<kVerifyFlags>();
515 return component_type != nullptr && component_type->template IsPrimitiveLong<kNewFlags>();
518 // Creates a raw object instance but does not invoke the default constructor.
519 template<bool kIsInstrumented, bool kCheckAddFinalizer = true>
520 ALWAYS_INLINE Object* Alloc(Thread* self, gc::AllocatorType allocator_type)
521 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
523 Object* AllocObject(Thread* self)
524 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
525 Object* AllocNonMovableObject(Thread* self)
526 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
528 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
529 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
530 bool IsVariableSize() SHARED_REQUIRES(Locks::mutator_lock_) {
531 // Classes, arrays, and strings vary in size, and so the object_size_ field cannot
532 // be used to Get their instance size
533 return IsClassClass<kVerifyFlags, kReadBarrierOption>() ||
534 IsArrayClass<kVerifyFlags, kReadBarrierOption>() || IsStringClass();
537 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
538 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
539 uint32_t SizeOf() SHARED_REQUIRES(Locks::mutator_lock_) {
540 return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_size_));
543 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
544 uint32_t GetClassSize() SHARED_REQUIRES(Locks::mutator_lock_) {
545 return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_size_));
548 void SetClassSize(uint32_t new_class_size)
549 SHARED_REQUIRES(Locks::mutator_lock_);
551 // Compute how many bytes would be used a class with the given elements.
552 static uint32_t ComputeClassSize(bool has_embedded_vtable,
553 uint32_t num_vtable_entries,
554 uint32_t num_8bit_static_fields,
555 uint32_t num_16bit_static_fields,
556 uint32_t num_32bit_static_fields,
557 uint32_t num_64bit_static_fields,
558 uint32_t num_ref_static_fields,
559 size_t pointer_size);
561 // The size of java.lang.Class.class.
562 static uint32_t ClassClassSize(size_t pointer_size) {
563 // The number of vtable entries in java.lang.Class.
564 uint32_t vtable_entries = Object::kVTableLength + 72;
565 return ComputeClassSize(true, vtable_entries, 0, 0, 4, 1, 0, pointer_size);
568 // The size of a java.lang.Class representing a primitive such as int.class.
569 static uint32_t PrimitiveClassSize(size_t pointer_size) {
570 return ComputeClassSize(false, 0, 0, 0, 0, 0, 0, pointer_size);
573 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
574 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
575 uint32_t GetObjectSize() SHARED_REQUIRES(Locks::mutator_lock_);
576 static MemberOffset ObjectSizeOffset() {
577 return OFFSET_OF_OBJECT_MEMBER(Class, object_size_);
580 void SetObjectSize(uint32_t new_object_size) SHARED_REQUIRES(Locks::mutator_lock_) {
581 DCHECK(!IsVariableSize());
582 // Not called within a transaction.
583 return SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, object_size_), new_object_size);
586 void SetObjectSizeWithoutChecks(uint32_t new_object_size)
587 SHARED_REQUIRES(Locks::mutator_lock_) {
588 // Not called within a transaction.
589 return SetField32<false, false, kVerifyNone>(
590 OFFSET_OF_OBJECT_MEMBER(Class, object_size_), new_object_size);
593 // Returns true if this class is in the same packages as that class.
594 bool IsInSamePackage(Class* that) SHARED_REQUIRES(Locks::mutator_lock_);
596 static bool IsInSamePackage(const StringPiece& descriptor1, const StringPiece& descriptor2);
598 // Returns true if this class can access that class.
599 bool CanAccess(Class* that) SHARED_REQUIRES(Locks::mutator_lock_) {
600 return that->IsPublic() || this->IsInSamePackage(that);
603 // Can this class access a member in the provided class with the provided member access flags?
604 // Note that access to the class isn't checked in case the declaring class is protected and the
605 // method has been exposed by a public sub-class
606 bool CanAccessMember(Class* access_to, uint32_t member_flags)
607 SHARED_REQUIRES(Locks::mutator_lock_) {
608 // Classes can access all of their own members
609 if (this == access_to) {
612 // Public members are trivially accessible
613 if (member_flags & kAccPublic) {
616 // Private members are trivially not accessible
617 if (member_flags & kAccPrivate) {
620 // Check for protected access from a sub-class, which may or may not be in the same package.
621 if (member_flags & kAccProtected) {
622 if (!this->IsInterface() && this->IsSubClass(access_to)) {
626 // Allow protected access from other classes in the same package.
627 return this->IsInSamePackage(access_to);
630 // Can this class access a resolved field?
631 // Note that access to field's class is checked and this may require looking up the class
632 // referenced by the FieldId in the DexFile in case the declaring class is inaccessible.
633 bool CanAccessResolvedField(Class* access_to, ArtField* field,
634 DexCache* dex_cache, uint32_t field_idx)
635 SHARED_REQUIRES(Locks::mutator_lock_);
636 bool CheckResolvedFieldAccess(Class* access_to, ArtField* field,
638 SHARED_REQUIRES(Locks::mutator_lock_);
640 // Can this class access a resolved method?
641 // Note that access to methods's class is checked and this may require looking up the class
642 // referenced by the MethodId in the DexFile in case the declaring class is inaccessible.
643 bool CanAccessResolvedMethod(Class* access_to, ArtMethod* resolved_method,
644 DexCache* dex_cache, uint32_t method_idx)
645 SHARED_REQUIRES(Locks::mutator_lock_);
646 template <InvokeType throw_invoke_type>
647 bool CheckResolvedMethodAccess(Class* access_to, ArtMethod* resolved_method,
649 SHARED_REQUIRES(Locks::mutator_lock_);
651 bool IsSubClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
653 // Can src be assigned to this class? For example, String can be assigned to Object (by an
654 // upcast), however, an Object cannot be assigned to a String as a potentially exception throwing
655 // downcast would be necessary. Similarly for interfaces, a class that implements (or an interface
656 // that extends) another can be assigned to its parent, but not vice-versa. All Classes may assign
657 // to themselves. Classes for primitive types may not assign to each other.
658 ALWAYS_INLINE bool IsAssignableFrom(Class* src) SHARED_REQUIRES(Locks::mutator_lock_);
660 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
661 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
662 ALWAYS_INLINE Class* GetSuperClass() SHARED_REQUIRES(Locks::mutator_lock_);
664 // Get first common super class. It will never return null.
665 // `This` and `klass` must be classes.
666 Class* GetCommonSuperClass(Handle<Class> klass) SHARED_REQUIRES(Locks::mutator_lock_);
668 void SetSuperClass(Class* new_super_class) SHARED_REQUIRES(Locks::mutator_lock_) {
669 // Super class is assigned once, except during class linker initialization.
670 Class* old_super_class = GetFieldObject<Class>(OFFSET_OF_OBJECT_MEMBER(Class, super_class_));
671 DCHECK(old_super_class == nullptr || old_super_class == new_super_class);
672 DCHECK(new_super_class != nullptr);
673 SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(Class, super_class_), new_super_class);
676 bool HasSuperClass() SHARED_REQUIRES(Locks::mutator_lock_) {
677 return GetSuperClass() != nullptr;
680 static MemberOffset SuperClassOffset() {
681 return MemberOffset(OFFSETOF_MEMBER(Class, super_class_));
684 ClassLoader* GetClassLoader() ALWAYS_INLINE SHARED_REQUIRES(Locks::mutator_lock_);
686 void SetClassLoader(ClassLoader* new_cl) SHARED_REQUIRES(Locks::mutator_lock_);
688 static MemberOffset DexCacheOffset() {
689 return MemberOffset(OFFSETOF_MEMBER(Class, dex_cache_));
693 kDumpClassFullDetail = 1,
694 kDumpClassClassLoader = (1 << 1),
695 kDumpClassInitialized = (1 << 2),
698 void DumpClass(std::ostream& os, int flags) SHARED_REQUIRES(Locks::mutator_lock_);
700 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
701 DexCache* GetDexCache() SHARED_REQUIRES(Locks::mutator_lock_);
703 // Also updates the dex_cache_strings_ variable from new_dex_cache.
704 void SetDexCache(DexCache* new_dex_cache) SHARED_REQUIRES(Locks::mutator_lock_);
706 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetDirectMethods(size_t pointer_size)
707 SHARED_REQUIRES(Locks::mutator_lock_);
709 ALWAYS_INLINE LengthPrefixedArray<ArtMethod>* GetMethodsPtr()
710 SHARED_REQUIRES(Locks::mutator_lock_);
712 static MemberOffset MethodsOffset() {
713 return MemberOffset(OFFSETOF_MEMBER(Class, methods_));
716 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetMethods(size_t pointer_size)
717 SHARED_REQUIRES(Locks::mutator_lock_);
719 void SetMethodsPtr(LengthPrefixedArray<ArtMethod>* new_methods,
721 uint32_t num_virtual)
722 SHARED_REQUIRES(Locks::mutator_lock_);
723 // Used by image writer.
724 void SetMethodsPtrUnchecked(LengthPrefixedArray<ArtMethod>* new_methods,
726 uint32_t num_virtual)
727 SHARED_REQUIRES(Locks::mutator_lock_);
729 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
730 ALWAYS_INLINE ArraySlice<ArtMethod> GetDirectMethodsSlice(size_t pointer_size)
731 SHARED_REQUIRES(Locks::mutator_lock_);
733 ALWAYS_INLINE ArtMethod* GetDirectMethod(size_t i, size_t pointer_size)
734 SHARED_REQUIRES(Locks::mutator_lock_);
736 // Use only when we are allocating populating the method arrays.
737 ALWAYS_INLINE ArtMethod* GetDirectMethodUnchecked(size_t i, size_t pointer_size)
738 SHARED_REQUIRES(Locks::mutator_lock_);
739 ALWAYS_INLINE ArtMethod* GetVirtualMethodUnchecked(size_t i, size_t pointer_size)
740 SHARED_REQUIRES(Locks::mutator_lock_);
742 // Returns the number of static, private, and constructor methods.
743 ALWAYS_INLINE uint32_t NumDirectMethods() SHARED_REQUIRES(Locks::mutator_lock_);
745 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
746 ALWAYS_INLINE ArraySlice<ArtMethod> GetMethodsSlice(size_t pointer_size)
747 SHARED_REQUIRES(Locks::mutator_lock_);
749 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
750 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredMethodsSlice(size_t pointer_size)
751 SHARED_REQUIRES(Locks::mutator_lock_);
753 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetDeclaredMethods(
755 SHARED_REQUIRES(Locks::mutator_lock_);
757 template <bool kTransactionActive = false>
758 static Method* GetDeclaredMethodInternal(Thread* self,
759 mirror::Class* klass,
760 mirror::String* name,
761 mirror::ObjectArray<mirror::Class>* args)
762 SHARED_REQUIRES(Locks::mutator_lock_);
763 template <bool kTransactionActive = false>
764 static Constructor* GetDeclaredConstructorInternal(Thread* self,
765 mirror::Class* klass,
766 mirror::ObjectArray<mirror::Class>* args)
767 SHARED_REQUIRES(Locks::mutator_lock_);
769 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
770 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredVirtualMethodsSlice(size_t pointer_size)
771 SHARED_REQUIRES(Locks::mutator_lock_);
773 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetDeclaredVirtualMethods(
775 SHARED_REQUIRES(Locks::mutator_lock_);
777 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
778 ALWAYS_INLINE ArraySlice<ArtMethod> GetCopiedMethodsSlice(size_t pointer_size)
779 SHARED_REQUIRES(Locks::mutator_lock_);
781 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetCopiedMethods(size_t pointer_size)
782 SHARED_REQUIRES(Locks::mutator_lock_);
784 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
785 ALWAYS_INLINE ArraySlice<ArtMethod> GetVirtualMethodsSlice(size_t pointer_size)
786 SHARED_REQUIRES(Locks::mutator_lock_);
788 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetVirtualMethods(size_t pointer_size)
789 SHARED_REQUIRES(Locks::mutator_lock_);
791 // Returns the number of non-inherited virtual methods (sum of declared and copied methods).
792 ALWAYS_INLINE uint32_t NumVirtualMethods() SHARED_REQUIRES(Locks::mutator_lock_);
794 // Returns the number of copied virtual methods.
795 ALWAYS_INLINE uint32_t NumCopiedVirtualMethods() SHARED_REQUIRES(Locks::mutator_lock_);
797 // Returns the number of declared virtual methods.
798 ALWAYS_INLINE uint32_t NumDeclaredVirtualMethods() SHARED_REQUIRES(Locks::mutator_lock_);
800 ALWAYS_INLINE uint32_t NumMethods() SHARED_REQUIRES(Locks::mutator_lock_);
802 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
803 ArtMethod* GetVirtualMethod(size_t i, size_t pointer_size)
804 SHARED_REQUIRES(Locks::mutator_lock_);
806 ArtMethod* GetVirtualMethodDuringLinking(size_t i, size_t pointer_size)
807 SHARED_REQUIRES(Locks::mutator_lock_);
809 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
810 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
811 ALWAYS_INLINE PointerArray* GetVTable() SHARED_REQUIRES(Locks::mutator_lock_);
813 ALWAYS_INLINE PointerArray* GetVTableDuringLinking() SHARED_REQUIRES(Locks::mutator_lock_);
815 void SetVTable(PointerArray* new_vtable) SHARED_REQUIRES(Locks::mutator_lock_);
817 static MemberOffset VTableOffset() {
818 return OFFSET_OF_OBJECT_MEMBER(Class, vtable_);
821 static MemberOffset EmbeddedVTableLengthOffset() {
822 return MemberOffset(sizeof(Class));
825 static MemberOffset ImtPtrOffset(size_t pointer_size) {
827 RoundUp(EmbeddedVTableLengthOffset().Uint32Value() + sizeof(uint32_t), pointer_size));
830 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
831 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
832 bool ShouldHaveImt() SHARED_REQUIRES(Locks::mutator_lock_) {
833 return ShouldHaveEmbeddedVTable<kVerifyFlags, kReadBarrierOption>();
836 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
837 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
838 bool ShouldHaveEmbeddedVTable() SHARED_REQUIRES(Locks::mutator_lock_) {
839 return IsInstantiable<kVerifyFlags, kReadBarrierOption>();
842 bool HasVTable() SHARED_REQUIRES(Locks::mutator_lock_);
844 static MemberOffset EmbeddedVTableEntryOffset(uint32_t i, size_t pointer_size);
846 int32_t GetVTableLength() SHARED_REQUIRES(Locks::mutator_lock_);
848 ArtMethod* GetVTableEntry(uint32_t i, size_t pointer_size)
849 SHARED_REQUIRES(Locks::mutator_lock_);
851 int32_t GetEmbeddedVTableLength() SHARED_REQUIRES(Locks::mutator_lock_);
853 void SetEmbeddedVTableLength(int32_t len) SHARED_REQUIRES(Locks::mutator_lock_);
855 ImTable* GetImt(size_t pointer_size) SHARED_REQUIRES(Locks::mutator_lock_);
857 void SetImt(ImTable* imt, size_t pointer_size) SHARED_REQUIRES(Locks::mutator_lock_);
859 ArtMethod* GetEmbeddedVTableEntry(uint32_t i, size_t pointer_size)
860 SHARED_REQUIRES(Locks::mutator_lock_);
862 void SetEmbeddedVTableEntry(uint32_t i, ArtMethod* method, size_t pointer_size)
863 SHARED_REQUIRES(Locks::mutator_lock_);
865 inline void SetEmbeddedVTableEntryUnchecked(uint32_t i, ArtMethod* method, size_t pointer_size)
866 SHARED_REQUIRES(Locks::mutator_lock_);
868 void PopulateEmbeddedVTable(size_t pointer_size)
869 SHARED_REQUIRES(Locks::mutator_lock_);
871 // Given a method implemented by this class but potentially from a super class, return the
872 // specific implementation method for this class.
873 ArtMethod* FindVirtualMethodForVirtual(ArtMethod* method, size_t pointer_size)
874 SHARED_REQUIRES(Locks::mutator_lock_);
876 // Given a method implemented by this class' super class, return the specific implementation
877 // method for this class.
878 ArtMethod* FindVirtualMethodForSuper(ArtMethod* method, size_t pointer_size)
879 SHARED_REQUIRES(Locks::mutator_lock_);
881 // Given a method from some implementor of this interface, return the specific implementation
882 // method for this class.
883 ArtMethod* FindVirtualMethodForInterfaceSuper(ArtMethod* method, size_t pointer_size)
884 SHARED_REQUIRES(Locks::mutator_lock_);
886 // Given a method implemented by this class, but potentially from a
887 // super class or interface, return the specific implementation
888 // method for this class.
889 ArtMethod* FindVirtualMethodForInterface(ArtMethod* method, size_t pointer_size)
890 SHARED_REQUIRES(Locks::mutator_lock_) ALWAYS_INLINE;
892 ArtMethod* FindVirtualMethodForVirtualOrInterface(ArtMethod* method, size_t pointer_size)
893 SHARED_REQUIRES(Locks::mutator_lock_);
895 ArtMethod* FindInterfaceMethod(const StringPiece& name, const StringPiece& signature,
897 SHARED_REQUIRES(Locks::mutator_lock_);
899 ArtMethod* FindInterfaceMethod(const StringPiece& name, const Signature& signature,
901 SHARED_REQUIRES(Locks::mutator_lock_);
903 ArtMethod* FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx,
905 SHARED_REQUIRES(Locks::mutator_lock_);
907 ArtMethod* FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature,
909 SHARED_REQUIRES(Locks::mutator_lock_);
911 ArtMethod* FindDeclaredDirectMethod(const StringPiece& name, const Signature& signature,
913 SHARED_REQUIRES(Locks::mutator_lock_);
915 ArtMethod* FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx,
917 SHARED_REQUIRES(Locks::mutator_lock_);
919 ArtMethod* FindDirectMethod(const StringPiece& name, const StringPiece& signature,
921 SHARED_REQUIRES(Locks::mutator_lock_);
923 ArtMethod* FindDirectMethod(const StringPiece& name, const Signature& signature,
925 SHARED_REQUIRES(Locks::mutator_lock_);
927 ArtMethod* FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx,
929 SHARED_REQUIRES(Locks::mutator_lock_);
931 ArtMethod* FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature,
933 SHARED_REQUIRES(Locks::mutator_lock_);
935 ArtMethod* FindDeclaredVirtualMethod(const StringPiece& name, const Signature& signature,
937 SHARED_REQUIRES(Locks::mutator_lock_);
939 ArtMethod* FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx,
941 SHARED_REQUIRES(Locks::mutator_lock_);
943 ArtMethod* FindDeclaredVirtualMethodByName(const StringPiece& name, size_t pointer_size)
944 SHARED_REQUIRES(Locks::mutator_lock_);
946 ArtMethod* FindDeclaredDirectMethodByName(const StringPiece& name, size_t pointer_size)
947 SHARED_REQUIRES(Locks::mutator_lock_);
949 ArtMethod* FindVirtualMethod(const StringPiece& name, const StringPiece& signature,
951 SHARED_REQUIRES(Locks::mutator_lock_);
953 ArtMethod* FindVirtualMethod(const StringPiece& name, const Signature& signature,
955 SHARED_REQUIRES(Locks::mutator_lock_);
957 ArtMethod* FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx,
959 SHARED_REQUIRES(Locks::mutator_lock_);
961 ArtMethod* FindClassInitializer(size_t pointer_size) SHARED_REQUIRES(Locks::mutator_lock_);
963 bool HasDefaultMethods() SHARED_REQUIRES(Locks::mutator_lock_) {
964 return (GetAccessFlags() & kAccHasDefaultMethod) != 0;
967 bool HasBeenRecursivelyInitialized() SHARED_REQUIRES(Locks::mutator_lock_) {
968 return (GetAccessFlags() & kAccRecursivelyInitialized) != 0;
971 ALWAYS_INLINE int32_t GetIfTableCount() SHARED_REQUIRES(Locks::mutator_lock_);
973 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
974 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
975 ALWAYS_INLINE IfTable* GetIfTable() SHARED_REQUIRES(Locks::mutator_lock_);
977 ALWAYS_INLINE void SetIfTable(IfTable* new_iftable) SHARED_REQUIRES(Locks::mutator_lock_);
979 // Get instance fields of the class (See also GetSFields).
980 LengthPrefixedArray<ArtField>* GetIFieldsPtr() SHARED_REQUIRES(Locks::mutator_lock_);
982 ALWAYS_INLINE IterationRange<StrideIterator<ArtField>> GetIFields()
983 SHARED_REQUIRES(Locks::mutator_lock_);
985 void SetIFieldsPtr(LengthPrefixedArray<ArtField>* new_ifields)
986 SHARED_REQUIRES(Locks::mutator_lock_);
988 // Unchecked edition has no verification flags.
989 void SetIFieldsPtrUnchecked(LengthPrefixedArray<ArtField>* new_sfields)
990 SHARED_REQUIRES(Locks::mutator_lock_);
992 uint32_t NumInstanceFields() SHARED_REQUIRES(Locks::mutator_lock_);
993 ArtField* GetInstanceField(uint32_t i) SHARED_REQUIRES(Locks::mutator_lock_);
995 // Returns the number of instance fields containing reference types. Does not count fields in any
997 uint32_t NumReferenceInstanceFields() SHARED_REQUIRES(Locks::mutator_lock_) {
998 DCHECK(IsResolved() || IsErroneous());
999 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_));
1002 uint32_t NumReferenceInstanceFieldsDuringLinking() SHARED_REQUIRES(Locks::mutator_lock_) {
1003 DCHECK(IsLoaded() || IsErroneous());
1004 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_));
1007 void SetNumReferenceInstanceFields(uint32_t new_num) SHARED_REQUIRES(Locks::mutator_lock_) {
1008 // Not called within a transaction.
1009 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_), new_num);
1012 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
1013 uint32_t GetReferenceInstanceOffsets() ALWAYS_INLINE SHARED_REQUIRES(Locks::mutator_lock_);
1015 void SetReferenceInstanceOffsets(uint32_t new_reference_offsets)
1016 SHARED_REQUIRES(Locks::mutator_lock_);
1018 // Get the offset of the first reference instance field. Other reference instance fields follow.
1019 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1020 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
1021 MemberOffset GetFirstReferenceInstanceFieldOffset()
1022 SHARED_REQUIRES(Locks::mutator_lock_);
1024 // Returns the number of static fields containing reference types.
1025 uint32_t NumReferenceStaticFields() SHARED_REQUIRES(Locks::mutator_lock_) {
1026 DCHECK(IsResolved() || IsErroneous());
1027 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_));
1030 uint32_t NumReferenceStaticFieldsDuringLinking() SHARED_REQUIRES(Locks::mutator_lock_) {
1031 DCHECK(IsLoaded() || IsErroneous() || IsRetired());
1032 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_));
1035 void SetNumReferenceStaticFields(uint32_t new_num) SHARED_REQUIRES(Locks::mutator_lock_) {
1036 // Not called within a transaction.
1037 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_), new_num);
1040 // Get the offset of the first reference static field. Other reference static fields follow.
1041 template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1042 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
1043 MemberOffset GetFirstReferenceStaticFieldOffset(size_t pointer_size)
1044 SHARED_REQUIRES(Locks::mutator_lock_);
1046 // Get the offset of the first reference static field. Other reference static fields follow.
1047 MemberOffset GetFirstReferenceStaticFieldOffsetDuringLinking(size_t pointer_size)
1048 SHARED_REQUIRES(Locks::mutator_lock_);
1050 // Gets the static fields of the class.
1051 LengthPrefixedArray<ArtField>* GetSFieldsPtr() SHARED_REQUIRES(Locks::mutator_lock_);
1052 ALWAYS_INLINE IterationRange<StrideIterator<ArtField>> GetSFields()
1053 SHARED_REQUIRES(Locks::mutator_lock_);
1055 void SetSFieldsPtr(LengthPrefixedArray<ArtField>* new_sfields)
1056 SHARED_REQUIRES(Locks::mutator_lock_);
1058 // Unchecked edition has no verification flags.
1059 void SetSFieldsPtrUnchecked(LengthPrefixedArray<ArtField>* new_sfields)
1060 SHARED_REQUIRES(Locks::mutator_lock_);
1062 uint32_t NumStaticFields() SHARED_REQUIRES(Locks::mutator_lock_);
1065 ArtField* GetStaticField(uint32_t i) SHARED_REQUIRES(Locks::mutator_lock_);
1067 // Find a static or instance field using the JLS resolution order
1068 static ArtField* FindField(Thread* self, Handle<Class> klass, const StringPiece& name,
1069 const StringPiece& type)
1070 SHARED_REQUIRES(Locks::mutator_lock_);
1072 // Finds the given instance field in this class or a superclass.
1073 ArtField* FindInstanceField(const StringPiece& name, const StringPiece& type)
1074 SHARED_REQUIRES(Locks::mutator_lock_);
1076 // Finds the given instance field in this class or a superclass, only searches classes that
1077 // have the same dex cache.
1078 ArtField* FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx)
1079 SHARED_REQUIRES(Locks::mutator_lock_);
1081 ArtField* FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type)
1082 SHARED_REQUIRES(Locks::mutator_lock_);
1084 ArtField* FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx)
1085 SHARED_REQUIRES(Locks::mutator_lock_);
1087 // Finds the given static field in this class or a superclass.
1088 static ArtField* FindStaticField(Thread* self, Handle<Class> klass, const StringPiece& name,
1089 const StringPiece& type)
1090 SHARED_REQUIRES(Locks::mutator_lock_);
1092 // Finds the given static field in this class or superclass, only searches classes that
1093 // have the same dex cache.
1094 static ArtField* FindStaticField(Thread* self,
1096 const DexCache* dex_cache,
1097 uint32_t dex_field_idx)
1098 SHARED_REQUIRES(Locks::mutator_lock_);
1100 ArtField* FindDeclaredStaticField(const StringPiece& name, const StringPiece& type)
1101 SHARED_REQUIRES(Locks::mutator_lock_);
1103 ArtField* FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx)
1104 SHARED_REQUIRES(Locks::mutator_lock_);
1106 pid_t GetClinitThreadId() SHARED_REQUIRES(Locks::mutator_lock_) {
1107 DCHECK(IsIdxLoaded() || IsErroneous()) << PrettyClass(this);
1108 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, clinit_thread_id_));
1111 void SetClinitThreadId(pid_t new_clinit_thread_id) SHARED_REQUIRES(Locks::mutator_lock_);
1113 Object* GetVerifyError() SHARED_REQUIRES(Locks::mutator_lock_) {
1114 // DCHECK(IsErroneous());
1115 return GetFieldObject<Class>(OFFSET_OF_OBJECT_MEMBER(Class, verify_error_));
1118 uint16_t GetDexClassDefIndex() SHARED_REQUIRES(Locks::mutator_lock_) {
1119 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, dex_class_def_idx_));
1122 void SetDexClassDefIndex(uint16_t class_def_idx) SHARED_REQUIRES(Locks::mutator_lock_) {
1123 // Not called within a transaction.
1124 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, dex_class_def_idx_), class_def_idx);
1127 uint16_t GetDexTypeIndex() SHARED_REQUIRES(Locks::mutator_lock_) {
1128 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, dex_type_idx_));
1131 void SetDexTypeIndex(uint16_t type_idx) SHARED_REQUIRES(Locks::mutator_lock_) {
1132 // Not called within a transaction.
1133 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, dex_type_idx_), type_idx);
1136 uint32_t FindTypeIndexInOtherDexFile(const DexFile& dex_file)
1137 SHARED_REQUIRES(Locks::mutator_lock_);
1139 static Class* GetJavaLangClass() SHARED_REQUIRES(Locks::mutator_lock_) {
1140 DCHECK(HasJavaLangClass());
1141 return java_lang_Class_.Read();
1144 static bool HasJavaLangClass() SHARED_REQUIRES(Locks::mutator_lock_) {
1145 return !java_lang_Class_.IsNull();
1148 // Can't call this SetClass or else gets called instead of Object::SetClass in places.
1149 static void SetClassClass(Class* java_lang_Class) SHARED_REQUIRES(Locks::mutator_lock_);
1150 static void ResetClass();
1151 static void VisitRoots(RootVisitor* visitor)
1152 SHARED_REQUIRES(Locks::mutator_lock_);
1154 // Visit native roots visits roots which are keyed off the native pointers such as ArtFields and
1156 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier, class Visitor>
1157 void VisitNativeRoots(Visitor& visitor, size_t pointer_size)
1158 SHARED_REQUIRES(Locks::mutator_lock_);
1160 // When class is verified, set the kAccSkipAccessChecks flag on each method.
1161 void SetSkipAccessChecksFlagOnAllMethods(size_t pointer_size)
1162 SHARED_REQUIRES(Locks::mutator_lock_);
1164 // Get the descriptor of the class. In a few cases a std::string is required, rather than
1165 // always create one the storage argument is populated and its internal c_str() returned. We do
1166 // this to avoid memory allocation in the common case.
1167 const char* GetDescriptor(std::string* storage) SHARED_REQUIRES(Locks::mutator_lock_);
1169 const char* GetArrayDescriptor(std::string* storage) SHARED_REQUIRES(Locks::mutator_lock_);
1171 bool DescriptorEquals(const char* match) SHARED_REQUIRES(Locks::mutator_lock_);
1173 const DexFile::ClassDef* GetClassDef() SHARED_REQUIRES(Locks::mutator_lock_);
1175 ALWAYS_INLINE uint32_t NumDirectInterfaces() SHARED_REQUIRES(Locks::mutator_lock_);
1177 uint16_t GetDirectInterfaceTypeIdx(uint32_t idx) SHARED_REQUIRES(Locks::mutator_lock_);
1179 static mirror::Class* GetDirectInterface(Thread* self, Handle<mirror::Class> klass,
1181 SHARED_REQUIRES(Locks::mutator_lock_);
1183 const char* GetSourceFile() SHARED_REQUIRES(Locks::mutator_lock_);
1185 std::string GetLocation() SHARED_REQUIRES(Locks::mutator_lock_);
1187 const DexFile& GetDexFile() SHARED_REQUIRES(Locks::mutator_lock_);
1189 const DexFile::TypeList* GetInterfaceTypeList() SHARED_REQUIRES(Locks::mutator_lock_);
1191 // Asserts we are initialized or initializing in the given thread.
1192 void AssertInitializedOrInitializingInThread(Thread* self)
1193 SHARED_REQUIRES(Locks::mutator_lock_);
1195 Class* CopyOf(Thread* self, int32_t new_length, ImTable* imt,
1196 size_t pointer_size)
1197 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
1199 // For proxy class only.
1200 ObjectArray<Class>* GetInterfaces() SHARED_REQUIRES(Locks::mutator_lock_);
1202 // For proxy class only.
1203 ObjectArray<ObjectArray<Class>>* GetThrows() SHARED_REQUIRES(Locks::mutator_lock_);
1205 // For reference class only.
1206 MemberOffset GetDisableIntrinsicFlagOffset() SHARED_REQUIRES(Locks::mutator_lock_);
1207 MemberOffset GetSlowPathFlagOffset() SHARED_REQUIRES(Locks::mutator_lock_);
1208 bool GetSlowPathEnabled() SHARED_REQUIRES(Locks::mutator_lock_);
1209 void SetSlowPath(bool enabled) SHARED_REQUIRES(Locks::mutator_lock_);
1211 GcRoot<String>* GetDexCacheStrings() SHARED_REQUIRES(Locks::mutator_lock_);
1212 void SetDexCacheStrings(GcRoot<String>* new_dex_cache_strings)
1213 SHARED_REQUIRES(Locks::mutator_lock_);
1214 static MemberOffset DexCacheStringsOffset() {
1215 return OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_strings_);
1218 // May cause thread suspension due to EqualParameters.
1219 ArtMethod* GetDeclaredConstructor(
1220 Thread* self, Handle<mirror::ObjectArray<mirror::Class>> args, size_t pointer_size)
1221 SHARED_REQUIRES(Locks::mutator_lock_);
1223 static int32_t GetInnerClassFlags(Handle<Class> h_this, int32_t default_value)
1224 SHARED_REQUIRES(Locks::mutator_lock_);
1226 // Used to initialize a class in the allocation code path to ensure it is guarded by a StoreStore
1228 class InitializeClassVisitor {
1230 explicit InitializeClassVisitor(uint32_t class_size) : class_size_(class_size) {
1233 void operator()(mirror::Object* obj, size_t usable_size) const
1234 SHARED_REQUIRES(Locks::mutator_lock_);
1237 const uint32_t class_size_;
1239 DISALLOW_COPY_AND_ASSIGN(InitializeClassVisitor);
1242 // Returns true if the class loader is null, ie the class loader is the boot strap class loader.
1243 bool IsBootStrapClassLoaded() SHARED_REQUIRES(Locks::mutator_lock_) {
1244 return GetClassLoader() == nullptr;
1247 static size_t ImTableEntrySize(size_t pointer_size) {
1248 return pointer_size;
1251 static size_t VTableEntrySize(size_t pointer_size) {
1252 return pointer_size;
1255 ALWAYS_INLINE ArraySlice<ArtMethod> GetDirectMethodsSliceUnchecked(size_t pointer_size)
1256 SHARED_REQUIRES(Locks::mutator_lock_);
1258 ALWAYS_INLINE ArraySlice<ArtMethod> GetVirtualMethodsSliceUnchecked(size_t pointer_size)
1259 SHARED_REQUIRES(Locks::mutator_lock_);
1261 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredMethodsSliceUnchecked(size_t pointer_size)
1262 SHARED_REQUIRES(Locks::mutator_lock_);
1264 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredVirtualMethodsSliceUnchecked(size_t pointer_size)
1265 SHARED_REQUIRES(Locks::mutator_lock_);
1267 ALWAYS_INLINE ArraySlice<ArtMethod> GetCopiedMethodsSliceUnchecked(size_t pointer_size)
1268 SHARED_REQUIRES(Locks::mutator_lock_);
1270 // Fix up all of the native pointers in the class by running them through the visitor. Only sets
1271 // the corresponding entry in dest if visitor(obj) != obj to prevent dirty memory. Dest should be
1272 // initialized to a copy of *this to prevent issues. Does not visit the ArtMethod and ArtField
1274 template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1275 ReadBarrierOption kReadBarrierOption = kWithReadBarrier,
1277 void FixupNativePointers(mirror::Class* dest, size_t pointer_size, const Visitor& visitor)
1278 SHARED_REQUIRES(Locks::mutator_lock_);
1281 ALWAYS_INLINE void SetMethodsPtrInternal(LengthPrefixedArray<ArtMethod>* new_methods)
1282 SHARED_REQUIRES(Locks::mutator_lock_);
1284 void SetVerifyError(Object* klass) SHARED_REQUIRES(Locks::mutator_lock_);
1286 template <bool throw_on_failure, bool use_referrers_cache>
1287 bool ResolvedFieldAccessTest(Class* access_to, ArtField* field,
1288 uint32_t field_idx, DexCache* dex_cache)
1289 SHARED_REQUIRES(Locks::mutator_lock_);
1290 template <bool throw_on_failure, bool use_referrers_cache, InvokeType throw_invoke_type>
1291 bool ResolvedMethodAccessTest(Class* access_to, ArtMethod* resolved_method,
1292 uint32_t method_idx, DexCache* dex_cache)
1293 SHARED_REQUIRES(Locks::mutator_lock_);
1295 bool Implements(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
1296 bool IsArrayAssignableFromArray(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
1297 bool IsAssignableFromArray(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
1299 void CheckObjectAlloc() SHARED_REQUIRES(Locks::mutator_lock_);
1301 // Unchecked editions is for root visiting.
1302 LengthPrefixedArray<ArtField>* GetSFieldsPtrUnchecked() SHARED_REQUIRES(Locks::mutator_lock_);
1303 IterationRange<StrideIterator<ArtField>> GetSFieldsUnchecked()
1304 SHARED_REQUIRES(Locks::mutator_lock_);
1305 LengthPrefixedArray<ArtField>* GetIFieldsPtrUnchecked() SHARED_REQUIRES(Locks::mutator_lock_);
1306 IterationRange<StrideIterator<ArtField>> GetIFieldsUnchecked()
1307 SHARED_REQUIRES(Locks::mutator_lock_);
1309 // The index in the methods_ array where the first declared virtual method is.
1310 ALWAYS_INLINE uint32_t GetVirtualMethodsStartOffset() SHARED_REQUIRES(Locks::mutator_lock_);
1312 // The index in the methods_ array where the first direct method is.
1313 ALWAYS_INLINE uint32_t GetDirectMethodsStartOffset() SHARED_REQUIRES(Locks::mutator_lock_);
1315 // The index in the methods_ array where the first copied method is.
1316 ALWAYS_INLINE uint32_t GetCopiedMethodsStartOffset() SHARED_REQUIRES(Locks::mutator_lock_);
1318 bool ProxyDescriptorEquals(const char* match) SHARED_REQUIRES(Locks::mutator_lock_);
1320 // Check that the pointer size matches the one in the class linker.
1321 ALWAYS_INLINE static void CheckPointerSize(size_t pointer_size);
1322 static MemberOffset EmbeddedVTableOffset(size_t pointer_size);
1323 template <bool kVisitNativeRoots,
1324 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1325 ReadBarrierOption kReadBarrierOption = kWithReadBarrier,
1327 void VisitReferences(mirror::Class* klass, const Visitor& visitor)
1328 SHARED_REQUIRES(Locks::mutator_lock_);
1330 // 'Class' Object Fields
1331 // Order governed by java field ordering. See art::ClassLinker::LinkFields.
1333 HeapReference<Object> annotation_type_;
1335 // Defining class loader, or null for the "bootstrap" system loader.
1336 HeapReference<ClassLoader> class_loader_;
1338 // For array classes, the component class object for instanceof/checkcast
1339 // (for String[][][], this will be String[][]). null for non-array classes.
1340 HeapReference<Class> component_type_;
1342 // DexCache of resolved constant pool entries (will be null for classes generated by the
1343 // runtime such as arrays and primitive classes).
1344 HeapReference<DexCache> dex_cache_;
1346 // The interface table (iftable_) contains pairs of a interface class and an array of the
1347 // interface methods. There is one pair per interface supported by this class. That means one
1348 // pair for each interface we support directly, indirectly via superclass, or indirectly via a
1349 // superinterface. This will be null if neither we nor our superclass implement any interfaces.
1351 // Why we need this: given "class Foo implements Face", declare "Face faceObj = new Foo()".
1352 // Invoke faceObj.blah(), where "blah" is part of the Face interface. We can't easily use a
1355 // For every interface a concrete class implements, we create an array of the concrete vtable_
1356 // methods for the methods in the interface.
1357 HeapReference<IfTable> iftable_;
1359 // Descriptor for the class such as "java.lang.Class" or "[C". Lazily initialized by ComputeName
1360 HeapReference<String> name_;
1362 // The superclass, or null if this is java.lang.Object or a primitive type.
1364 // Note that interfaces have java.lang.Object as their
1365 // superclass. This doesn't match the expectations in JNI
1366 // GetSuperClass or java.lang.Class.getSuperClass() which need to
1367 // check for interfaces and return null.
1368 HeapReference<Class> super_class_;
1370 // If class verify fails, we must return same error on subsequent tries. We may store either
1371 // the class of the error, or an actual instance of Throwable here.
1372 HeapReference<Object> verify_error_;
1374 // Virtual method table (vtable), for use by "invoke-virtual". The vtable from the superclass is
1375 // copied in, and virtual methods from our class either replace those from the super or are
1376 // appended. For abstract classes, methods may be created in the vtable that aren't in
1377 // virtual_ methods_ for miranda methods.
1378 HeapReference<PointerArray> vtable_;
1380 // Access flags; low 16 bits are defined by VM spec.
1381 uint32_t access_flags_;
1383 // Short cuts to dex_cache_ member for fast compiled code access.
1384 uint64_t dex_cache_strings_;
1388 // These describe the layout of the contents of an Object.
1389 // Note that only the fields directly declared by this class are
1390 // listed in ifields; fields declared by a superclass are listed in
1391 // the superclass's Class.ifields.
1393 // ArtFields are allocated as a length prefixed ArtField array, and not an array of pointers to
1397 // Pointer to an ArtMethod length-prefixed array. All the methods where this class is the place
1398 // where they are logically defined. This includes all private, static, final and virtual methods
1399 // as well as inherited default methods and miranda methods.
1401 // The slice methods_ [0, virtual_methods_offset_) are the direct (static, private, init) methods
1402 // declared by this class.
1404 // The slice methods_ [virtual_methods_offset_, copied_methods_offset_) are the virtual methods
1405 // declared by this class.
1407 // The slice methods_ [copied_methods_offset_, |methods_|) are the methods that are copied from
1408 // interfaces such as miranda or default methods. These are copied for resolution purposes as this
1409 // class is where they are (logically) declared as far as the virtual dispatch is concerned.
1411 // Note that this field is used by the native debugger as the unique identifier for the type.
1414 // Static fields length-prefixed array.
1417 // Class flags to help speed up visiting object references.
1418 uint32_t class_flags_;
1420 // Total size of the Class instance; used when allocating storage on gc heap.
1421 // See also object_size_.
1422 uint32_t class_size_;
1424 // Tid used to check for recursive <clinit> invocation.
1425 pid_t clinit_thread_id_;
1427 // ClassDef index in dex file, -1 if no class definition such as an array.
1428 // TODO: really 16bits
1429 int32_t dex_class_def_idx_;
1431 // Type index in dex file.
1432 // TODO: really 16bits
1433 int32_t dex_type_idx_;
1435 // Number of instance fields that are object refs.
1436 uint32_t num_reference_instance_fields_;
1438 // Number of static fields that are object refs,
1439 uint32_t num_reference_static_fields_;
1441 // Total object size; used when allocating storage on gc heap.
1442 // (For interfaces and abstract classes this will be zero.)
1443 // See also class_size_.
1444 uint32_t object_size_;
1446 // The lower 16 bits contains a Primitive::Type value. The upper 16
1447 // bits contains the size shift of the primitive type.
1448 uint32_t primitive_type_;
1450 // Bitmap of offsets of ifields.
1451 uint32_t reference_instance_offsets_;
1453 // State of class initialization.
1456 // The offset of the first virtual method that is copied from an interface. This includes miranda,
1457 // default, and default-conflict methods. Having a hard limit of ((2 << 16) - 1) for methods
1458 // defined on a single class is well established in Java so we will use only uint16_t's here.
1459 uint16_t copied_methods_offset_;
1461 // The offset of the first declared virtual methods in the methods_ array.
1462 uint16_t virtual_methods_offset_;
1465 // initiating class loader list
1466 // NOTE: for classes with low serialNumber, these are unused, and the
1467 // values are kept in a table in gDvm.
1468 // InitiatingLoaderList initiating_loader_list_;
1470 // The following data exist in real class objects.
1471 // Embedded Imtable, for class object that's not an interface, fixed size.
1472 // ImTableEntry embedded_imtable_[0];
1473 // Embedded Vtable, for class object that's not an interface, variable size.
1474 // VTableEntry embedded_vtable_[0];
1475 // Static fields, variable size.
1476 // uint32_t fields_[0];
1479 static GcRoot<Class> java_lang_Class_;
1481 friend struct art::ClassOffsets; // for verifying offset information
1482 friend class Object; // For VisitReferences
1483 DISALLOW_IMPLICIT_CONSTRUCTORS(Class);
1486 std::ostream& operator<<(std::ostream& os, const Class::Status& rhs);
1488 } // namespace mirror
1491 #endif // ART_RUNTIME_MIRROR_CLASS_H_