blob: 8fbbf5c2e1bdc81210723462ac11d09d99f5a01d [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 "object.h"
Alex Lighta01de592016-11-15 10:43:06 -080024#include "object_array.h"
Alex Lightd6251582016-10-31 11:12:30 -070025#include "string.h"
26
27namespace art {
28
29struct ClassExtOffsets;
30
31namespace mirror {
32
33// C++ mirror of dalvik.system.ClassExt
34class MANAGED ClassExt : public Object {
35 public:
Alex Light4f2e9572017-03-16 13:13:31 -070036 static uint32_t ClassSize(PointerSize pointer_size);
Alex Lightd6251582016-10-31 11:12:30 -070037
38 // Size of an instance of dalvik.system.ClassExt.
39 static constexpr uint32_t InstanceSize() {
40 return sizeof(ClassExt);
41 }
42
43 void SetVerifyError(ObjPtr<Object> obj) REQUIRES_SHARED(Locks::mutator_lock_);
44
Vladimir Markobb206de2019-03-28 10:30:32 +000045 ObjPtr<Object> GetVerifyError() REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lightd6251582016-10-31 11:12:30 -070046
Vladimir Markobb206de2019-03-28 10:30:32 +000047 ObjPtr<ObjectArray<DexCache>> GetObsoleteDexCaches() REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighta01de592016-11-15 10:43:06 -080048
Alex Light4f2e9572017-03-16 13:13:31 -070049 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
50 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Vladimir Markobb206de2019-03-28 10:30:32 +000051 ObjPtr<PointerArray> GetObsoleteMethods() REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighta01de592016-11-15 10:43:06 -080052
Vladimir Markobb206de2019-03-28 10:30:32 +000053 ObjPtr<Object> GetOriginalDexFile() REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighta7e38d82017-01-19 14:57:28 -080054
Alex Light2f814aa2017-03-24 15:21:34 +000055 void SetOriginalDexFile(ObjPtr<Object> bytes) REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighta7e38d82017-01-19 14:57:28 -080056
David Brazdil1a658632018-12-01 17:54:26 +000057 uint16_t GetPreRedefineClassDefIndex() REQUIRES_SHARED(Locks::mutator_lock_) {
58 return static_cast<uint16_t>(
59 GetField32(OFFSET_OF_OBJECT_MEMBER(ClassExt, pre_redefine_class_def_index_)));
60 }
61
62 void SetPreRedefineClassDefIndex(uint16_t index) REQUIRES_SHARED(Locks::mutator_lock_);
63
64 const DexFile* GetPreRedefineDexFile() REQUIRES_SHARED(Locks::mutator_lock_) {
65 return reinterpret_cast<const DexFile*>(static_cast<uintptr_t>(
66 GetField64(OFFSET_OF_OBJECT_MEMBER(ClassExt, pre_redefine_dex_file_ptr_))));
67 }
68
69 void SetPreRedefineDexFile(const DexFile* dex_file) REQUIRES_SHARED(Locks::mutator_lock_);
70
Alex Lighta01de592016-11-15 10:43:06 -080071 void SetObsoleteArrays(ObjPtr<PointerArray> methods, ObjPtr<ObjectArray<DexCache>> dex_caches)
72 REQUIRES_SHARED(Locks::mutator_lock_);
73
74 // Extend the obsolete arrays by the given amount.
75 bool ExtendObsoleteArrays(Thread* self, uint32_t increase)
76 REQUIRES_SHARED(Locks::mutator_lock_);
77
Alex Light4f2e9572017-03-16 13:13:31 -070078 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier, class Visitor>
79 inline void VisitNativeRoots(Visitor& visitor, PointerSize pointer_size)
80 REQUIRES_SHARED(Locks::mutator_lock_);
81
Vladimir Markobb206de2019-03-28 10:30:32 +000082 static ObjPtr<ClassExt> Alloc(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lightd6251582016-10-31 11:12:30 -070083
84 private:
85 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
Alex Lighta01de592016-11-15 10:43:06 -080086 HeapReference<ObjectArray<DexCache>> obsolete_dex_caches_;
87
88 HeapReference<PointerArray> obsolete_methods_;
89
Alex Light2f814aa2017-03-24 15:21:34 +000090 HeapReference<Object> original_dex_file_;
Alex Lighta01de592016-11-15 10:43:06 -080091
92 // The saved verification error of this class.
Alex Lightd6251582016-10-31 11:12:30 -070093 HeapReference<Object> verify_error_;
94
David Brazdil1a658632018-12-01 17:54:26 +000095 // Native pointer to DexFile and ClassDef index of this class before it was JVMTI-redefined.
96 int64_t pre_redefine_dex_file_ptr_;
97 int32_t pre_redefine_class_def_index_;
98
Alex Lightd6251582016-10-31 11:12:30 -070099 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_