blob: 91046314db78f308400c9933b97c656ba66f4db3 [file] [log] [blame]
Alex Lightd6251582016-10-31 11:12:30 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_RUNTIME_MIRROR_CLASS_EXT_H_
18#define ART_RUNTIME_MIRROR_CLASS_EXT_H_
19
20#include "class-inl.h"
21
Alex Lighta01de592016-11-15 10:43:06 -080022#include "array.h"
23#include "dex_cache.h"
Alex Lightd6251582016-10-31 11:12:30 -070024#include "gc_root.h"
25#include "object.h"
Alex Lighta01de592016-11-15 10:43:06 -080026#include "object_array.h"
Alex Lightd6251582016-10-31 11:12:30 -070027#include "object_callbacks.h"
28#include "string.h"
29
30namespace art {
31
32struct ClassExtOffsets;
33
34namespace mirror {
35
36// C++ mirror of dalvik.system.ClassExt
37class MANAGED ClassExt : public Object {
38 public:
39 static uint32_t ClassSize(PointerSize pointer_size) {
40 uint32_t vtable_entries = Object::kVTableLength;
41 return Class::ComputeClassSize(true, vtable_entries, 0, 0, 0, 0, 0, pointer_size);
42 }
43
44 // Size of an instance of dalvik.system.ClassExt.
45 static constexpr uint32_t InstanceSize() {
46 return sizeof(ClassExt);
47 }
48
49 void SetVerifyError(ObjPtr<Object> obj) REQUIRES_SHARED(Locks::mutator_lock_);
50
51 Object* GetVerifyError() REQUIRES_SHARED(Locks::mutator_lock_) {
52 return GetFieldObject<ClassExt>(OFFSET_OF_OBJECT_MEMBER(ClassExt, verify_error_));
53 }
54
Alex Lighta01de592016-11-15 10:43:06 -080055 ObjectArray<DexCache>* GetObsoleteDexCaches() REQUIRES_SHARED(Locks::mutator_lock_) {
56 return GetFieldObject<ObjectArray<DexCache>>(
57 OFFSET_OF_OBJECT_MEMBER(ClassExt, obsolete_dex_caches_));
58 }
59
60 PointerArray* GetObsoleteMethods() REQUIRES_SHARED(Locks::mutator_lock_) {
61 return GetFieldObject<PointerArray>(OFFSET_OF_OBJECT_MEMBER(ClassExt, obsolete_methods_));
62 }
63
64 void SetObsoleteArrays(ObjPtr<PointerArray> methods, ObjPtr<ObjectArray<DexCache>> dex_caches)
65 REQUIRES_SHARED(Locks::mutator_lock_);
66
67 // Extend the obsolete arrays by the given amount.
68 bool ExtendObsoleteArrays(Thread* self, uint32_t increase)
69 REQUIRES_SHARED(Locks::mutator_lock_);
70
Alex Lightd6251582016-10-31 11:12:30 -070071 static void SetClass(ObjPtr<Class> dalvik_system_ClassExt);
72 static void ResetClass();
73 static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
74
75 static ClassExt* Alloc(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
76
77 private:
78 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
Alex Lighta01de592016-11-15 10:43:06 -080079 HeapReference<ObjectArray<DexCache>> obsolete_dex_caches_;
80
81 HeapReference<PointerArray> obsolete_methods_;
82
83 HeapReference<DexCache> original_dex_cache_;
84
85 // The saved verification error of this class.
Alex Lightd6251582016-10-31 11:12:30 -070086 HeapReference<Object> verify_error_;
87
88 static GcRoot<Class> dalvik_system_ClassExt_;
89
90 friend struct art::ClassExtOffsets; // for verifying offset information
91 DISALLOW_IMPLICIT_CONSTRUCTORS(ClassExt);
92};
93
94} // namespace mirror
95} // namespace art
96
97#endif // ART_RUNTIME_MIRROR_CLASS_EXT_H_