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_ACCESSIBLE_OBJECT_H_
     18 #define ART_RUNTIME_MIRROR_ACCESSIBLE_OBJECT_H_
     19 
     20 #include "class.h"
     21 #include "gc_root.h"
     22 #include "object.h"
     23 #include "read_barrier_option.h"
     24 #include "thread.h"
     25 
     26 namespace art {
     27 
     28 namespace mirror {
     29 
     30 // C++ mirror of java.lang.reflect.AccessibleObject
     31 class MANAGED AccessibleObject : public Object {
     32  public:
     33   static MemberOffset FlagOffset() {
     34     return OFFSET_OF_OBJECT_MEMBER(AccessibleObject, flag_);
     35   }
     36 
     37   template<bool kTransactionActive>
     38   void SetAccessible(bool value) REQUIRES_SHARED(Locks::mutator_lock_) {
     39     UNUSED(padding_);
     40     return SetFieldBoolean<kTransactionActive>(FlagOffset(), value ? 1u : 0u);
     41   }
     42 
     43   bool IsAccessible() REQUIRES_SHARED(Locks::mutator_lock_) {
     44     return GetFieldBoolean(FlagOffset());
     45   }
     46 
     47  private:
     48   uint8_t flag_;
     49   // Padding required for correct alignment of subclasses like Executable, Field, etc.
     50   uint8_t padding_[1];
     51 
     52   DISALLOW_IMPLICIT_CONSTRUCTORS(AccessibleObject);
     53 };
     54 
     55 }  // namespace mirror
     56 }  // namespace art
     57 
     58 #endif  // ART_RUNTIME_MIRROR_ACCESSIBLE_OBJECT_H_
     59