blob: 9e749e3df6f87bf54c543213115a94288393ded8 [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 Rogers87e552d2012-08-31 15:54:48 -070032
Sebastien Hertz56adf602013-07-09 17:27:07 +020033// AbstractMethodError
34
Ian Rogersef7d42f2014-01-06 12:55:46 -080035void ThrowAbstractMethodError(mirror::ArtMethod* method)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070036 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Sebastien Hertz56adf602013-07-09 17:27:07 +020037
Ian Rogers62d6c772013-02-27 08:32:07 -080038// ArithmeticException
Ian Rogers87e552d2012-08-31 15:54:48 -070039
Ian Rogers8d31bbd2013-10-13 10:44:14 -070040void ThrowArithmeticExceptionDivideByZero() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080041
42// ArrayIndexOutOfBoundsException
43
44void ThrowArrayIndexOutOfBoundsException(int index, int length)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070045 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070046
Ian Rogers62d6c772013-02-27 08:32:07 -080047// ArrayStoreException
48
Ian Rogersef7d42f2014-01-06 12:55:46 -080049void ThrowArrayStoreException(mirror::Class* element_class, mirror::Class* array_class)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070050 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070051
Ian Rogers62d6c772013-02-27 08:32:07 -080052// ClassCircularityError
53
Ian Rogers8d31bbd2013-10-13 10:44:14 -070054void ThrowClassCircularityError(mirror::Class* c)
55 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080056
57// ClassCastException
58
Ian Rogersef7d42f2014-01-06 12:55:46 -080059void ThrowClassCastException(mirror::Class* dest_type, mirror::Class* src_type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070060 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080061
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +000062void ThrowClassCastException(const char* msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070063 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080064
65// ClassFormatError
66
Ian Rogersef7d42f2014-01-06 12:55:46 -080067void ThrowClassFormatError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -080068 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -070069 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070070
71// IllegalAccessError
72
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080073void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* accessed)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070074 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070075
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080076void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed,
Ian Rogersef7d42f2014-01-06 12:55:46 -080077 mirror::ArtMethod* called,
Ian Rogers87e552d2012-08-31 15:54:48 -070078 InvokeType type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070079 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070080
Brian Carlstromea46f952013-07-30 01:26:50 -070081void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::ArtMethod* accessed)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070082 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070083
Brian Carlstromea46f952013-07-30 01:26:50 -070084void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::ArtField* accessed)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070085 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070086
Ian Rogersef7d42f2014-01-06 12:55:46 -080087void ThrowIllegalAccessErrorFinalField(mirror::ArtMethod* referrer, mirror::ArtField* accessed)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070088 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070089
Ian Rogers62d6c772013-02-27 08:32:07 -080090void ThrowIllegalAccessError(mirror::Class* referrer, const char* fmt, ...)
91 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -070092 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080093
Jeff Hao11d5d8f2014-03-26 15:08:20 -070094// IllegalAccessException
95
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +000096void ThrowIllegalAccessException(const char* msg)
Jeff Hao11d5d8f2014-03-26 15:08:20 -070097 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
98
Ian Rogers62d6c772013-02-27 08:32:07 -080099// IllegalArgumentException
100
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000101void ThrowIllegalArgumentException(const char* msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700102 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800103
Ian Rogers87e552d2012-08-31 15:54:48 -0700104// IncompatibleClassChangeError
105
106void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800107 mirror::ArtMethod* method, mirror::ArtMethod* referrer)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700108 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700109
Ian Rogersef7d42f2014-01-06 12:55:46 -0800110void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(mirror::ArtMethod* interface_method,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800111 mirror::Object* this_object,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800112 mirror::ArtMethod* referrer)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700113 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700114
Ian Rogersef7d42f2014-01-06 12:55:46 -0800115void ThrowIncompatibleClassChangeErrorField(mirror::ArtField* resolved_field, bool is_static,
116 mirror::ArtMethod* referrer)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700117 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700118
Ian Rogersef7d42f2014-01-06 12:55:46 -0800119void ThrowIncompatibleClassChangeError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -0800120 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700121 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
122
123// IOException
124
125void ThrowIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2)))
126 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800127
Andreas Gampe329d1882014-04-08 10:32:19 -0700128void ThrowWrappedIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2)))
129 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
130
Ian Rogers62d6c772013-02-27 08:32:07 -0800131// LinkageError
132
Ian Rogersef7d42f2014-01-06 12:55:46 -0800133void ThrowLinkageError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -0800134 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700135 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800136
137// NegativeArraySizeException
138
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700139void ThrowNegativeArraySizeException(int size)
140 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800141
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700142void ThrowNegativeArraySizeException(const char* msg)
143 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800144
145
146// NoSuchFieldError
147
148void ThrowNoSuchFieldError(const StringPiece& scope, mirror::Class* c,
149 const StringPiece& type, const StringPiece& name)
150 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
151
Ian Rogers87e552d2012-08-31 15:54:48 -0700152// NoSuchMethodError
153
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800154void ThrowNoSuchMethodError(InvokeType type, mirror::Class* c, const StringPiece& name,
Ian Rogersd91d6d62013-09-25 20:26:14 -0700155 const Signature& signature)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700156 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700157
Ian Rogers62d6c772013-02-27 08:32:07 -0800158void ThrowNoSuchMethodError(uint32_t method_idx)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700159 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800160
161// NullPointerException
162
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000163void ThrowNullPointerExceptionForFieldAccess(mirror::ArtField* field,
Ian Rogers62d6c772013-02-27 08:32:07 -0800164 bool is_read)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700165 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800166
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000167void ThrowNullPointerExceptionForMethodAccess(uint32_t method_idx,
Ian Rogers62d6c772013-02-27 08:32:07 -0800168 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
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000171void ThrowNullPointerExceptionForMethodAccess(mirror::ArtMethod* method,
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200172 InvokeType type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700173 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200174
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000175void ThrowNullPointerExceptionFromDexPC()
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700176 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800177
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000178void ThrowNullPointerException(const char* msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700179 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800180
181// RuntimeException
182
183void ThrowRuntimeException(const char* fmt, ...)
184 __attribute__((__format__(__printf__, 1, 2)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700185 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800186
187// VerifyError
188
Ian Rogersef7d42f2014-01-06 12:55:46 -0800189void ThrowVerifyError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -0800190 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700191 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700192
193} // namespace art
194
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700195#endif // ART_RUNTIME_COMMON_THROWS_H_