blob: cfbe4926f4079033e340d95fbaf9bca70f065e96 [file] [log] [blame]
Mathieu Chartierfc58af42015-04-16 18:00:39 -07001/*
2 * Copyright (C) 2015 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_ABSTRACT_METHOD_H_
18#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_
19
20#include "accessible_object.h"
21#include "gc_root.h"
22#include "object.h"
23#include "object_callbacks.h"
24#include "read_barrier_option.h"
25
26namespace art {
27
28struct AbstractMethodOffsets;
Mathieu Chartiere401d142015-04-22 13:56:20 -070029class ArtMethod;
Mathieu Chartierfc58af42015-04-16 18:00:39 -070030
31namespace mirror {
32
Mathieu Chartierfc58af42015-04-16 18:00:39 -070033// C++ mirror of java.lang.reflect.AbstractMethod.
34class MANAGED AbstractMethod : public AccessibleObject {
35 public:
36 // Called from Constructor::CreateFromArtMethod, Method::CreateFromArtMethod.
Andreas Gampe542451c2016-07-26 09:02:02 -070037 template <PointerSize kPointerSize, bool kTransactionActive>
Mathieu Chartiered8990a2015-07-23 14:11:16 -070038 bool CreateFromArtMethod(ArtMethod* method) SHARED_REQUIRES(Locks::mutator_lock_)
39 REQUIRES(!Roles::uninterruptible_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070040
Mathieu Chartier90443472015-07-16 20:32:27 -070041 ArtMethod* GetArtMethod() SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -070042 // Only used by the image writer.
Andreas Gampebc4d2182016-02-22 10:03:12 -080043 template <bool kTransactionActive = false>
Mathieu Chartier90443472015-07-16 20:32:27 -070044 void SetArtMethod(ArtMethod* method) SHARED_REQUIRES(Locks::mutator_lock_);
45 mirror::Class* GetDeclaringClass() SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070046
47 private:
48 static MemberOffset ArtMethodOffset() {
49 return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, art_method_));
50 }
51 static MemberOffset DeclaringClassOffset() {
52 return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_));
53 }
54 static MemberOffset DeclaringClassOfOverriddenMethodOffset() {
55 return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_of_overridden_method_));
56 }
57 static MemberOffset AccessFlagsOffset() {
58 return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, access_flags_));
59 }
60 static MemberOffset DexMethodIndexOffset() {
61 return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, dex_method_index_));
62 }
63
Mathieu Chartierfc58af42015-04-16 18:00:39 -070064 HeapReference<mirror::Class> declaring_class_;
65 HeapReference<mirror::Class> declaring_class_of_overridden_method_;
Mathieu Chartierfc58af42015-04-16 18:00:39 -070066 uint32_t access_flags_;
Richard Uhlerfab67882015-07-13 17:00:35 -070067 uint64_t art_method_;
Mathieu Chartierfc58af42015-04-16 18:00:39 -070068 uint32_t dex_method_index_;
69
70 friend struct art::AbstractMethodOffsets; // for verifying offset information
71 DISALLOW_IMPLICIT_CONSTRUCTORS(AbstractMethod);
72};
73
74} // namespace mirror
75} // namespace art
76
77#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_