blob: 0b569640eb38d626cace37081d9db10dabaa5eeb [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_METHOD_H_
18#define ART_RUNTIME_MIRROR_METHOD_H_
19
20#include "abstract_method.h"
21#include "gc_root.h"
22
23namespace art {
24namespace mirror {
25
26class Class;
27
28// C++ mirror of java.lang.reflect.Method.
29class MANAGED Method : public AbstractMethod {
30 public:
Andreas Gampebc4d2182016-02-22 10:03:12 -080031 template <bool kTransactionActive = false>
Mathieu Chartiere401d142015-04-22 13:56:20 -070032 static Method* CreateFromArtMethod(Thread* self, ArtMethod* method)
Mathieu Chartiered8990a2015-07-23 14:11:16 -070033 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070034
Mathieu Chartier90443472015-07-16 20:32:27 -070035 static mirror::Class* StaticClass() SHARED_REQUIRES(Locks::mutator_lock_) {
Mathieu Chartierfc58af42015-04-16 18:00:39 -070036 return static_class_.Read();
37 }
38
Mathieu Chartier90443472015-07-16 20:32:27 -070039 static void SetClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070040
Mathieu Chartier90443472015-07-16 20:32:27 -070041 static void ResetClass() SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070042
Mathieu Chartier90443472015-07-16 20:32:27 -070043 static mirror::Class* ArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) {
Mathieu Chartierfc58af42015-04-16 18:00:39 -070044 return array_class_.Read();
45 }
46
Mathieu Chartier90443472015-07-16 20:32:27 -070047 static void SetArrayClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070048
Mathieu Chartier90443472015-07-16 20:32:27 -070049 static void ResetArrayClass() SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070050
Mathieu Chartier90443472015-07-16 20:32:27 -070051 static void VisitRoots(RootVisitor* visitor) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070052
53 private:
54 static GcRoot<Class> static_class_; // java.lang.reflect.Method.class.
55 static GcRoot<Class> array_class_; // [java.lang.reflect.Method.class.
56
57 DISALLOW_COPY_AND_ASSIGN(Method);
58};
59
60// C++ mirror of java.lang.reflect.Constructor.
61class MANAGED Constructor: public AbstractMethod {
62 public:
Andreas Gampe6039e562016-04-05 18:18:43 -070063 template <bool kTransactionActive = false>
Mathieu Chartiere401d142015-04-22 13:56:20 -070064 static Constructor* CreateFromArtMethod(Thread* self, ArtMethod* method)
Mathieu Chartiered8990a2015-07-23 14:11:16 -070065 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070066
Mathieu Chartier90443472015-07-16 20:32:27 -070067 static mirror::Class* StaticClass() SHARED_REQUIRES(Locks::mutator_lock_) {
Mathieu Chartierfc58af42015-04-16 18:00:39 -070068 return static_class_.Read();
69 }
70
Mathieu Chartier90443472015-07-16 20:32:27 -070071 static void SetClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070072
Mathieu Chartier90443472015-07-16 20:32:27 -070073 static void ResetClass() SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070074
Mathieu Chartier90443472015-07-16 20:32:27 -070075 static mirror::Class* ArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) {
Mathieu Chartierfc58af42015-04-16 18:00:39 -070076 return array_class_.Read();
77 }
78
Mathieu Chartier90443472015-07-16 20:32:27 -070079 static void SetArrayClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070080
Mathieu Chartier90443472015-07-16 20:32:27 -070081 static void ResetArrayClass() SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070082
Mathieu Chartier90443472015-07-16 20:32:27 -070083 static void VisitRoots(RootVisitor* visitor) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070084
85 private:
86 static GcRoot<Class> static_class_; // java.lang.reflect.Constructor.class.
87 static GcRoot<Class> array_class_; // [java.lang.reflect.Constructor.class.
88
89 DISALLOW_COPY_AND_ASSIGN(Constructor);
90};
91
92} // namespace mirror
93} // namespace art
94
95#endif // ART_RUNTIME_MIRROR_METHOD_H_