blob: ad8a61b676a481a39c73af1e0238657096b05d63 [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
Alex Lighta7e38d82017-01-19 14:57:28 -080064 ByteArray* GetOriginalDexFileBytes() REQUIRES_SHARED(Locks::mutator_lock_) {
65 return GetFieldObject<ByteArray>(OFFSET_OF_OBJECT_MEMBER(ClassExt, original_dex_file_bytes_));
66 }
67
68 void SetOriginalDexFileBytes(ObjPtr<ByteArray> bytes) REQUIRES_SHARED(Locks::mutator_lock_);
69
Alex Lighta01de592016-11-15 10:43:06 -080070 void SetObsoleteArrays(ObjPtr<PointerArray> methods, ObjPtr<ObjectArray<DexCache>> dex_caches)
71 REQUIRES_SHARED(Locks::mutator_lock_);
72
73 // Extend the obsolete arrays by the given amount.
74 bool ExtendObsoleteArrays(Thread* self, uint32_t increase)
75 REQUIRES_SHARED(Locks::mutator_lock_);
76
Alex Lightd6251582016-10-31 11:12:30 -070077 static void SetClass(ObjPtr<Class> dalvik_system_ClassExt);
78 static void ResetClass();
79 static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
80
81 static ClassExt* Alloc(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
82
83 private:
84 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
Alex Lighta01de592016-11-15 10:43:06 -080085 HeapReference<ObjectArray<DexCache>> obsolete_dex_caches_;
86
87 HeapReference<PointerArray> obsolete_methods_;
88
Alex Lighta7e38d82017-01-19 14:57:28 -080089 HeapReference<ByteArray> original_dex_file_bytes_;
Alex Lighta01de592016-11-15 10:43:06 -080090
91 // The saved verification error of this class.
Alex Lightd6251582016-10-31 11:12:30 -070092 HeapReference<Object> verify_error_;
93
94 static GcRoot<Class> dalvik_system_ClassExt_;
95
96 friend struct art::ClassExtOffsets; // for verifying offset information
97 DISALLOW_IMPLICIT_CONSTRUCTORS(ClassExt);
98};
99
100} // namespace mirror
101} // namespace art
102
103#endif // ART_RUNTIME_MIRROR_CLASS_EXT_H_