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 17 #ifndef ART_RUNTIME_COMMON_THROWS_H_ 18 #define ART_RUNTIME_COMMON_THROWS_H_ 19 20 #include "base/mutex.h" 21 #include "invoke_type.h" 22 #include "obj_ptr.h" 23 24 namespace art { 25 namespace mirror { 26 class Class; 27 class Object; 28 class MethodType; 29 } // namespace mirror 30 class ArtField; 31 class ArtMethod; 32 class DexFile; 33 class Signature; 34 class StringPiece; 35 36 // AbstractMethodError 37 38 void ThrowAbstractMethodError(ArtMethod* method) 39 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 40 41 void ThrowAbstractMethodError(uint32_t method_idx, const DexFile& dex_file) 42 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 43 44 // ArithmeticException 45 46 void ThrowArithmeticExceptionDivideByZero() REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 47 48 // ArrayIndexOutOfBoundsException 49 50 void ThrowArrayIndexOutOfBoundsException(int index, int length) 51 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 52 53 // ArrayStoreException 54 55 void ThrowArrayStoreException(ObjPtr<mirror::Class> element_class, 56 ObjPtr<mirror::Class> array_class) 57 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 58 59 // BootstrapMethodError 60 61 void ThrowBootstrapMethodError(const char* fmt, ...) 62 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 63 64 void ThrowWrappedBootstrapMethodError(const char* fmt, ...) 65 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 66 67 // ClassCircularityError 68 69 void ThrowClassCircularityError(ObjPtr<mirror::Class> c) 70 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 71 72 void ThrowClassCircularityError(ObjPtr<mirror::Class> c, const char* fmt, ...) 73 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 74 75 // ClassCastException 76 77 void ThrowClassCastException(ObjPtr<mirror::Class> dest_type, ObjPtr<mirror::Class> src_type) 78 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 79 80 void ThrowClassCastException(const char* msg) 81 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 82 83 // ClassFormatError 84 85 void ThrowClassFormatError(ObjPtr<mirror::Class> referrer, const char* fmt, ...) 86 __attribute__((__format__(__printf__, 2, 3))) 87 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 88 89 // IllegalAccessError 90 91 void ThrowIllegalAccessErrorClass(ObjPtr<mirror::Class> referrer, ObjPtr<mirror::Class> accessed) 92 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 93 94 void ThrowIllegalAccessErrorClassForMethodDispatch(ObjPtr<mirror::Class> referrer, 95 ObjPtr<mirror::Class> accessed, 96 ArtMethod* called, 97 InvokeType type) 98 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 99 100 void ThrowIllegalAccessErrorMethod(ObjPtr<mirror::Class> referrer, ArtMethod* accessed) 101 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 102 103 void ThrowIllegalAccessErrorField(ObjPtr<mirror::Class> referrer, ArtField* accessed) 104 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 105 106 void ThrowIllegalAccessErrorFinalField(ArtMethod* referrer, ArtField* accessed) 107 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 108 109 void ThrowIllegalAccessError(ObjPtr<mirror::Class> referrer, const char* fmt, ...) 110 __attribute__((__format__(__printf__, 2, 3))) 111 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 112 113 // IllegalAccessException 114 115 void ThrowIllegalAccessException(const char* msg) 116 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 117 118 // IllegalArgumentException 119 120 void ThrowIllegalArgumentException(const char* msg) 121 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 122 123 // IncompatibleClassChangeError 124 125 void ThrowIncompatibleClassChangeError(InvokeType expected_type, 126 InvokeType found_type, 127 ArtMethod* method, 128 ArtMethod* referrer) 129 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 130 131 void ThrowIncompatibleClassChangeErrorClassForInterfaceSuper(ArtMethod* method, 132 ObjPtr<mirror::Class> target_class, 133 ObjPtr<mirror::Object> this_object, 134 ArtMethod* referrer) 135 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 136 137 void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(ArtMethod* interface_method, 138 ObjPtr<mirror::Object> this_object, 139 ArtMethod* referrer) 140 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 141 142 void ThrowIncompatibleClassChangeErrorField(ArtField* resolved_field, 143 bool is_static, 144 ArtMethod* referrer) 145 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 146 147 void ThrowIncompatibleClassChangeError(ObjPtr<mirror::Class> referrer, const char* fmt, ...) 148 __attribute__((__format__(__printf__, 2, 3))) 149 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 150 151 void ThrowIncompatibleClassChangeErrorForMethodConflict(ArtMethod* method) 152 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 153 154 // InternalError 155 156 void ThrowInternalError(const char* fmt, ...) 157 __attribute__((__format__(__printf__, 1, 2))) 158 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 159 160 // IOException 161 162 void ThrowIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2))) 163 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 164 165 void ThrowWrappedIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2))) 166 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 167 168 // LinkageError 169 170 void ThrowLinkageError(ObjPtr<mirror::Class> referrer, const char* fmt, ...) 171 __attribute__((__format__(__printf__, 2, 3))) 172 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 173 174 void ThrowWrappedLinkageError(ObjPtr<mirror::Class> referrer, const char* fmt, ...) 175 __attribute__((__format__(__printf__, 2, 3))) 176 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 177 178 // NegativeArraySizeException 179 180 void ThrowNegativeArraySizeException(int size) 181 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 182 183 void ThrowNegativeArraySizeException(const char* msg) 184 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 185 186 187 // NoSuchFieldError 188 189 void ThrowNoSuchFieldError(const StringPiece& scope, 190 ObjPtr<mirror::Class> c, 191 const StringPiece& type, 192 const StringPiece& name) 193 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 194 195 void ThrowNoSuchFieldException(ObjPtr<mirror::Class> c, const StringPiece& name) 196 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 197 198 // NoSuchMethodError 199 200 void ThrowNoSuchMethodError(InvokeType type, 201 ObjPtr<mirror::Class> c, 202 const StringPiece& name, 203 const Signature& signature) 204 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 205 206 // NullPointerException 207 208 void ThrowNullPointerExceptionForFieldAccess(ArtField* field, 209 bool is_read) 210 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 211 212 void ThrowNullPointerExceptionForMethodAccess(uint32_t method_idx, 213 InvokeType type) 214 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 215 216 void ThrowNullPointerExceptionForMethodAccess(ArtMethod* method, 217 InvokeType type) 218 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 219 220 void ThrowNullPointerExceptionFromDexPC(bool check_address = false, uintptr_t addr = 0) 221 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 222 223 void ThrowNullPointerException(const char* msg) 224 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 225 226 // RuntimeException 227 228 void ThrowRuntimeException(const char* fmt, ...) 229 __attribute__((__format__(__printf__, 1, 2))) 230 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 231 232 // SecurityException 233 234 void ThrowSecurityException(const char* fmt, ...) 235 __attribute__((__format__(__printf__, 1, 2))) 236 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 237 238 // Stack overflow. 239 240 void ThrowStackOverflowError(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 241 242 // StringIndexOutOfBoundsException 243 244 void ThrowStringIndexOutOfBoundsException(int index, int length) 245 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 246 247 // VerifyError 248 249 void ThrowVerifyError(ObjPtr<mirror::Class> referrer, const char* fmt, ...) 250 __attribute__((__format__(__printf__, 2, 3))) 251 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 252 253 // WrongMethodTypeException 254 void ThrowWrongMethodTypeException(mirror::MethodType* callee_type, 255 mirror::MethodType* callsite_type) 256 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 257 258 } // namespace art 259 260 #endif // ART_RUNTIME_COMMON_THROWS_H_ 261