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_METHOD_H_ |
| 18 | #define ART_RUNTIME_MIRROR_METHOD_H_ |
| 19 | |
| 20 | #include "abstract_method.h" |
| 21 | #include "gc_root.h" |
| 22 | |
| 23 | namespace art { |
| 24 | namespace mirror { |
| 25 | |
| 26 | class Class; |
| 27 | |
| 28 | // C++ mirror of java.lang.reflect.Method. |
| 29 | class MANAGED Method : public AbstractMethod { |
| 30 | public: |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 31 | static Method* CreateFromArtMethod(Thread* self, ArtMethod* method) |
Mathieu Chartier | ed8990a | 2015-07-23 14:11:16 -0700 | [diff] [blame] | 32 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 33 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 34 | static mirror::Class* StaticClass() SHARED_REQUIRES(Locks::mutator_lock_) { |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 35 | return static_class_.Read(); |
| 36 | } |
| 37 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 38 | static void SetClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 39 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 40 | static void ResetClass() SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 41 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 42 | static mirror::Class* ArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) { |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 43 | return array_class_.Read(); |
| 44 | } |
| 45 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 46 | static void SetArrayClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 47 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 48 | static void ResetArrayClass() SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 49 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 50 | static void VisitRoots(RootVisitor* visitor) SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 51 | |
| 52 | private: |
| 53 | static GcRoot<Class> static_class_; // java.lang.reflect.Method.class. |
| 54 | static GcRoot<Class> array_class_; // [java.lang.reflect.Method.class. |
| 55 | |
| 56 | DISALLOW_COPY_AND_ASSIGN(Method); |
| 57 | }; |
| 58 | |
| 59 | // C++ mirror of java.lang.reflect.Constructor. |
| 60 | class MANAGED Constructor: public AbstractMethod { |
| 61 | public: |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 62 | static Constructor* CreateFromArtMethod(Thread* self, ArtMethod* method) |
Mathieu Chartier | ed8990a | 2015-07-23 14:11:16 -0700 | [diff] [blame] | 63 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 64 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 65 | static mirror::Class* StaticClass() SHARED_REQUIRES(Locks::mutator_lock_) { |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 66 | return static_class_.Read(); |
| 67 | } |
| 68 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 69 | static void SetClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 70 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 71 | static void ResetClass() SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 72 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 73 | static mirror::Class* ArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) { |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 74 | return array_class_.Read(); |
| 75 | } |
| 76 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 77 | static void SetArrayClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 78 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 79 | static void ResetArrayClass() SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 80 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 81 | static void VisitRoots(RootVisitor* visitor) SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 82 | |
| 83 | private: |
| 84 | static GcRoot<Class> static_class_; // java.lang.reflect.Constructor.class. |
| 85 | static GcRoot<Class> array_class_; // [java.lang.reflect.Constructor.class. |
| 86 | |
| 87 | DISALLOW_COPY_AND_ASSIGN(Constructor); |
| 88 | }; |
| 89 | |
| 90 | } // namespace mirror |
| 91 | } // namespace art |
| 92 | |
| 93 | #endif // ART_RUNTIME_MIRROR_METHOD_H_ |