• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   MIRROR_CLASS("Ljava/lang/Throwable;");
35 
36   void SetDetailMessage(ObjPtr<String> new_detail_message) REQUIRES_SHARED(Locks::mutator_lock_);
37 
38   ObjPtr<String> GetDetailMessage() REQUIRES_SHARED(Locks::mutator_lock_);
39 
40   std::string Dump() REQUIRES_SHARED(Locks::mutator_lock_);
41 
42   // This is a runtime version of initCause, you shouldn't use it if initCause may have been
43   // overridden. Also it asserts rather than throwing exceptions. Currently this is only used
44   // in cases like the verifier where the checks cannot fail and initCause isn't overridden.
45   void SetCause(ObjPtr<Throwable> cause) REQUIRES_SHARED(Locks::mutator_lock_);
46   void SetStackState(ObjPtr<Object> state) REQUIRES_SHARED(Locks::mutator_lock_);
47   bool IsCheckedException() REQUIRES_SHARED(Locks::mutator_lock_);
48   bool IsError() REQUIRES_SHARED(Locks::mutator_lock_);
49 
50   int32_t GetStackDepth() REQUIRES_SHARED(Locks::mutator_lock_);
51 
52  private:
53   ObjPtr<Object> GetStackState() REQUIRES_SHARED(Locks::mutator_lock_);
54   ObjPtr<Object> GetStackTrace() REQUIRES_SHARED(Locks::mutator_lock_);
55 
56   // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
57   HeapReference<Object> backtrace_;
58   HeapReference<Throwable> cause_;
59   HeapReference<String> detail_message_;
60   HeapReference<Object> stack_trace_;
61   HeapReference<Object> suppressed_exceptions_;
62 
63   friend struct art::ThrowableOffsets;  // for verifying offset information
64   DISALLOW_IMPLICIT_CONSTRUCTORS(Throwable);
65 };
66 
67 }  // namespace mirror
68 }  // namespace art
69 
70 #endif  // ART_RUNTIME_MIRROR_THROWABLE_H_
71