blob: 792cdefce2bcab171cf1e63e124b2cb2f538ba03 [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
95// IllegalArgumentException
96
97void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const char* msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -070098 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -080099
Ian Rogers87e552d2012-08-31 15:54:48 -0700100// IncompatibleClassChangeError
101
102void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800103 mirror::ArtMethod* method, mirror::ArtMethod* referrer)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700104 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700105
Ian Rogersef7d42f2014-01-06 12:55:46 -0800106void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(mirror::ArtMethod* interface_method,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800107 mirror::Object* this_object,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800108 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 ThrowIncompatibleClassChangeErrorField(mirror::ArtField* resolved_field, bool is_static,
112 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 ThrowIncompatibleClassChangeError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -0800116 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700117 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
118
119// IOException
120
121void ThrowIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2)))
122 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800123
124// LinkageError
125
Ian Rogersef7d42f2014-01-06 12:55:46 -0800126void ThrowLinkageError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -0800127 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700128 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800129
130// NegativeArraySizeException
131
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700132void ThrowNegativeArraySizeException(int size)
133 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800134
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700135void ThrowNegativeArraySizeException(const char* msg)
136 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800137
138
139// NoSuchFieldError
140
141void ThrowNoSuchFieldError(const StringPiece& scope, mirror::Class* c,
142 const StringPiece& type, const StringPiece& name)
143 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
144
Ian Rogers87e552d2012-08-31 15:54:48 -0700145// NoSuchMethodError
146
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800147void ThrowNoSuchMethodError(InvokeType type, mirror::Class* c, const StringPiece& name,
Ian Rogersd91d6d62013-09-25 20:26:14 -0700148 const Signature& signature)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700149 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700150
Ian Rogers62d6c772013-02-27 08:32:07 -0800151void ThrowNoSuchMethodError(uint32_t method_idx)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700152 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800153
154// NullPointerException
155
156void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location,
Brian Carlstromea46f952013-07-30 01:26:50 -0700157 mirror::ArtField* field,
Ian Rogers62d6c772013-02-27 08:32:07 -0800158 bool is_read)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700159 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800160
161void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
162 uint32_t method_idx,
163 InvokeType type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700164 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800165
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200166void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
Brian Carlstromea46f952013-07-30 01:26:50 -0700167 mirror::ArtMethod* method,
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200168 InvokeType type)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700169 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Sebastien Hertz2d6ba512013-05-17 11:31:37 +0200170
Ian Rogers62d6c772013-02-27 08:32:07 -0800171void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700172 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800173
174void ThrowNullPointerException(const ThrowLocation* throw_location, const char* msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700175 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800176
177// RuntimeException
178
179void ThrowRuntimeException(const char* fmt, ...)
180 __attribute__((__format__(__printf__, 1, 2)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700181 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers62d6c772013-02-27 08:32:07 -0800182
183// VerifyError
184
Ian Rogersef7d42f2014-01-06 12:55:46 -0800185void ThrowVerifyError(mirror::Class* referrer, const char* fmt, ...)
Ian Rogers62d6c772013-02-27 08:32:07 -0800186 __attribute__((__format__(__printf__, 2, 3)))
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700187 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
Ian Rogers87e552d2012-08-31 15:54:48 -0700188
189} // namespace art
190
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700191#endif // ART_RUNTIME_COMMON_THROWS_H_