blob: 3164f308c12fb8233dd5cc59dc2928cda9fd7db0 [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
Brian Carlstromea46f952013-07-30 01:26:50 -070036void ThrowAbstractMethodError(const 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
50void ThrowArrayStoreException(const mirror::Class* element_class,
51 const mirror::Class* array_class)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070052 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070053
Ian Rogers62d6c772013-02-27 08:32:07 -080054// ClassCircularityError
55
Ian Rogers8d31bbd2013-10-13 10:44:14 -070056void ThrowClassCircularityError(mirror::Class* c)
57 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080058
59// ClassCastException
60
61void ThrowClassCastException(const mirror::Class* dest_type, const mirror::Class* src_type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070062 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080063
64void ThrowClassCastException(const ThrowLocation* throw_location, const char* msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070065 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080066
67// ClassFormatError
68
69void ThrowClassFormatError(const mirror::Class* referrer, const char* fmt, ...)
70 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -070071 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070072
73// IllegalAccessError
74
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080075void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* accessed)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070076 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070077
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080078void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed,
Brian Carlstromea46f952013-07-30 01:26:50 -070079 const mirror::ArtMethod* caller,
80 const mirror::ArtMethod* called,
Ian Rogers87e552d2012-08-31 15:54:48 -070081 InvokeType type)
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 ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::ArtMethod* 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
Brian Carlstromea46f952013-07-30 01:26:50 -070087void ThrowIllegalAccessErrorField(mirror::Class* 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
Brian Carlstromea46f952013-07-30 01:26:50 -070090void ThrowIllegalAccessErrorFinalField(const mirror::ArtMethod* referrer,
91 mirror::ArtField* accessed)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070092 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -070093
Ian Rogers62d6c772013-02-27 08:32:07 -080094void ThrowIllegalAccessError(mirror::Class* referrer, const char* fmt, ...)
95 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -070096 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080097
98// IllegalArgumentException
99
100void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const char* msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700101 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800102
Ian Rogers87e552d2012-08-31 15:54:48 -0700103// IncompatibleClassChangeError
104
105void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type,
Brian Carlstromea46f952013-07-30 01:26:50 -0700106 mirror::ArtMethod* method,
107 const 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
Brian Carlstromea46f952013-07-30 01:26:50 -0700110void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::ArtMethod* interface_method,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800111 mirror::Object* this_object,
Brian Carlstromea46f952013-07-30 01:26:50 -0700112 const 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
Brian Carlstromea46f952013-07-30 01:26:50 -0700115void ThrowIncompatibleClassChangeErrorField(const mirror::ArtField* resolved_field, bool is_static,
116 const 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 Rogers62d6c772013-02-27 08:32:07 -0800119void ThrowIncompatibleClassChangeError(const mirror::Class* referrer, const char* fmt, ...)
120 __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
128// LinkageError
129
130void ThrowLinkageError(const mirror::Class* referrer, const char* fmt, ...)
131 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700132 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800133
134// NegativeArraySizeException
135
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700136void ThrowNegativeArraySizeException(int size)
137 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800138
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700139void ThrowNegativeArraySizeException(const char* msg)
140 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800141
142
143// NoSuchFieldError
144
145void ThrowNoSuchFieldError(const StringPiece& scope, mirror::Class* c,
146 const StringPiece& type, const StringPiece& name)
147 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
148
Ian Rogers87e552d2012-08-31 15:54:48 -0700149// NoSuchMethodError
150
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800151void ThrowNoSuchMethodError(InvokeType type, mirror::Class* c, const StringPiece& name,
Ian Rogersd91d6d62013-09-25 20:26:14 -0700152 const Signature& signature)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700153 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700154
Ian Rogers62d6c772013-02-27 08:32:07 -0800155void ThrowNoSuchMethodError(uint32_t method_idx)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700156 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800157
158// NullPointerException
159
160void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location,
Brian Carlstromea46f952013-07-30 01:26:50 -0700161 mirror::ArtField* field,
Ian Rogers62d6c772013-02-27 08:32:07 -0800162 bool is_read)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700163 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800164
165void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
166 uint32_t method_idx,
167 InvokeType type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700168 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800169
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200170void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
Brian Carlstromea46f952013-07-30 01:26:50 -0700171 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
Ian Rogers62d6c772013-02-27 08:32:07 -0800175void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700176 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800177
178void ThrowNullPointerException(const ThrowLocation* throw_location, 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
189void ThrowVerifyError(const mirror::Class* referrer, const char* fmt, ...)
190 __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_