• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 "array.h"
21 #include "class.h"
22 #include "dex_cache.h"
23 #include "object.h"
24 #include "object_array.h"
25 #include "string.h"
26 
27 namespace art {
28 
29 struct ClassExtOffsets;
30 
31 namespace mirror {
32 
33 // C++ mirror of dalvik.system.ClassExt
34 class MANAGED ClassExt : public Object {
35  public:
36   static uint32_t ClassSize(PointerSize pointer_size);
37 
38   // Size of an instance of dalvik.system.ClassExt.
InstanceSize()39   static constexpr uint32_t InstanceSize() {
40     return sizeof(ClassExt);
41   }
42 
43   void SetVerifyError(ObjPtr<Object> obj) REQUIRES_SHARED(Locks::mutator_lock_);
44 
45   ObjPtr<Object> GetVerifyError() REQUIRES_SHARED(Locks::mutator_lock_);
46 
47   ObjPtr<ObjectArray<DexCache>> GetObsoleteDexCaches() REQUIRES_SHARED(Locks::mutator_lock_);
48 
49   template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
50            ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
51   ObjPtr<PointerArray> GetObsoleteMethods() REQUIRES_SHARED(Locks::mutator_lock_);
52 
53   ObjPtr<Object> GetOriginalDexFile() REQUIRES_SHARED(Locks::mutator_lock_);
54 
55   void SetOriginalDexFile(ObjPtr<Object> bytes) REQUIRES_SHARED(Locks::mutator_lock_);
56 
GetPreRedefineClassDefIndex()57   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 
GetPreRedefineDexFile()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 
71   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 
78   template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier, class Visitor>
79   inline void VisitNativeRoots(Visitor& visitor, PointerSize pointer_size)
80       REQUIRES_SHARED(Locks::mutator_lock_);
81 
82   static ObjPtr<ClassExt> Alloc(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
83 
84  private:
85   // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
86   HeapReference<ObjectArray<DexCache>> obsolete_dex_caches_;
87 
88   HeapReference<PointerArray> obsolete_methods_;
89 
90   HeapReference<Object> original_dex_file_;
91 
92   // The saved verification error of this class.
93   HeapReference<Object> verify_error_;
94 
95   // 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 
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_
107