blob: 35eaae147a1fbd0b704ee61d58e4a1040520cc28 [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
22#include "gc_root.h"
23#include "object.h"
24#include "object_callbacks.h"
25#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:
36 static uint32_t ClassSize(PointerSize pointer_size) {
37 uint32_t vtable_entries = Object::kVTableLength;
38 return Class::ComputeClassSize(true, vtable_entries, 0, 0, 0, 0, 0, pointer_size);
39 }
40
41 // Size of an instance of dalvik.system.ClassExt.
42 static constexpr uint32_t InstanceSize() {
43 return sizeof(ClassExt);
44 }
45
46 void SetVerifyError(ObjPtr<Object> obj) REQUIRES_SHARED(Locks::mutator_lock_);
47
48 Object* GetVerifyError() REQUIRES_SHARED(Locks::mutator_lock_) {
49 return GetFieldObject<ClassExt>(OFFSET_OF_OBJECT_MEMBER(ClassExt, verify_error_));
50 }
51
52 static void SetClass(ObjPtr<Class> dalvik_system_ClassExt);
53 static void ResetClass();
54 static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
55
56 static ClassExt* Alloc(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
57
58 private:
59 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
60 HeapReference<Object> verify_error_;
61
62 static GcRoot<Class> dalvik_system_ClassExt_;
63
64 friend struct art::ClassExtOffsets; // for verifying offset information
65 DISALLOW_IMPLICIT_CONSTRUCTORS(ClassExt);
66};
67
68} // namespace mirror
69} // namespace art
70
71#endif // ART_RUNTIME_MIRROR_CLASS_EXT_H_