Home | History | Annotate | Download | only in mirror
      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 "gc_root.h"
     21 #include "executable.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 Executable {
     30  public:
     31   template <PointerSize kPointerSize, bool kTransactionActive>
     32   static Method* CreateFromArtMethod(Thread* self, ArtMethod* method)
     33       REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
     34 
     35   static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
     36     return static_class_.Read();
     37   }
     38 
     39   static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
     40 
     41   static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
     42 
     43   static mirror::Class* ArrayClass() REQUIRES_SHARED(Locks::mutator_lock_) {
     44     return array_class_.Read();
     45   }
     46 
     47   static void SetArrayClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
     48 
     49   static void ResetArrayClass() REQUIRES_SHARED(Locks::mutator_lock_);
     50 
     51   static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
     52 
     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.
     61 class MANAGED Constructor: public Executable {
     62  public:
     63   template <PointerSize kPointerSize, bool kTransactionActive>
     64   static Constructor* CreateFromArtMethod(Thread* self, ArtMethod* method)
     65       REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
     66 
     67   static mirror::Class* StaticClass() REQUIRES_SHARED(Locks::mutator_lock_) {
     68     return static_class_.Read();
     69   }
     70 
     71   static void SetClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
     72 
     73   static void ResetClass() REQUIRES_SHARED(Locks::mutator_lock_);
     74 
     75   static mirror::Class* ArrayClass() REQUIRES_SHARED(Locks::mutator_lock_) {
     76     return array_class_.Read();
     77   }
     78 
     79   static void SetArrayClass(Class* klass) REQUIRES_SHARED(Locks::mutator_lock_);
     80 
     81   static void ResetArrayClass() REQUIRES_SHARED(Locks::mutator_lock_);
     82 
     83   static void VisitRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
     84 
     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_
     96