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 22 namespace art { 23 24 class RootVisitor; 25 struct ThrowableOffsets; 26 27 namespace mirror { 28 29 class String; 30 31 // C++ mirror of java.lang.Throwable 32 class MANAGED Throwable : public Object { 33 public: 34 void SetDetailMessage(ObjPtr<String> new_detail_message) REQUIRES_SHARED(Locks::mutator_lock_); 35 36 ObjPtr<String> GetDetailMessage() REQUIRES_SHARED(Locks::mutator_lock_); 37 38 std::string Dump() REQUIRES_SHARED(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(ObjPtr<Throwable> cause) REQUIRES_SHARED(Locks::mutator_lock_); 44 void SetStackState(ObjPtr<Object> state) REQUIRES_SHARED(Locks::mutator_lock_); 45 bool IsCheckedException() REQUIRES_SHARED(Locks::mutator_lock_); 46 bool IsError() REQUIRES_SHARED(Locks::mutator_lock_); 47 48 int32_t GetStackDepth() REQUIRES_SHARED(Locks::mutator_lock_); 49 50 private: 51 ObjPtr<Object> GetStackState() REQUIRES_SHARED(Locks::mutator_lock_); 52 ObjPtr<Object> GetStackTrace() REQUIRES_SHARED(Locks::mutator_lock_); 53 54 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". 55 HeapReference<Object> backtrace_; 56 HeapReference<Throwable> cause_; 57 HeapReference<String> detail_message_; 58 HeapReference<Object> stack_trace_; 59 HeapReference<Object> suppressed_exceptions_; 60 61 friend struct art::ThrowableOffsets; // for verifying offset information 62 DISALLOW_IMPLICIT_CONSTRUCTORS(Throwable); 63 }; 64 65 } // namespace mirror 66 } // namespace art 67 68 #endif // ART_RUNTIME_MIRROR_THROWABLE_H_ 69