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_THROWABLE_H_ 18 #define ART_RUNTIME_MIRROR_THROWABLE_H_ 19 20 #include "object.h" 21 #include "string.h" 22 23 namespace art { 24 25 struct ThrowableOffsets; 26 27 namespace mirror { 28 29 // C++ mirror of java.lang.Throwable 30 class MANAGED Throwable : public Object { 31 public: SetDetailMessage(String * new_detail_message)32 void SetDetailMessage(String* new_detail_message) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 33 SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Throwable, detail_message_), new_detail_message, false); 34 } GetDetailMessage()35 String* GetDetailMessage() const { 36 return GetFieldObject<String*>(OFFSET_OF_OBJECT_MEMBER(Throwable, detail_message_), false); 37 } 38 std::string Dump() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 39 40 // This is a runtime version of initCause, you shouldn't use it if initCause may have been 41 // overridden. Also it asserts rather than throwing exceptions. Currently this is only used 42 // in cases like the verifier where the checks cannot fail and initCause isn't overridden. 43 void SetCause(Throwable* cause) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 44 bool IsCheckedException() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 45 GetJavaLangThrowable()46 static Class* GetJavaLangThrowable() { 47 DCHECK(java_lang_Throwable_ != NULL); 48 return java_lang_Throwable_; 49 } 50 51 static void SetClass(Class* java_lang_Throwable); 52 static void ResetClass(); 53 54 private: GetStackState()55 Object* GetStackState() const { 56 return GetFieldObject<Object*>(OFFSET_OF_OBJECT_MEMBER(Throwable, stack_state_), true); 57 } 58 59 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". 60 Throwable* cause_; 61 String* detail_message_; 62 Object* stack_state_; // Note this is Java volatile: 63 Object* stack_trace_; 64 Object* suppressed_exceptions_; 65 66 static Class* java_lang_Throwable_; 67 68 friend struct art::ThrowableOffsets; // for verifying offset information 69 DISALLOW_IMPLICIT_CONSTRUCTORS(Throwable); 70 }; 71 72 } // namespace mirror 73 } // namespace art 74 75 #endif // ART_RUNTIME_MIRROR_THROWABLE_H_ 76