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: 31 static Method* CreateFromArtMethod(Thread* self, ArtMethod* method) 32 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 33 StaticClass()34 static mirror::Class* StaticClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 35 return static_class_.Read(); 36 } 37 38 static void SetClass(Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 39 40 static void ResetClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 41 ArrayClass()42 static mirror::Class* ArrayClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 43 return array_class_.Read(); 44 } 45 46 static void SetArrayClass(Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 47 48 static void ResetArrayClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 49 50 static void VisitRoots(RootVisitor* visitor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 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: 62 static Constructor* CreateFromArtMethod(Thread* self, ArtMethod* method) 63 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 64 StaticClass()65 static mirror::Class* StaticClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 66 return static_class_.Read(); 67 } 68 69 static void SetClass(Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 70 71 static void ResetClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 72 ArrayClass()73 static mirror::Class* ArrayClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 74 return array_class_.Read(); 75 } 76 77 static void SetArrayClass(Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 78 79 static void ResetArrayClass() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 80 81 static void VisitRoots(RootVisitor* visitor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 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_ 94