blob: 708665d46b72024818c8cab3476be0b625f97e58 [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
Alex Lighta01de592016-11-15 10:43:06 -080020#include "array.h"
Alex Light4f2e9572017-03-16 13:13:31 -070021#include "class.h"
Alex Lighta01de592016-11-15 10:43:06 -080022#include "dex_cache.h"
Alex Lightd6251582016-10-31 11:12:30 -070023#include "gc_root.h"
24#include "object.h"
Alex Lighta01de592016-11-15 10:43:06 -080025#include "object_array.h"
Alex Lightd6251582016-10-31 11:12:30 -070026#include "object_callbacks.h"
27#include "string.h"
28
29namespace art {
30
31struct ClassExtOffsets;
32
33namespace mirror {
34
35// C++ mirror of dalvik.system.ClassExt
36class MANAGED ClassExt : public Object {
37 public:
Alex Light4f2e9572017-03-16 13:13:31 -070038 static uint32_t ClassSize(PointerSize pointer_size);
Alex Lightd6251582016-10-31 11:12:30 -070039
40 // Size of an instance of dalvik.system.ClassExt.
41 static constexpr uint32_t InstanceSize() {
42 return sizeof(ClassExt);
43 }
44
45 void SetVerifyError(ObjPtr<Object> obj) REQUIRES_SHARED(Locks::mutator_lock_);
46
47 Object* GetVerifyError() REQUIRES_SHARED(Locks::mutator_lock_) {
48 return GetFieldObject<ClassExt>(OFFSET_OF_OBJECT_MEMBER(ClassExt, verify_error_));
49 }
50
Alex Lighta01de592016-11-15 10:43:06 -080051 ObjectArray<DexCache>* GetObsoleteDexCaches() REQUIRES_SHARED(Locks::mutator_lock_) {
52 return GetFieldObject<ObjectArray<DexCache>>(
53 OFFSET_OF_OBJECT_MEMBER(ClassExt, obsolete_dex_caches_));
54 }
55
Alex Light4f2e9572017-03-16 13:13:31 -070056 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
57 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
58 inline PointerArray* GetObsoleteMethods() REQUIRES_SHARED(Locks::mutator_lock_) {
59 return GetFieldObject<PointerArray, kVerifyFlags, kReadBarrierOption>(
60 OFFSET_OF_OBJECT_MEMBER(ClassExt, obsolete_methods_));
Alex Lighta01de592016-11-15 10:43:06 -080061 }
62
Alex Light2f814aa2017-03-24 15:21:34 +000063 Object* GetOriginalDexFile() REQUIRES_SHARED(Locks::mutator_lock_) {
64 return GetFieldObject<Object>(OFFSET_OF_OBJECT_MEMBER(ClassExt, original_dex_file_));
Alex Lighta7e38d82017-01-19 14:57:28 -080065 }
66
Alex Light2f814aa2017-03-24 15:21:34 +000067 void SetOriginalDexFile(ObjPtr<Object> bytes) REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighta7e38d82017-01-19 14:57:28 -080068
Alex Lighta01de592016-11-15 10:43:06 -080069 void SetObsoleteArrays(ObjPtr<PointerArray> methods, ObjPtr<ObjectArray<DexCache>> dex_caches)
70 REQUIRES_SHARED(Locks::mutator_lock_);
71
72 // Extend the obsolete arrays by the given amount.
73 bool ExtendObsoleteArrays(Thread* self, uint32_t increase)
74 REQUIRES_SHARED(Locks::mutator_lock_);
75
Alex Lightd6251582016-10-31 11:12:30 -070076 static void SetClass(ObjPtr<Class> dalvik_system_ClassExt);
77 static void ResetClass();
78 static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
79
Alex Light4f2e9572017-03-16 13:13:31 -070080 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier, class Visitor>
81 inline void VisitNativeRoots(Visitor& visitor, PointerSize pointer_size)
82 REQUIRES_SHARED(Locks::mutator_lock_);
83
Alex Lightd6251582016-10-31 11:12:30 -070084 static ClassExt* Alloc(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
85
86 private:
87 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
Alex Lighta01de592016-11-15 10:43:06 -080088 HeapReference<ObjectArray<DexCache>> obsolete_dex_caches_;
89
90 HeapReference<PointerArray> obsolete_methods_;
91
Alex Light2f814aa2017-03-24 15:21:34 +000092 HeapReference<Object> original_dex_file_;
Alex Lighta01de592016-11-15 10:43:06 -080093
94 // The saved verification error of this class.
Alex Lightd6251582016-10-31 11:12:30 -070095 HeapReference<Object> verify_error_;
96
97 static GcRoot<Class> dalvik_system_ClassExt_;
98
99 friend struct art::ClassExtOffsets; // for verifying offset information
100 DISALLOW_IMPLICIT_CONSTRUCTORS(ClassExt);
101};
102
103} // namespace mirror
104} // namespace art
105
106#endif // ART_RUNTIME_MIRROR_CLASS_EXT_H_