blob: 50db34c5ba0fc2ce4d10f7aa76cd57c89f955e3e [file] [log] [blame]
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001/*
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 Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_MIRROR_THROWABLE_H_
18#define ART_RUNTIME_MIRROR_THROWABLE_H_
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080019
20#include "object.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080021
22namespace art {
23
Andreas Gampe5d08fcc2017-06-05 17:56:46 -070024class RootVisitor;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080025struct ThrowableOffsets;
26
27namespace mirror {
28
Andreas Gampe5d08fcc2017-06-05 17:56:46 -070029class String;
30
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080031// C++ mirror of java.lang.Throwable
32class MANAGED Throwable : public Object {
33 public:
Alex Light8f187c32021-04-20 14:29:00 -070034 MIRROR_CLASS("Ljava/lang/Throwable;");
35
Mathieu Chartier31e88222016-10-14 18:43:19 -070036 void SetDetailMessage(ObjPtr<String> new_detail_message) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070037
Vladimir Marko3b458902019-03-26 17:08:41 +000038 ObjPtr<String> GetDetailMessage() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070039
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070040 std::string Dump() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080041
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.
Mathieu Chartier31e88222016-10-14 18:43:19 -070045 void SetCause(ObjPtr<Throwable> cause) REQUIRES_SHARED(Locks::mutator_lock_);
46 void SetStackState(ObjPtr<Object> state) REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070047 bool IsCheckedException() REQUIRES_SHARED(Locks::mutator_lock_);
Orion Hodsona5dca522018-02-27 12:42:11 +000048 bool IsError() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080049
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070050 int32_t GetStackDepth() REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffray7642cfc2015-02-26 10:56:09 +000051
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080052 private:
Vladimir Marko3b458902019-03-26 17:08:41 +000053 ObjPtr<Object> GetStackState() REQUIRES_SHARED(Locks::mutator_lock_);
54 ObjPtr<Object> GetStackTrace() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080055
56 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
Vladimir Marko3b458902019-03-26 17:08:41 +000057 HeapReference<Object> backtrace_;
Ian Rogersef7d42f2014-01-06 12:55:46 -080058 HeapReference<Throwable> cause_;
59 HeapReference<String> detail_message_;
Ian Rogersef7d42f2014-01-06 12:55:46 -080060 HeapReference<Object> stack_trace_;
61 HeapReference<Object> suppressed_exceptions_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080062
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080063 friend struct art::ThrowableOffsets; // for verifying offset information
64 DISALLOW_IMPLICIT_CONSTRUCTORS(Throwable);
65};
66
67} // namespace mirror
68} // namespace art
69
Brian Carlstromfc0e3212013-07-17 14:40:12 -070070#endif // ART_RUNTIME_MIRROR_THROWABLE_H_