blob: c06763e4b4b73ef687f9fb18cf11f0302b79bf35 [file] [log] [blame]
Ian Rogers87e552d2012-08-31 15:54:48 -07001/*
2 * Copyright (C) 2012 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_COMMON_THROWS_H_
18#define ART_RUNTIME_COMMON_THROWS_H_
Ian Rogers87e552d2012-08-31 15:54:48 -070019
Elliott Hughes76b61672012-12-12 17:47:30 -080020#include "base/mutex.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080021#include "invoke_type.h"
Ian Rogers87e552d2012-08-31 15:54:48 -070022
23namespace art {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080024namespace mirror {
Ian Rogers8d31bbd2013-10-13 10:44:14 -070025 class ArtField;
26 class ArtMethod;
27 class Class;
28 class Object;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080029} // namespace mirror
Ian Rogersd91d6d62013-09-25 20:26:14 -070030class Signature;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080031class StringPiece;
Ian Rogers62d6c772013-02-27 08:32:07 -080032class ThrowLocation;
Ian Rogers87e552d2012-08-31 15:54:48 -070033
Sebastien Hertz56adf602013-07-09 17:27:07 +020034// AbstractMethodError
35
Ian Rogersef7d42f2014-01-06 12:55:46 -080036void ThrowAbstractMethodError(mirror::ArtMethod* method)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070037 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Sebastien Hertz56adf602013-07-09 17:27:07 +020038
Ian Rogers62d6c772013-02-27 08:32:07 -080039// ArithmeticException
Ian Rogers87e552d2012-08-31 15:54:48 -070040
Ian Rogers8d31bbd2013-10-13 10:44:14 -070041void ThrowArithmeticExceptionDivideByZero() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080042
43// ArrayIndexOutOfBoundsException
44
45void ThrowArrayIndexOutOfBoundsException(int index, int length)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070046 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070047
Ian Rogers62d6c772013-02-27 08:32:07 -080048// ArrayStoreException
49
Ian Rogersef7d42f2014-01-06 12:55:46 -080050void ThrowArrayStoreException(mirror::Class* element_class, mirror::Class* array_class)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070051 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070052
Ian Rogers62d6c772013-02-27 08:32:07 -080053// ClassCircularityError
54
Ian Rogers8d31bbd2013-10-13 10:44:14 -070055void ThrowClassCircularityError(mirror::Class* c)
56 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080057
58// ClassCastException
59
Ian Rogersef7d42f2014-01-06 12:55:46 -080060void ThrowClassCastException(mirror::Class* dest_type, mirror::Class* src_type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070061 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080062
63void ThrowClassCastException(const ThrowLocation* throw_location, const char* msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070064 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080065
66// ClassFormatError
67
Ian Rogersef7d42f2014-01-06 12:55:46 -080068void ThrowClassFormatError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -080069 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -070070 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070071
72// IllegalAccessError
73
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080074void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* accessed)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070075 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070076
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080077void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed,
Ian Rogersef7d42f2014-01-06 12:55:46 -080078 mirror::ArtMethod* called,
Ian Rogers87e552d2012-08-31 15:54:48 -070079 InvokeType type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070080 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070081
Brian Carlstromea46f952013-07-30 01:26:50 -070082void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::ArtMethod* accessed)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070083 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070084
Brian Carlstromea46f952013-07-30 01:26:50 -070085void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::ArtField* accessed)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070086 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070087
Ian Rogersef7d42f2014-01-06 12:55:46 -080088void ThrowIllegalAccessErrorFinalField(mirror::ArtMethod* referrer, mirror::ArtField* accessed)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070089 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070090
Ian Rogers62d6c772013-02-27 08:32:07 -080091void ThrowIllegalAccessError(mirror::Class* referrer, const char* fmt, ...)
92 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -070093 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080094
Jeff Hao11d5d8f2014-03-26 15:08:20 -070095// IllegalAccessException
96
97void ThrowIllegalAccessException(const ThrowLocation* throw_location, const char* msg)
98 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
99
Ian Rogers62d6c772013-02-27 08:32:07 -0800100// IllegalArgumentException
101
102void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const char* msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700103 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800104
Ian Rogers87e552d2012-08-31 15:54:48 -0700105// IncompatibleClassChangeError
106
107void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800108 mirror::ArtMethod* method, mirror::ArtMethod* referrer)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700109 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700110
Ian Rogersef7d42f2014-01-06 12:55:46 -0800111void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(mirror::ArtMethod* interface_method,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800112 mirror::Object* this_object,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800113 mirror::ArtMethod* referrer)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700114 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700115
Ian Rogersef7d42f2014-01-06 12:55:46 -0800116void ThrowIncompatibleClassChangeErrorField(mirror::ArtField* resolved_field, bool is_static,
117 mirror::ArtMethod* referrer)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700118 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700119
Ian Rogersef7d42f2014-01-06 12:55:46 -0800120void ThrowIncompatibleClassChangeError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -0800121 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700122 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
123
124// IOException
125
126void ThrowIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2)))
127 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800128
129// LinkageError
130
Ian Rogersef7d42f2014-01-06 12:55:46 -0800131void ThrowLinkageError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -0800132 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700133 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800134
135// NegativeArraySizeException
136
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700137void ThrowNegativeArraySizeException(int size)
138 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800139
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700140void ThrowNegativeArraySizeException(const char* msg)
141 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800142
143
144// NoSuchFieldError
145
146void ThrowNoSuchFieldError(const StringPiece& scope, mirror::Class* c,
147 const StringPiece& type, const StringPiece& name)
148 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
149
Ian Rogers87e552d2012-08-31 15:54:48 -0700150// NoSuchMethodError
151
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800152void ThrowNoSuchMethodError(InvokeType type, mirror::Class* c, const StringPiece& name,
Ian Rogersd91d6d62013-09-25 20:26:14 -0700153 const Signature& signature)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700154 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700155
Ian Rogers62d6c772013-02-27 08:32:07 -0800156void ThrowNoSuchMethodError(uint32_t method_idx)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700157 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800158
159// NullPointerException
160
161void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location,
Brian Carlstromea46f952013-07-30 01:26:50 -0700162 mirror::ArtField* field,
Ian Rogers62d6c772013-02-27 08:32:07 -0800163 bool is_read)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700164 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800165
166void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
167 uint32_t method_idx,
168 InvokeType type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700169 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800170
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200171void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
Brian Carlstromea46f952013-07-30 01:26:50 -0700172 mirror::ArtMethod* method,
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200173 InvokeType type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700174 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200175
Ian Rogers62d6c772013-02-27 08:32:07 -0800176void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700177 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800178
179void ThrowNullPointerException(const ThrowLocation* throw_location, const char* msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700180 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800181
182// RuntimeException
183
184void ThrowRuntimeException(const char* fmt, ...)
185 __attribute__((__format__(__printf__, 1, 2)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700186 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800187
188// VerifyError
189
Ian Rogersef7d42f2014-01-06 12:55:46 -0800190void ThrowVerifyError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -0800191 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700192 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700193
194} // namespace art
195
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700196#endif // ART_RUNTIME_COMMON_THROWS_H_