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