Home | History | Annotate | Download | only in mirror
      1 /*
      2  * Copyright (C) 2011 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_STACK_TRACE_ELEMENT_H_
     18 #define ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_
     19 
     20 #include "object.h"
     21 
     22 namespace art {
     23 
     24 struct StackTraceElementOffsets;
     25 
     26 namespace mirror {
     27 
     28 // C++ mirror of java.lang.StackTraceElement
     29 class MANAGED StackTraceElement : public Object {
     30  public:
     31   const String* GetDeclaringClass() const {
     32     return GetFieldObject<const String*>(
     33         OFFSET_OF_OBJECT_MEMBER(StackTraceElement, declaring_class_), false);
     34   }
     35 
     36   const String* GetMethodName() const {
     37     return GetFieldObject<const String*>(
     38         OFFSET_OF_OBJECT_MEMBER(StackTraceElement, method_name_), false);
     39   }
     40 
     41   const String* GetFileName() const {
     42     return GetFieldObject<const String*>(
     43         OFFSET_OF_OBJECT_MEMBER(StackTraceElement, file_name_), false);
     44   }
     45 
     46   int32_t GetLineNumber() const {
     47     return GetField32(
     48         OFFSET_OF_OBJECT_MEMBER(StackTraceElement, line_number_), false);
     49   }
     50 
     51   static StackTraceElement* Alloc(Thread* self,
     52                                   String* declaring_class,
     53                                   String* method_name,
     54                                   String* file_name,
     55                                   int32_t line_number)
     56       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
     57 
     58   static void SetClass(Class* java_lang_StackTraceElement);
     59 
     60   static void ResetClass();
     61 
     62  private:
     63   // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
     64   String* declaring_class_;
     65   String* file_name_;
     66   String* method_name_;
     67   int32_t line_number_;
     68 
     69   static Class* GetStackTraceElement() {
     70     DCHECK(java_lang_StackTraceElement_ != NULL);
     71     return java_lang_StackTraceElement_;
     72   }
     73 
     74   static Class* java_lang_StackTraceElement_;
     75 
     76   friend struct art::StackTraceElementOffsets;  // for verifying offset information
     77   DISALLOW_IMPLICIT_CONSTRUCTORS(StackTraceElement);
     78 };
     79 
     80 }  // namespace mirror
     81 }  // namespace art
     82 
     83 #endif  // ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_
     84