blob: 0c28e4f58051aad195eaf2cd23adff5c8e703752 [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:
Mathieu Chartiere401d142015-04-22 13:56:20 -070031 static Method* CreateFromArtMethod(Thread* self, ArtMethod* method)
Mathieu Chartiered8990a2015-07-23 14:11:16 -070032 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070033
Mathieu Chartier90443472015-07-16 20:32:27 -070034 static mirror::Class* StaticClass() SHARED_REQUIRES(Locks::mutator_lock_) {
Mathieu Chartierfc58af42015-04-16 18:00:39 -070035 return static_class_.Read();
36 }
37
Mathieu Chartier90443472015-07-16 20:32:27 -070038 static void SetClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070039
Mathieu Chartier90443472015-07-16 20:32:27 -070040 static void ResetClass() SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070041
Mathieu Chartier90443472015-07-16 20:32:27 -070042 static mirror::Class* ArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) {
Mathieu Chartierfc58af42015-04-16 18:00:39 -070043 return array_class_.Read();
44 }
45
Mathieu Chartier90443472015-07-16 20:32:27 -070046 static void SetArrayClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070047
Mathieu Chartier90443472015-07-16 20:32:27 -070048 static void ResetArrayClass() SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070049
Mathieu Chartier90443472015-07-16 20:32:27 -070050 static void VisitRoots(RootVisitor* visitor) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070051
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.
60class MANAGED Constructor: public AbstractMethod {
61 public:
Mathieu Chartiere401d142015-04-22 13:56:20 -070062 static Constructor* CreateFromArtMethod(Thread* self, ArtMethod* method)
Mathieu Chartiered8990a2015-07-23 14:11:16 -070063 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070064
Mathieu Chartier90443472015-07-16 20:32:27 -070065 static mirror::Class* StaticClass() SHARED_REQUIRES(Locks::mutator_lock_) {
Mathieu Chartierfc58af42015-04-16 18:00:39 -070066 return static_class_.Read();
67 }
68
Mathieu Chartier90443472015-07-16 20:32:27 -070069 static void SetClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070070
Mathieu Chartier90443472015-07-16 20:32:27 -070071 static void ResetClass() SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070072
Mathieu Chartier90443472015-07-16 20:32:27 -070073 static mirror::Class* ArrayClass() SHARED_REQUIRES(Locks::mutator_lock_) {
Mathieu Chartierfc58af42015-04-16 18:00:39 -070074 return array_class_.Read();
75 }
76
Mathieu Chartier90443472015-07-16 20:32:27 -070077 static void SetArrayClass(Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070078
Mathieu Chartier90443472015-07-16 20:32:27 -070079 static void ResetArrayClass() SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070080
Mathieu Chartier90443472015-07-16 20:32:27 -070081 static void VisitRoots(RootVisitor* visitor) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070082
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_