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"
25 #include "invoke_type.h"
26 #include "modifiers.h"
28 #include "object_array.h"
29 #include "object_callbacks.h"
30 #include "primitive.h"
31 #include "read_barrier_option.h"
32 #include "stride_iterator.h"
37 #error IMT_SIZE not defined
45 template<class T> class Handle;
46 template<typename T> class LengthPrefixedArray;
47 template<typename T> class ArraySlice;
50 template<size_t kNumReferences> class PACKED(4) StackHandleScope;
60 // C++ mirror of java.lang.Class
61 class MANAGED Class FINAL : public Object {
63 // A magic value for reference_instance_offsets_. Ignore the bits and walk the super chain when
65 // [This is an unlikely "natural" value, since it would be 30 non-ref instance fields followed by
66 // 2 ref instance fields.]
67 static constexpr uint32_t kClassWalkSuper = 0xC0000000;
69 // Interface method table size. Increasing this value reduces the chance of two interface methods
70 // colliding in the interface method table but increases the size of classes that implement
71 // (non-marker) interfaces.
72 static constexpr size_t kImtSize = IMT_SIZE;
76 // kStatusRetired: Class that's temporarily used till class linking time
77 // has its (vtable) size figured out and has been cloned to one with the
78 // right size which will be the one used later. The old one is retired and
79 // will be gc'ed once all refs to the class point to the newly
82 // kStatusNotReady: If a Class cannot be found in the class table by
83 // FindClass, it allocates an new one with AllocClass in the
84 // kStatusNotReady and calls LoadClass. Note if it does find a
85 // class, it may not be kStatusResolved and it will try to push it
86 // forward toward kStatusResolved.
88 // kStatusIdx: LoadClass populates with Class with information from
89 // the DexFile, moving the status to kStatusIdx, indicating that the
90 // Class value in super_class_ has not been populated. The new Class
91 // can then be inserted into the classes table.
93 // kStatusLoaded: After taking a lock on Class, the ClassLinker will
94 // attempt to move a kStatusIdx class forward to kStatusLoaded by
95 // using ResolveClass to initialize the super_class_ and ensuring the
96 // interfaces are resolved.
98 // kStatusResolving: Class is just cloned with the right size from
99 // temporary class that's acting as a placeholder for linking. The old
100 // class will be retired. New class is set to this status first before
101 // moving on to being resolved.
103 // kStatusResolved: Still holding the lock on Class, the ClassLinker
104 // shows linking is complete and fields of the Class populated by making
105 // it kStatusResolved. Java allows circularities of the form where a super
106 // class has a field that is of the type of the sub class. We need to be able
107 // to fully resolve super classes while resolving types for fields.
109 // kStatusRetryVerificationAtRuntime: The verifier sets a class to
110 // this state if it encounters a soft failure at compile time. This
111 // often happens when there are unresolved classes in other dex
112 // files, and this status marks a class as needing to be verified
115 // TODO: Explain the other states
117 kStatusRetired = -2, // Retired, should not be used. Use the newly cloned one instead.
120 kStatusIdx = 1, // Loaded, DEX idx in super_class_type_idx_ and interfaces_type_idx_.
121 kStatusLoaded = 2, // DEX idx values resolved.
122 kStatusResolving = 3, // Just cloned from temporary class object.
123 kStatusResolved = 4, // Part of linking.
124 kStatusVerifying = 5, // In the process of being verified.
125 kStatusRetryVerificationAtRuntime = 6, // Compile time verification failed, retry at runtime.
126 kStatusVerifyingAtRuntime = 7, // Retrying verification at runtime.
127 kStatusVerified = 8, // Logically part of linking; done pre-init.
128 kStatusInitializing = 9, // Class init in progress.
129 kStatusInitialized = 10, // Ready to go.
133 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
134 Status GetStatus() SHARED_REQUIRES(Locks::mutator_lock_) {
135 static_assert(sizeof(Status) == sizeof(uint32_t), "Size of status not equal to uint32");
136 return static_cast<Status>(
137 GetField32Volatile<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, status_)));
140 // This is static because 'this' may be moved by GC.
141 static void SetStatus(Handle<Class> h_this, Status new_status, Thread* self)
142 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
144 static MemberOffset StatusOffset() {
145 return OFFSET_OF_OBJECT_MEMBER(Class, status_);
148 // Returns true if the class has been retired.
149 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
150 bool IsRetired() SHARED_REQUIRES(Locks::mutator_lock_) {
151 return GetStatus<kVerifyFlags>() == kStatusRetired;
154 // Returns true if the class has failed to link.
155 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
156 bool IsErroneous() SHARED_REQUIRES(Locks::mutator_lock_) {
157 return GetStatus<kVerifyFlags>() == kStatusError;
160 // Returns true if the class has been loaded.
161 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
162 bool IsIdxLoaded() SHARED_REQUIRES(Locks::mutator_lock_) {
163 return GetStatus<kVerifyFlags>() >= kStatusIdx;
166 // Returns true if the class has been loaded.
167 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
168 bool IsLoaded() SHARED_REQUIRES(Locks::mutator_lock_) {
169 return GetStatus<kVerifyFlags>() >= kStatusLoaded;
172 // Returns true if the class has been linked.
173 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
174 bool IsResolved() SHARED_REQUIRES(Locks::mutator_lock_) {
175 return GetStatus<kVerifyFlags>() >= kStatusResolved;
178 // Returns true if the class was compile-time verified.
179 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
180 bool IsCompileTimeVerified() SHARED_REQUIRES(Locks::mutator_lock_) {
181 return GetStatus<kVerifyFlags>() >= kStatusRetryVerificationAtRuntime;
184 // Returns true if the class has been verified.
185 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
186 bool IsVerified() SHARED_REQUIRES(Locks::mutator_lock_) {
187 return GetStatus<kVerifyFlags>() >= kStatusVerified;
190 // Returns true if the class is initializing.
191 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
192 bool IsInitializing() SHARED_REQUIRES(Locks::mutator_lock_) {
193 return GetStatus<kVerifyFlags>() >= kStatusInitializing;
196 // Returns true if the class is initialized.
197 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
198 bool IsInitialized() SHARED_REQUIRES(Locks::mutator_lock_) {
199 return GetStatus<kVerifyFlags>() == kStatusInitialized;
202 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
203 ALWAYS_INLINE uint32_t GetAccessFlags() SHARED_REQUIRES(Locks::mutator_lock_);
204 static MemberOffset AccessFlagsOffset() {
205 return OFFSET_OF_OBJECT_MEMBER(Class, access_flags_);
208 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
209 ALWAYS_INLINE uint32_t GetClassFlags() SHARED_REQUIRES(Locks::mutator_lock_) {
210 return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_flags_));
212 void SetClassFlags(uint32_t new_flags) SHARED_REQUIRES(Locks::mutator_lock_);
214 void SetAccessFlags(uint32_t new_access_flags) SHARED_REQUIRES(Locks::mutator_lock_);
216 // Returns true if the class is an interface.
217 ALWAYS_INLINE bool IsInterface() SHARED_REQUIRES(Locks::mutator_lock_) {
218 return (GetAccessFlags() & kAccInterface) != 0;
221 // Returns true if the class is declared public.
222 ALWAYS_INLINE bool IsPublic() SHARED_REQUIRES(Locks::mutator_lock_) {
223 return (GetAccessFlags() & kAccPublic) != 0;
226 // Returns true if the class is declared final.
227 ALWAYS_INLINE bool IsFinal() SHARED_REQUIRES(Locks::mutator_lock_) {
228 return (GetAccessFlags() & kAccFinal) != 0;
231 ALWAYS_INLINE bool IsFinalizable() SHARED_REQUIRES(Locks::mutator_lock_) {
232 return (GetAccessFlags() & kAccClassIsFinalizable) != 0;
235 ALWAYS_INLINE void SetRecursivelyInitialized() SHARED_REQUIRES(Locks::mutator_lock_) {
236 DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId());
237 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
238 SetAccessFlags(flags | kAccRecursivelyInitialized);
241 ALWAYS_INLINE void SetHasDefaultMethods() SHARED_REQUIRES(Locks::mutator_lock_) {
242 DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId());
243 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
244 SetAccessFlags(flags | kAccHasDefaultMethod);
247 ALWAYS_INLINE void SetFinalizable() SHARED_REQUIRES(Locks::mutator_lock_) {
248 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
249 SetAccessFlags(flags | kAccClassIsFinalizable);
252 ALWAYS_INLINE bool IsStringClass() SHARED_REQUIRES(Locks::mutator_lock_) {
253 return (GetClassFlags() & kClassFlagString) != 0;
256 ALWAYS_INLINE void SetStringClass() SHARED_REQUIRES(Locks::mutator_lock_) {
257 SetClassFlags(kClassFlagString | kClassFlagNoReferenceFields);
260 ALWAYS_INLINE bool IsClassLoaderClass() SHARED_REQUIRES(Locks::mutator_lock_) {
261 return GetClassFlags() == kClassFlagClassLoader;
264 ALWAYS_INLINE void SetClassLoaderClass() SHARED_REQUIRES(Locks::mutator_lock_) {
265 SetClassFlags(kClassFlagClassLoader);
268 ALWAYS_INLINE bool IsDexCacheClass() SHARED_REQUIRES(Locks::mutator_lock_) {
269 return (GetClassFlags() & kClassFlagDexCache) != 0;
272 ALWAYS_INLINE void SetDexCacheClass() SHARED_REQUIRES(Locks::mutator_lock_) {
273 SetClassFlags(GetClassFlags() | kClassFlagDexCache);
276 // Returns true if the class is abstract.
277 ALWAYS_INLINE bool IsAbstract() SHARED_REQUIRES(Locks::mutator_lock_) {
278 return (GetAccessFlags() & kAccAbstract) != 0;
281 // Returns true if the class is an annotation.
282 ALWAYS_INLINE bool IsAnnotation() SHARED_REQUIRES(Locks::mutator_lock_) {
283 return (GetAccessFlags() & kAccAnnotation) != 0;
286 // Returns true if the class is synthetic.
287 ALWAYS_INLINE bool IsSynthetic() SHARED_REQUIRES(Locks::mutator_lock_) {
288 return (GetAccessFlags() & kAccSynthetic) != 0;
291 // Return whether the class had run the verifier at least once.
292 // This does not necessarily mean that access checks are avoidable,
293 // since the class methods might still need to be run with access checks.
294 bool WasVerificationAttempted() SHARED_REQUIRES(Locks::mutator_lock_) {
295 return (GetAccessFlags() & kAccSkipAccessChecks) != 0;
298 // Mark the class as having gone through a verification attempt.
299 // Mutually exclusive from whether or not each method is allowed to skip access checks.
300 void SetVerificationAttempted() SHARED_REQUIRES(Locks::mutator_lock_) {
301 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
302 if ((flags & kAccVerificationAttempted) == 0) {
303 SetAccessFlags(flags | kAccVerificationAttempted);
307 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
308 bool IsTypeOfReferenceClass() SHARED_REQUIRES(Locks::mutator_lock_) {
309 return (GetClassFlags<kVerifyFlags>() & kClassFlagReference) != 0;
312 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
313 bool IsWeakReferenceClass() SHARED_REQUIRES(Locks::mutator_lock_) {
314 return GetClassFlags<kVerifyFlags>() == kClassFlagWeakReference;
317 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
318 bool IsSoftReferenceClass() SHARED_REQUIRES(Locks::mutator_lock_) {
319 return GetClassFlags<kVerifyFlags>() == kClassFlagSoftReference;
322 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
323 bool IsFinalizerReferenceClass() SHARED_REQUIRES(Locks::mutator_lock_) {
324 return GetClassFlags<kVerifyFlags>() == kClassFlagFinalizerReference;
327 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
328 bool IsPhantomReferenceClass() SHARED_REQUIRES(Locks::mutator_lock_) {
329 return GetClassFlags<kVerifyFlags>() == kClassFlagPhantomReference;
332 // Can references of this type be assigned to by things of another type? For non-array types
333 // this is a matter of whether sub-classes may exist - which they can't if the type is final.
334 // For array classes, where all the classes are final due to there being no sub-classes, an
335 // Object[] may be assigned to by a String[] but a String[] may not be assigned to by other
336 // types as the component is final.
337 bool CannotBeAssignedFromOtherTypes() SHARED_REQUIRES(Locks::mutator_lock_) {
338 if (!IsArrayClass()) {
341 Class* component = GetComponentType();
342 if (component->IsPrimitive()) {
345 return component->CannotBeAssignedFromOtherTypes();
350 // Returns true if this class is the placeholder and should retire and
351 // be replaced with a class with the right size for embedded imt/vtable.
352 bool IsTemp() SHARED_REQUIRES(Locks::mutator_lock_) {
353 Status s = GetStatus();
354 return s < Status::kStatusResolving && ShouldHaveEmbeddedImtAndVTable();
357 String* GetName() SHARED_REQUIRES(Locks::mutator_lock_); // Returns the cached name.
358 void SetName(String* name) SHARED_REQUIRES(Locks::mutator_lock_); // Sets the cached name.
359 // Computes the name, then sets the cached value.
360 static String* ComputeName(Handle<Class> h_this) SHARED_REQUIRES(Locks::mutator_lock_)
361 REQUIRES(!Roles::uninterruptible_);
363 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
364 bool IsProxyClass() SHARED_REQUIRES(Locks::mutator_lock_) {
365 // Read access flags without using getter as whether something is a proxy can be check in
367 // TODO: switch to a check if the super class is java.lang.reflect.Proxy?
368 uint32_t access_flags = GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
369 return (access_flags & kAccClassIsProxy) != 0;
372 static MemberOffset PrimitiveTypeOffset() {
373 return OFFSET_OF_OBJECT_MEMBER(Class, primitive_type_);
376 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
377 Primitive::Type GetPrimitiveType() ALWAYS_INLINE SHARED_REQUIRES(Locks::mutator_lock_);
379 void SetPrimitiveType(Primitive::Type new_type) SHARED_REQUIRES(Locks::mutator_lock_) {
380 DCHECK_EQ(sizeof(Primitive::Type), sizeof(int32_t));
381 int32_t v32 = static_cast<int32_t>(new_type);
382 DCHECK_EQ(v32 & 0xFFFF, v32) << "upper 16 bits aren't zero";
383 // Store the component size shift in the upper 16 bits.
384 v32 |= Primitive::ComponentSizeShift(new_type) << 16;
385 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, primitive_type_), v32);
388 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
389 size_t GetPrimitiveTypeSizeShift() ALWAYS_INLINE SHARED_REQUIRES(Locks::mutator_lock_);
391 // Returns true if the class is a primitive type.
392 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
393 bool IsPrimitive() SHARED_REQUIRES(Locks::mutator_lock_) {
394 return GetPrimitiveType<kVerifyFlags>() != Primitive::kPrimNot;
397 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
398 bool IsPrimitiveBoolean() SHARED_REQUIRES(Locks::mutator_lock_) {
399 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimBoolean;
402 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
403 bool IsPrimitiveByte() SHARED_REQUIRES(Locks::mutator_lock_) {
404 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimByte;
407 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
408 bool IsPrimitiveChar() SHARED_REQUIRES(Locks::mutator_lock_) {
409 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimChar;
412 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
413 bool IsPrimitiveShort() SHARED_REQUIRES(Locks::mutator_lock_) {
414 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimShort;
417 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
418 bool IsPrimitiveInt() SHARED_REQUIRES(Locks::mutator_lock_) {
419 return GetPrimitiveType() == Primitive::kPrimInt;
422 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
423 bool IsPrimitiveLong() SHARED_REQUIRES(Locks::mutator_lock_) {
424 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimLong;
427 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
428 bool IsPrimitiveFloat() SHARED_REQUIRES(Locks::mutator_lock_) {
429 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimFloat;
432 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
433 bool IsPrimitiveDouble() SHARED_REQUIRES(Locks::mutator_lock_) {
434 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimDouble;
437 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
438 bool IsPrimitiveVoid() SHARED_REQUIRES(Locks::mutator_lock_) {
439 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimVoid;
442 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
443 bool IsPrimitiveArray() SHARED_REQUIRES(Locks::mutator_lock_) {
444 return IsArrayClass<kVerifyFlags>() &&
445 GetComponentType<static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis)>()->
449 // Depth of class from java.lang.Object
450 uint32_t Depth() SHARED_REQUIRES(Locks::mutator_lock_);
452 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
453 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
454 bool IsArrayClass() SHARED_REQUIRES(Locks::mutator_lock_);
456 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
457 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
458 bool IsClassClass() SHARED_REQUIRES(Locks::mutator_lock_);
460 bool IsThrowableClass() SHARED_REQUIRES(Locks::mutator_lock_);
462 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
463 bool IsReferenceClass() const SHARED_REQUIRES(Locks::mutator_lock_);
465 static MemberOffset ComponentTypeOffset() {
466 return OFFSET_OF_OBJECT_MEMBER(Class, component_type_);
469 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
470 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
471 Class* GetComponentType() SHARED_REQUIRES(Locks::mutator_lock_);
473 void SetComponentType(Class* new_component_type) SHARED_REQUIRES(Locks::mutator_lock_) {
474 DCHECK(GetComponentType() == nullptr);
475 DCHECK(new_component_type != nullptr);
476 // Component type is invariant: use non-transactional mode without check.
477 SetFieldObject<false, false>(ComponentTypeOffset(), new_component_type);
480 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
481 size_t GetComponentSize() SHARED_REQUIRES(Locks::mutator_lock_) {
482 return 1U << GetComponentSizeShift();
485 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
486 size_t GetComponentSizeShift() SHARED_REQUIRES(Locks::mutator_lock_) {
487 return GetComponentType<kDefaultVerifyFlags, kReadBarrierOption>()->GetPrimitiveTypeSizeShift();
490 bool IsObjectClass() SHARED_REQUIRES(Locks::mutator_lock_) {
491 return !IsPrimitive() && GetSuperClass() == nullptr;
494 bool IsInstantiableNonArray() SHARED_REQUIRES(Locks::mutator_lock_) {
495 return !IsPrimitive() && !IsInterface() && !IsAbstract() && !IsArrayClass();
498 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
499 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
500 bool IsInstantiable() SHARED_REQUIRES(Locks::mutator_lock_) {
501 return (!IsPrimitive() && !IsInterface() && !IsAbstract()) ||
502 (IsAbstract() && IsArrayClass<kVerifyFlags, kReadBarrierOption>());
505 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
506 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
507 bool IsObjectArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) {
508 mirror::Class* const component_type = GetComponentType<kVerifyFlags, kReadBarrierOption>();
509 return component_type != nullptr && !component_type->IsPrimitive();
512 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
513 bool IsIntArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) {
514 constexpr auto kNewFlags = static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis);
515 auto* component_type = GetComponentType<kVerifyFlags>();
516 return component_type != nullptr && component_type->template IsPrimitiveInt<kNewFlags>();
519 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
520 bool IsLongArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) {
521 constexpr auto kNewFlags = static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis);
522 auto* component_type = GetComponentType<kVerifyFlags>();
523 return component_type != nullptr && component_type->template IsPrimitiveLong<kNewFlags>();
526 // Creates a raw object instance but does not invoke the default constructor.
527 template<bool kIsInstrumented, bool kCheckAddFinalizer = true>
528 ALWAYS_INLINE Object* Alloc(Thread* self, gc::AllocatorType allocator_type)
529 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
531 Object* AllocObject(Thread* self)
532 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
533 Object* AllocNonMovableObject(Thread* self)
534 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
536 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
537 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
538 bool IsVariableSize() SHARED_REQUIRES(Locks::mutator_lock_) {
539 // Classes, arrays, and strings vary in size, and so the object_size_ field cannot
540 // be used to Get their instance size
541 return IsClassClass<kVerifyFlags, kReadBarrierOption>() ||
542 IsArrayClass<kVerifyFlags, kReadBarrierOption>() || IsStringClass();
545 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
546 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
547 uint32_t SizeOf() SHARED_REQUIRES(Locks::mutator_lock_) {
548 return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_size_));
551 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
552 uint32_t GetClassSize() SHARED_REQUIRES(Locks::mutator_lock_) {
553 return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_size_));
556 void SetClassSize(uint32_t new_class_size)
557 SHARED_REQUIRES(Locks::mutator_lock_);
559 // Compute how many bytes would be used a class with the given elements.
560 static uint32_t ComputeClassSize(bool has_embedded_tables,
561 uint32_t num_vtable_entries,
562 uint32_t num_8bit_static_fields,
563 uint32_t num_16bit_static_fields,
564 uint32_t num_32bit_static_fields,
565 uint32_t num_64bit_static_fields,
566 uint32_t num_ref_static_fields,
567 size_t pointer_size);
569 // The size of java.lang.Class.class.
570 static uint32_t ClassClassSize(size_t pointer_size) {
571 // The number of vtable entries in java.lang.Class.
572 uint32_t vtable_entries = Object::kVTableLength + 72;
573 return ComputeClassSize(true, vtable_entries, 0, 0, 4, 1, 0, pointer_size);
576 // The size of a java.lang.Class representing a primitive such as int.class.
577 static uint32_t PrimitiveClassSize(size_t pointer_size) {
578 return ComputeClassSize(false, 0, 0, 0, 0, 0, 0, pointer_size);
581 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
582 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
583 uint32_t GetObjectSize() SHARED_REQUIRES(Locks::mutator_lock_);
584 static MemberOffset ObjectSizeOffset() {
585 return OFFSET_OF_OBJECT_MEMBER(Class, object_size_);
588 void SetObjectSize(uint32_t new_object_size) SHARED_REQUIRES(Locks::mutator_lock_) {
589 DCHECK(!IsVariableSize());
590 // Not called within a transaction.
591 return SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, object_size_), new_object_size);
594 void SetObjectSizeWithoutChecks(uint32_t new_object_size)
595 SHARED_REQUIRES(Locks::mutator_lock_) {
596 // Not called within a transaction.
597 return SetField32<false, false, kVerifyNone>(
598 OFFSET_OF_OBJECT_MEMBER(Class, object_size_), new_object_size);
601 // Returns true if this class is in the same packages as that class.
602 bool IsInSamePackage(Class* that) SHARED_REQUIRES(Locks::mutator_lock_);
604 static bool IsInSamePackage(const StringPiece& descriptor1, const StringPiece& descriptor2);
606 // Returns true if this class can access that class.
607 bool CanAccess(Class* that) SHARED_REQUIRES(Locks::mutator_lock_) {
608 return that->IsPublic() || this->IsInSamePackage(that);
611 // Can this class access a member in the provided class with the provided member access flags?
612 // Note that access to the class isn't checked in case the declaring class is protected and the
613 // method has been exposed by a public sub-class
614 bool CanAccessMember(Class* access_to, uint32_t member_flags)
615 SHARED_REQUIRES(Locks::mutator_lock_) {
616 // Classes can access all of their own members
617 if (this == access_to) {
620 // Public members are trivially accessible
621 if (member_flags & kAccPublic) {
624 // Private members are trivially not accessible
625 if (member_flags & kAccPrivate) {
628 // Check for protected access from a sub-class, which may or may not be in the same package.
629 if (member_flags & kAccProtected) {
630 if (!this->IsInterface() && this->IsSubClass(access_to)) {
634 // Allow protected access from other classes in the same package.
635 return this->IsInSamePackage(access_to);
638 // Can this class access a resolved field?
639 // Note that access to field's class is checked and this may require looking up the class
640 // referenced by the FieldId in the DexFile in case the declaring class is inaccessible.
641 bool CanAccessResolvedField(Class* access_to, ArtField* field,
642 DexCache* dex_cache, uint32_t field_idx)
643 SHARED_REQUIRES(Locks::mutator_lock_);
644 bool CheckResolvedFieldAccess(Class* access_to, ArtField* field,
646 SHARED_REQUIRES(Locks::mutator_lock_);
648 // Can this class access a resolved method?
649 // Note that access to methods's class is checked and this may require looking up the class
650 // referenced by the MethodId in the DexFile in case the declaring class is inaccessible.
651 bool CanAccessResolvedMethod(Class* access_to, ArtMethod* resolved_method,
652 DexCache* dex_cache, uint32_t method_idx)
653 SHARED_REQUIRES(Locks::mutator_lock_);
654 template <InvokeType throw_invoke_type>
655 bool CheckResolvedMethodAccess(Class* access_to, ArtMethod* resolved_method,
657 SHARED_REQUIRES(Locks::mutator_lock_);
659 bool IsSubClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
661 // Can src be assigned to this class? For example, String can be assigned to Object (by an
662 // upcast), however, an Object cannot be assigned to a String as a potentially exception throwing
663 // downcast would be necessary. Similarly for interfaces, a class that implements (or an interface
664 // that extends) another can be assigned to its parent, but not vice-versa. All Classes may assign
665 // to themselves. Classes for primitive types may not assign to each other.
666 ALWAYS_INLINE bool IsAssignableFrom(Class* src) SHARED_REQUIRES(Locks::mutator_lock_);
668 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
669 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
670 ALWAYS_INLINE Class* GetSuperClass() SHARED_REQUIRES(Locks::mutator_lock_);
672 // Get first common super class. It will never return null.
673 // `This` and `klass` must be classes.
674 Class* GetCommonSuperClass(Handle<Class> klass) SHARED_REQUIRES(Locks::mutator_lock_);
676 void SetSuperClass(Class *new_super_class) SHARED_REQUIRES(Locks::mutator_lock_) {
677 // Super class is assigned once, except during class linker initialization.
678 Class* old_super_class = GetFieldObject<Class>(OFFSET_OF_OBJECT_MEMBER(Class, super_class_));
679 DCHECK(old_super_class == nullptr || old_super_class == new_super_class);
680 DCHECK(new_super_class != nullptr);
681 SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(Class, super_class_), new_super_class);
684 bool HasSuperClass() SHARED_REQUIRES(Locks::mutator_lock_) {
685 return GetSuperClass() != nullptr;
688 static MemberOffset SuperClassOffset() {
689 return MemberOffset(OFFSETOF_MEMBER(Class, super_class_));
692 ClassLoader* GetClassLoader() ALWAYS_INLINE SHARED_REQUIRES(Locks::mutator_lock_);
694 void SetClassLoader(ClassLoader* new_cl) SHARED_REQUIRES(Locks::mutator_lock_);
696 static MemberOffset DexCacheOffset() {
697 return MemberOffset(OFFSETOF_MEMBER(Class, dex_cache_));
701 kDumpClassFullDetail = 1,
702 kDumpClassClassLoader = (1 << 1),
703 kDumpClassInitialized = (1 << 2),
706 void DumpClass(std::ostream& os, int flags) SHARED_REQUIRES(Locks::mutator_lock_);
708 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
709 DexCache* GetDexCache() SHARED_REQUIRES(Locks::mutator_lock_);
711 // Also updates the dex_cache_strings_ variable from new_dex_cache.
712 void SetDexCache(DexCache* new_dex_cache) SHARED_REQUIRES(Locks::mutator_lock_);
714 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetDirectMethods(size_t pointer_size)
715 SHARED_REQUIRES(Locks::mutator_lock_);
717 ALWAYS_INLINE LengthPrefixedArray<ArtMethod>* GetMethodsPtr()
718 SHARED_REQUIRES(Locks::mutator_lock_);
720 static MemberOffset MethodsOffset() {
721 return MemberOffset(OFFSETOF_MEMBER(Class, methods_));
724 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetMethods(size_t pointer_size)
725 SHARED_REQUIRES(Locks::mutator_lock_);
727 void SetMethodsPtr(LengthPrefixedArray<ArtMethod>* new_methods,
729 uint32_t num_virtual)
730 SHARED_REQUIRES(Locks::mutator_lock_);
731 // Used by image writer.
732 void SetMethodsPtrUnchecked(LengthPrefixedArray<ArtMethod>* new_methods,
734 uint32_t num_virtual)
735 SHARED_REQUIRES(Locks::mutator_lock_);
737 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
738 ALWAYS_INLINE ArraySlice<ArtMethod> GetDirectMethodsSlice(size_t pointer_size)
739 SHARED_REQUIRES(Locks::mutator_lock_);
741 ALWAYS_INLINE ArtMethod* GetDirectMethod(size_t i, size_t pointer_size)
742 SHARED_REQUIRES(Locks::mutator_lock_);
744 // Use only when we are allocating populating the method arrays.
745 ALWAYS_INLINE ArtMethod* GetDirectMethodUnchecked(size_t i, size_t pointer_size)
746 SHARED_REQUIRES(Locks::mutator_lock_);
747 ALWAYS_INLINE ArtMethod* GetVirtualMethodUnchecked(size_t i, size_t pointer_size)
748 SHARED_REQUIRES(Locks::mutator_lock_);
750 // Returns the number of static, private, and constructor methods.
751 ALWAYS_INLINE uint32_t NumDirectMethods() SHARED_REQUIRES(Locks::mutator_lock_);
753 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
754 ALWAYS_INLINE ArraySlice<ArtMethod> GetMethodsSlice(size_t pointer_size)
755 SHARED_REQUIRES(Locks::mutator_lock_);
757 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
758 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredMethodsSlice(size_t pointer_size)
759 SHARED_REQUIRES(Locks::mutator_lock_);
761 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetDeclaredMethods(
763 SHARED_REQUIRES(Locks::mutator_lock_);
765 template <bool kTransactionActive = false>
766 static Method* GetDeclaredMethodInternal(Thread* self,
767 mirror::Class* klass,
768 mirror::String* name,
769 mirror::ObjectArray<mirror::Class>* args)
770 SHARED_REQUIRES(Locks::mutator_lock_);
771 template <bool kTransactionActive = false>
772 static Constructor* GetDeclaredConstructorInternal(Thread* self,
773 mirror::Class* klass,
774 mirror::ObjectArray<mirror::Class>* args)
775 SHARED_REQUIRES(Locks::mutator_lock_);
777 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
778 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredVirtualMethodsSlice(size_t pointer_size)
779 SHARED_REQUIRES(Locks::mutator_lock_);
781 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetDeclaredVirtualMethods(
783 SHARED_REQUIRES(Locks::mutator_lock_);
785 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
786 ALWAYS_INLINE ArraySlice<ArtMethod> GetCopiedMethodsSlice(size_t pointer_size)
787 SHARED_REQUIRES(Locks::mutator_lock_);
789 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetCopiedMethods(size_t pointer_size)
790 SHARED_REQUIRES(Locks::mutator_lock_);
792 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
793 ALWAYS_INLINE ArraySlice<ArtMethod> GetVirtualMethodsSlice(size_t pointer_size)
794 SHARED_REQUIRES(Locks::mutator_lock_);
796 ALWAYS_INLINE IterationRange<StrideIterator<ArtMethod>> GetVirtualMethods(size_t pointer_size)
797 SHARED_REQUIRES(Locks::mutator_lock_);
799 // Returns the number of non-inherited virtual methods (sum of declared and copied methods).
800 ALWAYS_INLINE uint32_t NumVirtualMethods() SHARED_REQUIRES(Locks::mutator_lock_);
802 // Returns the number of copied virtual methods.
803 ALWAYS_INLINE uint32_t NumCopiedVirtualMethods() SHARED_REQUIRES(Locks::mutator_lock_);
805 // Returns the number of declared virtual methods.
806 ALWAYS_INLINE uint32_t NumDeclaredVirtualMethods() SHARED_REQUIRES(Locks::mutator_lock_);
808 ALWAYS_INLINE uint32_t NumMethods() SHARED_REQUIRES(Locks::mutator_lock_);
810 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
811 ArtMethod* GetVirtualMethod(size_t i, size_t pointer_size)
812 SHARED_REQUIRES(Locks::mutator_lock_);
814 ArtMethod* GetVirtualMethodDuringLinking(size_t i, size_t pointer_size)
815 SHARED_REQUIRES(Locks::mutator_lock_);
817 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
818 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
819 ALWAYS_INLINE PointerArray* GetVTable() SHARED_REQUIRES(Locks::mutator_lock_);
821 ALWAYS_INLINE PointerArray* GetVTableDuringLinking() SHARED_REQUIRES(Locks::mutator_lock_);
823 void SetVTable(PointerArray* new_vtable) SHARED_REQUIRES(Locks::mutator_lock_);
825 static MemberOffset VTableOffset() {
826 return OFFSET_OF_OBJECT_MEMBER(Class, vtable_);
829 static MemberOffset EmbeddedVTableLengthOffset() {
830 return MemberOffset(sizeof(Class));
833 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
834 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
835 bool ShouldHaveEmbeddedImtAndVTable() SHARED_REQUIRES(Locks::mutator_lock_) {
836 return IsInstantiable<kVerifyFlags, kReadBarrierOption>();
839 bool HasVTable() SHARED_REQUIRES(Locks::mutator_lock_);
841 static MemberOffset EmbeddedImTableEntryOffset(uint32_t i, size_t pointer_size);
843 static MemberOffset EmbeddedVTableEntryOffset(uint32_t i, size_t pointer_size);
845 template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
846 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
847 ArtMethod* GetEmbeddedImTableEntry(uint32_t i, size_t pointer_size)
848 SHARED_REQUIRES(Locks::mutator_lock_);
850 template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
851 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
852 void SetEmbeddedImTableEntry(uint32_t i, ArtMethod* method, size_t pointer_size)
853 SHARED_REQUIRES(Locks::mutator_lock_);
855 int32_t GetVTableLength() SHARED_REQUIRES(Locks::mutator_lock_);
857 ArtMethod* GetVTableEntry(uint32_t i, size_t pointer_size)
858 SHARED_REQUIRES(Locks::mutator_lock_);
860 int32_t GetEmbeddedVTableLength() SHARED_REQUIRES(Locks::mutator_lock_);
862 void SetEmbeddedVTableLength(int32_t len) SHARED_REQUIRES(Locks::mutator_lock_);
864 ArtMethod* GetEmbeddedVTableEntry(uint32_t i, size_t pointer_size)
865 SHARED_REQUIRES(Locks::mutator_lock_);
867 void SetEmbeddedVTableEntry(uint32_t i, ArtMethod* method, size_t pointer_size)
868 SHARED_REQUIRES(Locks::mutator_lock_);
870 inline void SetEmbeddedVTableEntryUnchecked(uint32_t i, ArtMethod* method, size_t pointer_size)
871 SHARED_REQUIRES(Locks::mutator_lock_);
873 void PopulateEmbeddedImtAndVTable(ArtMethod* const (&methods)[kImtSize], size_t pointer_size)
874 SHARED_REQUIRES(Locks::mutator_lock_);
876 // Given a method implemented by this class but potentially from a super class, return the
877 // specific implementation method for this class.
878 ArtMethod* FindVirtualMethodForVirtual(ArtMethod* method, size_t pointer_size)
879 SHARED_REQUIRES(Locks::mutator_lock_);
881 // Given a method implemented by this class' super class, return the specific implementation
882 // method for this class.
883 ArtMethod* FindVirtualMethodForSuper(ArtMethod* method, size_t pointer_size)
884 SHARED_REQUIRES(Locks::mutator_lock_);
886 // Given a method from some implementor of this interface, return the specific implementation
887 // method for this class.
888 ArtMethod* FindVirtualMethodForInterfaceSuper(ArtMethod* method, size_t pointer_size)
889 SHARED_REQUIRES(Locks::mutator_lock_);
891 // Given a method implemented by this class, but potentially from a
892 // super class or interface, return the specific implementation
893 // method for this class.
894 ArtMethod* FindVirtualMethodForInterface(ArtMethod* method, size_t pointer_size)
895 SHARED_REQUIRES(Locks::mutator_lock_) ALWAYS_INLINE;
897 ArtMethod* FindVirtualMethodForVirtualOrInterface(ArtMethod* method, size_t pointer_size)
898 SHARED_REQUIRES(Locks::mutator_lock_);
900 ArtMethod* FindInterfaceMethod(const StringPiece& name, const StringPiece& signature,
902 SHARED_REQUIRES(Locks::mutator_lock_);
904 ArtMethod* FindInterfaceMethod(const StringPiece& name, const Signature& signature,
906 SHARED_REQUIRES(Locks::mutator_lock_);
908 ArtMethod* FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx,
910 SHARED_REQUIRES(Locks::mutator_lock_);
912 ArtMethod* FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature,
914 SHARED_REQUIRES(Locks::mutator_lock_);
916 ArtMethod* FindDeclaredDirectMethod(const StringPiece& name, const Signature& signature,
918 SHARED_REQUIRES(Locks::mutator_lock_);
920 ArtMethod* FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx,
922 SHARED_REQUIRES(Locks::mutator_lock_);
924 ArtMethod* FindDirectMethod(const StringPiece& name, const StringPiece& signature,
926 SHARED_REQUIRES(Locks::mutator_lock_);
928 ArtMethod* FindDirectMethod(const StringPiece& name, const Signature& signature,
930 SHARED_REQUIRES(Locks::mutator_lock_);
932 ArtMethod* FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx,
934 SHARED_REQUIRES(Locks::mutator_lock_);
936 ArtMethod* FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature,
938 SHARED_REQUIRES(Locks::mutator_lock_);
940 ArtMethod* FindDeclaredVirtualMethod(const StringPiece& name, const Signature& signature,
942 SHARED_REQUIRES(Locks::mutator_lock_);
944 ArtMethod* FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx,
946 SHARED_REQUIRES(Locks::mutator_lock_);
948 ArtMethod* FindDeclaredVirtualMethodByName(const StringPiece& name, size_t pointer_size)
949 SHARED_REQUIRES(Locks::mutator_lock_);
951 ArtMethod* FindDeclaredDirectMethodByName(const StringPiece& name, size_t pointer_size)
952 SHARED_REQUIRES(Locks::mutator_lock_);
954 ArtMethod* FindVirtualMethod(const StringPiece& name, const StringPiece& signature,
956 SHARED_REQUIRES(Locks::mutator_lock_);
958 ArtMethod* FindVirtualMethod(const StringPiece& name, const Signature& signature,
960 SHARED_REQUIRES(Locks::mutator_lock_);
962 ArtMethod* FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx,
964 SHARED_REQUIRES(Locks::mutator_lock_);
966 ArtMethod* FindClassInitializer(size_t pointer_size) SHARED_REQUIRES(Locks::mutator_lock_);
968 bool HasDefaultMethods() SHARED_REQUIRES(Locks::mutator_lock_) {
969 return (GetAccessFlags() & kAccHasDefaultMethod) != 0;
972 bool HasBeenRecursivelyInitialized() SHARED_REQUIRES(Locks::mutator_lock_) {
973 return (GetAccessFlags() & kAccRecursivelyInitialized) != 0;
976 ALWAYS_INLINE int32_t GetIfTableCount() SHARED_REQUIRES(Locks::mutator_lock_);
978 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
979 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
980 ALWAYS_INLINE IfTable* GetIfTable() SHARED_REQUIRES(Locks::mutator_lock_);
982 ALWAYS_INLINE void SetIfTable(IfTable* new_iftable) SHARED_REQUIRES(Locks::mutator_lock_);
984 // Get instance fields of the class (See also GetSFields).
985 LengthPrefixedArray<ArtField>* GetIFieldsPtr() SHARED_REQUIRES(Locks::mutator_lock_);
987 ALWAYS_INLINE IterationRange<StrideIterator<ArtField>> GetIFields()
988 SHARED_REQUIRES(Locks::mutator_lock_);
990 void SetIFieldsPtr(LengthPrefixedArray<ArtField>* new_ifields)
991 SHARED_REQUIRES(Locks::mutator_lock_);
993 // Unchecked edition has no verification flags.
994 void SetIFieldsPtrUnchecked(LengthPrefixedArray<ArtField>* new_sfields)
995 SHARED_REQUIRES(Locks::mutator_lock_);
997 uint32_t NumInstanceFields() SHARED_REQUIRES(Locks::mutator_lock_);
998 ArtField* GetInstanceField(uint32_t i) SHARED_REQUIRES(Locks::mutator_lock_);
1000 // Returns the number of instance fields containing reference types. Does not count fields in any
1002 uint32_t NumReferenceInstanceFields() SHARED_REQUIRES(Locks::mutator_lock_) {
1003 DCHECK(IsResolved() || IsErroneous());
1004 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_));
1007 uint32_t NumReferenceInstanceFieldsDuringLinking() SHARED_REQUIRES(Locks::mutator_lock_) {
1008 DCHECK(IsLoaded() || IsErroneous());
1009 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_));
1012 void SetNumReferenceInstanceFields(uint32_t new_num) SHARED_REQUIRES(Locks::mutator_lock_) {
1013 // Not called within a transaction.
1014 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_), new_num);
1017 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
1018 uint32_t GetReferenceInstanceOffsets() ALWAYS_INLINE SHARED_REQUIRES(Locks::mutator_lock_);
1020 void SetReferenceInstanceOffsets(uint32_t new_reference_offsets)
1021 SHARED_REQUIRES(Locks::mutator_lock_);
1023 // Get the offset of the first reference instance field. Other reference instance fields follow.
1024 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1025 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
1026 MemberOffset GetFirstReferenceInstanceFieldOffset()
1027 SHARED_REQUIRES(Locks::mutator_lock_);
1029 // Returns the number of static fields containing reference types.
1030 uint32_t NumReferenceStaticFields() SHARED_REQUIRES(Locks::mutator_lock_) {
1031 DCHECK(IsResolved() || IsErroneous());
1032 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_));
1035 uint32_t NumReferenceStaticFieldsDuringLinking() SHARED_REQUIRES(Locks::mutator_lock_) {
1036 DCHECK(IsLoaded() || IsErroneous() || IsRetired());
1037 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_));
1040 void SetNumReferenceStaticFields(uint32_t new_num) SHARED_REQUIRES(Locks::mutator_lock_) {
1041 // Not called within a transaction.
1042 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_), new_num);
1045 // Get the offset of the first reference static field. Other reference static fields follow.
1046 template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1047 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
1048 MemberOffset GetFirstReferenceStaticFieldOffset(size_t pointer_size)
1049 SHARED_REQUIRES(Locks::mutator_lock_);
1051 // Get the offset of the first reference static field. Other reference static fields follow.
1052 MemberOffset GetFirstReferenceStaticFieldOffsetDuringLinking(size_t pointer_size)
1053 SHARED_REQUIRES(Locks::mutator_lock_);
1055 // Gets the static fields of the class.
1056 LengthPrefixedArray<ArtField>* GetSFieldsPtr() SHARED_REQUIRES(Locks::mutator_lock_);
1057 ALWAYS_INLINE IterationRange<StrideIterator<ArtField>> GetSFields()
1058 SHARED_REQUIRES(Locks::mutator_lock_);
1060 void SetSFieldsPtr(LengthPrefixedArray<ArtField>* new_sfields)
1061 SHARED_REQUIRES(Locks::mutator_lock_);
1063 // Unchecked edition has no verification flags.
1064 void SetSFieldsPtrUnchecked(LengthPrefixedArray<ArtField>* new_sfields)
1065 SHARED_REQUIRES(Locks::mutator_lock_);
1067 uint32_t NumStaticFields() SHARED_REQUIRES(Locks::mutator_lock_);
1070 ArtField* GetStaticField(uint32_t i) SHARED_REQUIRES(Locks::mutator_lock_);
1072 // Find a static or instance field using the JLS resolution order
1073 static ArtField* FindField(Thread* self, Handle<Class> klass, const StringPiece& name,
1074 const StringPiece& type)
1075 SHARED_REQUIRES(Locks::mutator_lock_);
1077 // Finds the given instance field in this class or a superclass.
1078 ArtField* FindInstanceField(const StringPiece& name, const StringPiece& type)
1079 SHARED_REQUIRES(Locks::mutator_lock_);
1081 // Finds the given instance field in this class or a superclass, only searches classes that
1082 // have the same dex cache.
1083 ArtField* FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx)
1084 SHARED_REQUIRES(Locks::mutator_lock_);
1086 ArtField* FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type)
1087 SHARED_REQUIRES(Locks::mutator_lock_);
1089 ArtField* FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx)
1090 SHARED_REQUIRES(Locks::mutator_lock_);
1092 // Finds the given static field in this class or a superclass.
1093 static ArtField* FindStaticField(Thread* self, Handle<Class> klass, const StringPiece& name,
1094 const StringPiece& type)
1095 SHARED_REQUIRES(Locks::mutator_lock_);
1097 // Finds the given static field in this class or superclass, only searches classes that
1098 // have the same dex cache.
1099 static ArtField* FindStaticField(Thread* self, Handle<Class> klass, const DexCache* dex_cache,
1100 uint32_t dex_field_idx)
1101 SHARED_REQUIRES(Locks::mutator_lock_);
1103 ArtField* FindDeclaredStaticField(const StringPiece& name, const StringPiece& type)
1104 SHARED_REQUIRES(Locks::mutator_lock_);
1106 ArtField* FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx)
1107 SHARED_REQUIRES(Locks::mutator_lock_);
1109 pid_t GetClinitThreadId() SHARED_REQUIRES(Locks::mutator_lock_) {
1110 DCHECK(IsIdxLoaded() || IsErroneous()) << PrettyClass(this);
1111 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, clinit_thread_id_));
1114 void SetClinitThreadId(pid_t new_clinit_thread_id) SHARED_REQUIRES(Locks::mutator_lock_);
1116 Object* GetVerifyError() SHARED_REQUIRES(Locks::mutator_lock_) {
1117 // DCHECK(IsErroneous());
1118 return GetFieldObject<Class>(OFFSET_OF_OBJECT_MEMBER(Class, verify_error_));
1121 uint16_t GetDexClassDefIndex() SHARED_REQUIRES(Locks::mutator_lock_) {
1122 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, dex_class_def_idx_));
1125 void SetDexClassDefIndex(uint16_t class_def_idx) SHARED_REQUIRES(Locks::mutator_lock_) {
1126 // Not called within a transaction.
1127 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, dex_class_def_idx_), class_def_idx);
1130 uint16_t GetDexTypeIndex() SHARED_REQUIRES(Locks::mutator_lock_) {
1131 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, dex_type_idx_));
1134 void SetDexTypeIndex(uint16_t type_idx) SHARED_REQUIRES(Locks::mutator_lock_) {
1135 // Not called within a transaction.
1136 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, dex_type_idx_), type_idx);
1139 uint32_t FindTypeIndexInOtherDexFile(const DexFile& dex_file)
1140 SHARED_REQUIRES(Locks::mutator_lock_);
1142 static Class* GetJavaLangClass() SHARED_REQUIRES(Locks::mutator_lock_) {
1143 DCHECK(HasJavaLangClass());
1144 return java_lang_Class_.Read();
1147 static bool HasJavaLangClass() SHARED_REQUIRES(Locks::mutator_lock_) {
1148 return !java_lang_Class_.IsNull();
1151 // Can't call this SetClass or else gets called instead of Object::SetClass in places.
1152 static void SetClassClass(Class* java_lang_Class) SHARED_REQUIRES(Locks::mutator_lock_);
1153 static void ResetClass();
1154 static void VisitRoots(RootVisitor* visitor)
1155 SHARED_REQUIRES(Locks::mutator_lock_);
1157 // Visit native roots visits roots which are keyed off the native pointers such as ArtFields and
1159 template<class Visitor>
1160 void VisitNativeRoots(Visitor& visitor, size_t pointer_size)
1161 SHARED_REQUIRES(Locks::mutator_lock_);
1163 // When class is verified, set the kAccSkipAccessChecks flag on each method.
1164 void SetSkipAccessChecksFlagOnAllMethods(size_t pointer_size)
1165 SHARED_REQUIRES(Locks::mutator_lock_);
1167 // Get the descriptor of the class. In a few cases a std::string is required, rather than
1168 // always create one the storage argument is populated and its internal c_str() returned. We do
1169 // this to avoid memory allocation in the common case.
1170 const char* GetDescriptor(std::string* storage) SHARED_REQUIRES(Locks::mutator_lock_);
1172 const char* GetArrayDescriptor(std::string* storage) SHARED_REQUIRES(Locks::mutator_lock_);
1174 bool DescriptorEquals(const char* match) SHARED_REQUIRES(Locks::mutator_lock_);
1176 const DexFile::ClassDef* GetClassDef() SHARED_REQUIRES(Locks::mutator_lock_);
1178 ALWAYS_INLINE uint32_t NumDirectInterfaces() SHARED_REQUIRES(Locks::mutator_lock_);
1180 uint16_t GetDirectInterfaceTypeIdx(uint32_t idx) SHARED_REQUIRES(Locks::mutator_lock_);
1182 static mirror::Class* GetDirectInterface(Thread* self, Handle<mirror::Class> klass,
1184 SHARED_REQUIRES(Locks::mutator_lock_);
1186 const char* GetSourceFile() SHARED_REQUIRES(Locks::mutator_lock_);
1188 std::string GetLocation() SHARED_REQUIRES(Locks::mutator_lock_);
1190 const DexFile& GetDexFile() SHARED_REQUIRES(Locks::mutator_lock_);
1192 const DexFile::TypeList* GetInterfaceTypeList() SHARED_REQUIRES(Locks::mutator_lock_);
1194 // Asserts we are initialized or initializing in the given thread.
1195 void AssertInitializedOrInitializingInThread(Thread* self)
1196 SHARED_REQUIRES(Locks::mutator_lock_);
1198 Class* CopyOf(Thread* self, int32_t new_length, ArtMethod* const (&imt)[mirror::Class::kImtSize],
1199 size_t pointer_size)
1200 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
1202 // For proxy class only.
1203 ObjectArray<Class>* GetInterfaces() SHARED_REQUIRES(Locks::mutator_lock_);
1205 // For proxy class only.
1206 ObjectArray<ObjectArray<Class>>* GetThrows() SHARED_REQUIRES(Locks::mutator_lock_);
1208 // For reference class only.
1209 MemberOffset GetDisableIntrinsicFlagOffset() SHARED_REQUIRES(Locks::mutator_lock_);
1210 MemberOffset GetSlowPathFlagOffset() SHARED_REQUIRES(Locks::mutator_lock_);
1211 bool GetSlowPathEnabled() SHARED_REQUIRES(Locks::mutator_lock_);
1212 void SetSlowPath(bool enabled) SHARED_REQUIRES(Locks::mutator_lock_);
1214 GcRoot<String>* GetDexCacheStrings() SHARED_REQUIRES(Locks::mutator_lock_);
1215 void SetDexCacheStrings(GcRoot<String>* new_dex_cache_strings)
1216 SHARED_REQUIRES(Locks::mutator_lock_);
1217 static MemberOffset DexCacheStringsOffset() {
1218 return OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_strings_);
1221 // May cause thread suspension due to EqualParameters.
1222 ArtMethod* GetDeclaredConstructor(
1223 Thread* self, Handle<mirror::ObjectArray<mirror::Class>> args, size_t pointer_size)
1224 SHARED_REQUIRES(Locks::mutator_lock_);
1226 static int32_t GetInnerClassFlags(Handle<Class> h_this, int32_t default_value)
1227 SHARED_REQUIRES(Locks::mutator_lock_);
1229 // Used to initialize a class in the allocation code path to ensure it is guarded by a StoreStore
1231 class InitializeClassVisitor {
1233 explicit InitializeClassVisitor(uint32_t class_size) : class_size_(class_size) {
1236 void operator()(mirror::Object* obj, size_t usable_size) const
1237 SHARED_REQUIRES(Locks::mutator_lock_);
1240 const uint32_t class_size_;
1242 DISALLOW_COPY_AND_ASSIGN(InitializeClassVisitor);
1245 // Returns true if the class loader is null, ie the class loader is the boot strap class loader.
1246 bool IsBootStrapClassLoaded() SHARED_REQUIRES(Locks::mutator_lock_) {
1247 return GetClassLoader() == nullptr;
1250 static size_t ImTableEntrySize(size_t pointer_size) {
1251 return pointer_size;
1254 static size_t VTableEntrySize(size_t pointer_size) {
1255 return pointer_size;
1258 ALWAYS_INLINE ArraySlice<ArtMethod> GetDirectMethodsSliceUnchecked(size_t pointer_size)
1259 SHARED_REQUIRES(Locks::mutator_lock_);
1261 ALWAYS_INLINE ArraySlice<ArtMethod> GetVirtualMethodsSliceUnchecked(size_t pointer_size)
1262 SHARED_REQUIRES(Locks::mutator_lock_);
1264 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredMethodsSliceUnchecked(size_t pointer_size)
1265 SHARED_REQUIRES(Locks::mutator_lock_);
1267 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredVirtualMethodsSliceUnchecked(size_t pointer_size)
1268 SHARED_REQUIRES(Locks::mutator_lock_);
1270 ALWAYS_INLINE ArraySlice<ArtMethod> GetCopiedMethodsSliceUnchecked(size_t pointer_size)
1271 SHARED_REQUIRES(Locks::mutator_lock_);
1273 // Fix up all of the native pointers in the class by running them through the visitor. Only sets
1274 // the corresponding entry in dest if visitor(obj) != obj to prevent dirty memory. Dest should be
1275 // initialized to a copy of *this to prevent issues. Does not visit the ArtMethod and ArtField
1277 template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1278 ReadBarrierOption kReadBarrierOption = kWithReadBarrier,
1280 void FixupNativePointers(mirror::Class* dest, size_t pointer_size, const Visitor& visitor)
1281 SHARED_REQUIRES(Locks::mutator_lock_);
1284 ALWAYS_INLINE void SetMethodsPtrInternal(LengthPrefixedArray<ArtMethod>* new_methods)
1285 SHARED_REQUIRES(Locks::mutator_lock_);
1287 void SetVerifyError(Object* klass) SHARED_REQUIRES(Locks::mutator_lock_);
1289 template <bool throw_on_failure, bool use_referrers_cache>
1290 bool ResolvedFieldAccessTest(Class* access_to, ArtField* field,
1291 uint32_t field_idx, DexCache* dex_cache)
1292 SHARED_REQUIRES(Locks::mutator_lock_);
1293 template <bool throw_on_failure, bool use_referrers_cache, InvokeType throw_invoke_type>
1294 bool ResolvedMethodAccessTest(Class* access_to, ArtMethod* resolved_method,
1295 uint32_t method_idx, DexCache* dex_cache)
1296 SHARED_REQUIRES(Locks::mutator_lock_);
1298 bool Implements(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
1299 bool IsArrayAssignableFromArray(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
1300 bool IsAssignableFromArray(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
1302 void CheckObjectAlloc() SHARED_REQUIRES(Locks::mutator_lock_);
1304 // Unchecked editions is for root visiting.
1305 LengthPrefixedArray<ArtField>* GetSFieldsPtrUnchecked() SHARED_REQUIRES(Locks::mutator_lock_);
1306 IterationRange<StrideIterator<ArtField>> GetSFieldsUnchecked()
1307 SHARED_REQUIRES(Locks::mutator_lock_);
1308 LengthPrefixedArray<ArtField>* GetIFieldsPtrUnchecked() SHARED_REQUIRES(Locks::mutator_lock_);
1309 IterationRange<StrideIterator<ArtField>> GetIFieldsUnchecked()
1310 SHARED_REQUIRES(Locks::mutator_lock_);
1312 // The index in the methods_ array where the first declared virtual method is.
1313 ALWAYS_INLINE uint32_t GetVirtualMethodsStartOffset() SHARED_REQUIRES(Locks::mutator_lock_);
1315 // The index in the methods_ array where the first direct method is.
1316 ALWAYS_INLINE uint32_t GetDirectMethodsStartOffset() SHARED_REQUIRES(Locks::mutator_lock_);
1318 // The index in the methods_ array where the first copied method is.
1319 ALWAYS_INLINE uint32_t GetCopiedMethodsStartOffset() SHARED_REQUIRES(Locks::mutator_lock_);
1321 bool ProxyDescriptorEquals(const char* match) SHARED_REQUIRES(Locks::mutator_lock_);
1323 // Check that the pointer size matches the one in the class linker.
1324 ALWAYS_INLINE static void CheckPointerSize(size_t pointer_size);
1326 static MemberOffset EmbeddedImTableOffset(size_t pointer_size);
1327 static MemberOffset EmbeddedVTableOffset(size_t pointer_size);
1329 template <bool kVisitNativeRoots,
1330 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1331 ReadBarrierOption kReadBarrierOption = kWithReadBarrier,
1333 void VisitReferences(mirror::Class* klass, const Visitor& visitor)
1334 SHARED_REQUIRES(Locks::mutator_lock_);
1336 // 'Class' Object Fields
1337 // Order governed by java field ordering. See art::ClassLinker::LinkFields.
1339 HeapReference<Object> annotation_type_;
1341 // Defining class loader, or null for the "bootstrap" system loader.
1342 HeapReference<ClassLoader> class_loader_;
1344 // For array classes, the component class object for instanceof/checkcast
1345 // (for String[][][], this will be String[][]). null for non-array classes.
1346 HeapReference<Class> component_type_;
1348 // DexCache of resolved constant pool entries (will be null for classes generated by the
1349 // runtime such as arrays and primitive classes).
1350 HeapReference<DexCache> dex_cache_;
1352 // The interface table (iftable_) contains pairs of a interface class and an array of the
1353 // interface methods. There is one pair per interface supported by this class. That means one
1354 // pair for each interface we support directly, indirectly via superclass, or indirectly via a
1355 // superinterface. This will be null if neither we nor our superclass implement any interfaces.
1357 // Why we need this: given "class Foo implements Face", declare "Face faceObj = new Foo()".
1358 // Invoke faceObj.blah(), where "blah" is part of the Face interface. We can't easily use a
1361 // For every interface a concrete class implements, we create an array of the concrete vtable_
1362 // methods for the methods in the interface.
1363 HeapReference<IfTable> iftable_;
1365 // Descriptor for the class such as "java.lang.Class" or "[C". Lazily initialized by ComputeName
1366 HeapReference<String> name_;
1368 // The superclass, or null if this is java.lang.Object or a primitive type.
1370 // Note that interfaces have java.lang.Object as their
1371 // superclass. This doesn't match the expectations in JNI
1372 // GetSuperClass or java.lang.Class.getSuperClass() which need to
1373 // check for interfaces and return null.
1374 HeapReference<Class> super_class_;
1376 // If class verify fails, we must return same error on subsequent tries. We may store either
1377 // the class of the error, or an actual instance of Throwable here.
1378 HeapReference<Object> verify_error_;
1380 // Virtual method table (vtable), for use by "invoke-virtual". The vtable from the superclass is
1381 // copied in, and virtual methods from our class either replace those from the super or are
1382 // appended. For abstract classes, methods may be created in the vtable that aren't in
1383 // virtual_ methods_ for miranda methods.
1384 HeapReference<PointerArray> vtable_;
1386 // Access flags; low 16 bits are defined by VM spec.
1387 uint32_t access_flags_;
1389 // Short cuts to dex_cache_ member for fast compiled code access.
1390 uint64_t dex_cache_strings_;
1394 // These describe the layout of the contents of an Object.
1395 // Note that only the fields directly declared by this class are
1396 // listed in ifields; fields declared by a superclass are listed in
1397 // the superclass's Class.ifields.
1399 // ArtFields are allocated as a length prefixed ArtField array, and not an array of pointers to
1403 // Pointer to an ArtMethod length-prefixed array. All the methods where this class is the place
1404 // where they are logically defined. This includes all private, static, final and virtual methods
1405 // as well as inherited default methods and miranda methods.
1407 // The slice methods_ [0, virtual_methods_offset_) are the direct (static, private, init) methods
1408 // declared by this class.
1410 // The slice methods_ [virtual_methods_offset_, copied_methods_offset_) are the virtual methods
1411 // declared by this class.
1413 // The slice methods_ [copied_methods_offset_, |methods_|) are the methods that are copied from
1414 // interfaces such as miranda or default methods. These are copied for resolution purposes as this
1415 // class is where they are (logically) declared as far as the virtual dispatch is concerned.
1417 // Note that this field is used by the native debugger as the unique identifier for the type.
1420 // Static fields length-prefixed array.
1423 // Class flags to help speed up visiting object references.
1424 uint32_t class_flags_;
1426 // Total size of the Class instance; used when allocating storage on gc heap.
1427 // See also object_size_.
1428 uint32_t class_size_;
1430 // Tid used to check for recursive <clinit> invocation.
1431 pid_t clinit_thread_id_;
1433 // ClassDef index in dex file, -1 if no class definition such as an array.
1434 // TODO: really 16bits
1435 int32_t dex_class_def_idx_;
1437 // Type index in dex file.
1438 // TODO: really 16bits
1439 int32_t dex_type_idx_;
1441 // Number of instance fields that are object refs.
1442 uint32_t num_reference_instance_fields_;
1444 // Number of static fields that are object refs,
1445 uint32_t num_reference_static_fields_;
1447 // Total object size; used when allocating storage on gc heap.
1448 // (For interfaces and abstract classes this will be zero.)
1449 // See also class_size_.
1450 uint32_t object_size_;
1452 // The lower 16 bits contains a Primitive::Type value. The upper 16
1453 // bits contains the size shift of the primitive type.
1454 uint32_t primitive_type_;
1456 // Bitmap of offsets of ifields.
1457 uint32_t reference_instance_offsets_;
1459 // State of class initialization.
1462 // The offset of the first virtual method that is copied from an interface. This includes miranda,
1463 // default, and default-conflict methods. Having a hard limit of ((2 << 16) - 1) for methods
1464 // defined on a single class is well established in Java so we will use only uint16_t's here.
1465 uint16_t copied_methods_offset_;
1467 // The offset of the first declared virtual methods in the methods_ array.
1468 uint16_t virtual_methods_offset_;
1471 // initiating class loader list
1472 // NOTE: for classes with low serialNumber, these are unused, and the
1473 // values are kept in a table in gDvm.
1474 // InitiatingLoaderList initiating_loader_list_;
1476 // The following data exist in real class objects.
1477 // Embedded Imtable, for class object that's not an interface, fixed size.
1478 // ImTableEntry embedded_imtable_[0];
1479 // Embedded Vtable, for class object that's not an interface, variable size.
1480 // VTableEntry embedded_vtable_[0];
1481 // Static fields, variable size.
1482 // uint32_t fields_[0];
1485 static GcRoot<Class> java_lang_Class_;
1487 friend struct art::ClassOffsets; // for verifying offset information
1488 friend class Object; // For VisitReferences
1489 DISALLOW_IMPLICIT_CONSTRUCTORS(Class);
1492 std::ostream& operator<<(std::ostream& os, const Class::Status& rhs);
1494 } // namespace mirror
1497 #endif // ART_RUNTIME_MIRROR_CLASS_H_