Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 1 | /* |
| 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 Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_COMMON_THROWS_H_ |
| 18 | #define ART_RUNTIME_COMMON_THROWS_H_ |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 19 | |
Elliott Hughes | 76b6167 | 2012-12-12 17:47:30 -0800 | [diff] [blame] | 20 | #include "base/mutex.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 21 | #include "invoke_type.h" |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 22 | |
| 23 | namespace art { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 24 | namespace mirror { |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 25 | class ArtField; |
| 26 | class ArtMethod; |
| 27 | class Class; |
| 28 | class Object; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 29 | } // namespace mirror |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 30 | class Signature; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 31 | class StringPiece; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 32 | class ThrowLocation; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 33 | |
Sebastien Hertz | 56adf60 | 2013-07-09 17:27:07 +0200 | [diff] [blame] | 34 | // AbstractMethodError |
| 35 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 36 | void ThrowAbstractMethodError(mirror::ArtMethod* method) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 37 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Sebastien Hertz | 56adf60 | 2013-07-09 17:27:07 +0200 | [diff] [blame] | 38 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 39 | // ArithmeticException |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 40 | |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 41 | void ThrowArithmeticExceptionDivideByZero() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 42 | |
| 43 | // ArrayIndexOutOfBoundsException |
| 44 | |
| 45 | void ThrowArrayIndexOutOfBoundsException(int index, int length) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 46 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 47 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 48 | // ArrayStoreException |
| 49 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 50 | void ThrowArrayStoreException(mirror::Class* element_class, mirror::Class* array_class) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 51 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 52 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 53 | // ClassCircularityError |
| 54 | |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 55 | void ThrowClassCircularityError(mirror::Class* c) |
| 56 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 57 | |
| 58 | // ClassCastException |
| 59 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 60 | void ThrowClassCastException(mirror::Class* dest_type, mirror::Class* src_type) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 61 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 62 | |
| 63 | void ThrowClassCastException(const ThrowLocation* throw_location, const char* msg) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 64 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 65 | |
| 66 | // ClassFormatError |
| 67 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 68 | void ThrowClassFormatError(mirror::Class* referrer, const char* fmt, ...) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 69 | __attribute__((__format__(__printf__, 2, 3))) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 70 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 71 | |
| 72 | // IllegalAccessError |
| 73 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 74 | void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* accessed) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 75 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 76 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 77 | void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed, |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 78 | mirror::ArtMethod* called, |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 79 | InvokeType type) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 80 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 81 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 82 | void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::ArtMethod* accessed) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 83 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 84 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 85 | void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::ArtField* accessed) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 86 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 87 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 88 | void ThrowIllegalAccessErrorFinalField(mirror::ArtMethod* referrer, mirror::ArtField* accessed) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 89 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 90 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 91 | void ThrowIllegalAccessError(mirror::Class* referrer, const char* fmt, ...) |
| 92 | __attribute__((__format__(__printf__, 2, 3))) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 93 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 94 | |
Jeff Hao | 11d5d8f | 2014-03-26 15:08:20 -0700 | [diff] [blame] | 95 | // IllegalAccessException |
| 96 | |
| 97 | void ThrowIllegalAccessException(const ThrowLocation* throw_location, const char* msg) |
| 98 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
| 99 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 100 | // IllegalArgumentException |
| 101 | |
| 102 | void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const char* msg) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 103 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 104 | |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 105 | // IncompatibleClassChangeError |
| 106 | |
| 107 | void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type, |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 108 | mirror::ArtMethod* method, mirror::ArtMethod* referrer) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 109 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 110 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 111 | void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(mirror::ArtMethod* interface_method, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 112 | mirror::Object* this_object, |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 113 | mirror::ArtMethod* referrer) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 114 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 115 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 116 | void ThrowIncompatibleClassChangeErrorField(mirror::ArtField* resolved_field, bool is_static, |
| 117 | mirror::ArtMethod* referrer) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 118 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 119 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 120 | void ThrowIncompatibleClassChangeError(mirror::Class* referrer, const char* fmt, ...) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 121 | __attribute__((__format__(__printf__, 2, 3))) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 122 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
| 123 | |
| 124 | // IOException |
| 125 | |
| 126 | void ThrowIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2))) |
| 127 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 128 | |
Andreas Gampe | 329d188 | 2014-04-08 10:32:19 -0700 | [diff] [blame] | 129 | void ThrowWrappedIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2))) |
| 130 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
| 131 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 132 | // LinkageError |
| 133 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 134 | void ThrowLinkageError(mirror::Class* referrer, const char* fmt, ...) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 135 | __attribute__((__format__(__printf__, 2, 3))) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 136 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 137 | |
| 138 | // NegativeArraySizeException |
| 139 | |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 140 | void ThrowNegativeArraySizeException(int size) |
| 141 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 142 | |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 143 | void ThrowNegativeArraySizeException(const char* msg) |
| 144 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 145 | |
| 146 | |
| 147 | // NoSuchFieldError |
| 148 | |
| 149 | void ThrowNoSuchFieldError(const StringPiece& scope, mirror::Class* c, |
| 150 | const StringPiece& type, const StringPiece& name) |
| 151 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 152 | |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 153 | // NoSuchMethodError |
| 154 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 155 | void ThrowNoSuchMethodError(InvokeType type, mirror::Class* c, const StringPiece& name, |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 156 | const Signature& signature) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 157 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 158 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 159 | void ThrowNoSuchMethodError(uint32_t method_idx) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 160 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 161 | |
| 162 | // NullPointerException |
| 163 | |
| 164 | void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location, |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 165 | mirror::ArtField* field, |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 166 | bool is_read) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 167 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 168 | |
| 169 | void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, |
| 170 | uint32_t method_idx, |
| 171 | InvokeType type) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 172 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 173 | |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 174 | void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 175 | mirror::ArtMethod* method, |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 176 | InvokeType type) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 177 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 178 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 179 | void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 180 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 181 | |
| 182 | void ThrowNullPointerException(const ThrowLocation* throw_location, const char* msg) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 183 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 184 | |
| 185 | // RuntimeException |
| 186 | |
| 187 | void ThrowRuntimeException(const char* fmt, ...) |
| 188 | __attribute__((__format__(__printf__, 1, 2))) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 189 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 190 | |
| 191 | // VerifyError |
| 192 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 193 | void ThrowVerifyError(mirror::Class* referrer, const char* fmt, ...) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 194 | __attribute__((__format__(__printf__, 2, 3))) |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 195 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 196 | |
| 197 | } // namespace art |
| 198 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 199 | #endif // ART_RUNTIME_COMMON_THROWS_H_ |