Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame^] | 1 | /* |
| 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 | |
| 26 | namespace art { |
| 27 | |
| 28 | struct AbstractMethodOffsets; |
| 29 | |
| 30 | namespace mirror { |
| 31 | |
| 32 | class ArtMethod; |
| 33 | |
| 34 | // C++ mirror of java.lang.reflect.AbstractMethod. |
| 35 | class MANAGED AbstractMethod : public AccessibleObject { |
| 36 | public: |
| 37 | // Called from Constructor::CreateFromArtMethod, Method::CreateFromArtMethod. |
| 38 | bool CreateFromArtMethod(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 39 | |
| 40 | mirror::ArtMethod* GetArtMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 41 | mirror::Class* GetDeclaringClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 42 | |
| 43 | private: |
| 44 | static MemberOffset ArtMethodOffset() { |
| 45 | return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, art_method_)); |
| 46 | } |
| 47 | static MemberOffset DeclaringClassOffset() { |
| 48 | return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_)); |
| 49 | } |
| 50 | static MemberOffset DeclaringClassOfOverriddenMethodOffset() { |
| 51 | return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_of_overridden_method_)); |
| 52 | } |
| 53 | static MemberOffset AccessFlagsOffset() { |
| 54 | return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, access_flags_)); |
| 55 | } |
| 56 | static MemberOffset DexMethodIndexOffset() { |
| 57 | return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, dex_method_index_)); |
| 58 | } |
| 59 | |
| 60 | HeapReference<mirror::ArtMethod> art_method_; |
| 61 | HeapReference<mirror::Class> declaring_class_; |
| 62 | HeapReference<mirror::Class> declaring_class_of_overridden_method_; |
| 63 | uint32_t access_flags_; |
| 64 | uint32_t dex_method_index_; |
| 65 | |
| 66 | friend struct art::AbstractMethodOffsets; // for verifying offset information |
| 67 | DISALLOW_IMPLICIT_CONSTRUCTORS(AbstractMethod); |
| 68 | }; |
| 69 | |
| 70 | } // namespace mirror |
| 71 | } // namespace art |
| 72 | |
| 73 | #endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ |