blob: ebedae00edce994d51ba0b9ef823d4e2ae1bd9a8 [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
Andreas Gampe329d1882014-04-08 10:32:19 -0700129void ThrowWrappedIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2)))
130 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
131
Ian Rogers62d6c772013-02-27 08:32:07 -0800132// LinkageError
133
Ian Rogersef7d42f2014-01-06 12:55:46 -0800134void ThrowLinkageError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -0800135 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700136 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800137
138// NegativeArraySizeException
139
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700140void ThrowNegativeArraySizeException(int size)
141 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800142
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700143void ThrowNegativeArraySizeException(const char* msg)
144 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800145
146
147// NoSuchFieldError
148
149void ThrowNoSuchFieldError(const StringPiece& scope, mirror::Class* c,
150 const StringPiece& type, const StringPiece& name)
151 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
152
Ian Rogers87e552d2012-08-31 15:54:48 -0700153// NoSuchMethodError
154
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800155void ThrowNoSuchMethodError(InvokeType type, mirror::Class* c, const StringPiece& name,
Ian Rogersd91d6d62013-09-25 20:26:14 -0700156 const Signature& signature)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700157 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700158
Ian Rogers62d6c772013-02-27 08:32:07 -0800159void ThrowNoSuchMethodError(uint32_t method_idx)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700160 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800161
162// NullPointerException
163
164void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location,
Brian Carlstromea46f952013-07-30 01:26:50 -0700165 mirror::ArtField* field,
Ian Rogers62d6c772013-02-27 08:32:07 -0800166 bool is_read)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700167 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800168
169void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
170 uint32_t method_idx,
171 InvokeType type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700172 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800173
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200174void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
Brian Carlstromea46f952013-07-30 01:26:50 -0700175 mirror::ArtMethod* method,
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200176 InvokeType type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700177 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200178
Ian Rogers62d6c772013-02-27 08:32:07 -0800179void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700180 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800181
182void ThrowNullPointerException(const ThrowLocation* throw_location, const char* msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700183 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800184
185// RuntimeException
186
187void ThrowRuntimeException(const char* fmt, ...)
188 __attribute__((__format__(__printf__, 1, 2)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700189 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800190
191// VerifyError
192
Ian Rogersef7d42f2014-01-06 12:55:46 -0800193void ThrowVerifyError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -0800194 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700195 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700196
197} // namespace art
198
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700199#endif // ART_RUNTIME_COMMON_THROWS_H_