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 24namespace art { 25namespace mirror { 26 class Class; 27 class Object; 28 class MethodType; 29} // namespace mirror 30class ArtField; 31class ArtMethod; 32class DexFile; 33class Signature; 34class StringPiece; 35 36// AbstractMethodError 37 38void ThrowAbstractMethodError(ArtMethod* method) 39 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 40 41void ThrowAbstractMethodError(uint32_t method_idx, const DexFile& dex_file) 42 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 43 44// ArithmeticException 45 46void ThrowArithmeticExceptionDivideByZero() REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 47 48// ArrayIndexOutOfBoundsException 49 50void ThrowArrayIndexOutOfBoundsException(int index, int length) 51 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 52 53// ArrayStoreException 54 55void ThrowArrayStoreException(ObjPtr<mirror::Class> element_class, 56 ObjPtr<mirror::Class> array_class) 57 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 58 59// BootstrapMethodError 60 61void ThrowBootstrapMethodError(const char* fmt, ...) 62 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 63 64void ThrowWrappedBootstrapMethodError(const char* fmt, ...) 65 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 66 67// ClassCircularityError 68 69void ThrowClassCircularityError(ObjPtr<mirror::Class> c) 70 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 71 72void ThrowClassCircularityError(ObjPtr<mirror::Class> c, const char* fmt, ...) 73 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 74 75// ClassCastException 76 77void ThrowClassCastException(ObjPtr<mirror::Class> dest_type, ObjPtr<mirror::Class> src_type) 78 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 79 80void ThrowClassCastException(const char* msg) 81 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 82 83// ClassFormatError 84 85void 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 91void ThrowIllegalAccessErrorClass(ObjPtr<mirror::Class> referrer, ObjPtr<mirror::Class> accessed) 92 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 93 94void 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 100void ThrowIllegalAccessErrorMethod(ObjPtr<mirror::Class> referrer, ArtMethod* accessed) 101 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 102 103void ThrowIllegalAccessErrorField(ObjPtr<mirror::Class> referrer, ArtField* accessed) 104 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 105 106void ThrowIllegalAccessErrorFinalField(ArtMethod* referrer, ArtField* accessed) 107 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 108 109void 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 115void ThrowIllegalAccessException(const char* msg) 116 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 117 118// IllegalArgumentException 119 120void ThrowIllegalArgumentException(const char* msg) 121 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 122 123// IncompatibleClassChangeError 124 125void ThrowIncompatibleClassChangeError(InvokeType expected_type, 126 InvokeType found_type, 127 ArtMethod* method, 128 ArtMethod* referrer) 129 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 130 131void 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 137void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(ArtMethod* interface_method, 138 ObjPtr<mirror::Object> this_object, 139 ArtMethod* referrer) 140 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 141 142void ThrowIncompatibleClassChangeErrorField(ArtField* resolved_field, 143 bool is_static, 144 ArtMethod* referrer) 145 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 146 147void ThrowIncompatibleClassChangeError(ObjPtr<mirror::Class> referrer, const char* fmt, ...) 148 __attribute__((__format__(__printf__, 2, 3))) 149 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 150 151void ThrowIncompatibleClassChangeErrorForMethodConflict(ArtMethod* method) 152 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 153 154// InternalError 155 156void ThrowInternalError(const char* fmt, ...) 157 __attribute__((__format__(__printf__, 1, 2))) 158 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 159 160// IOException 161 162void ThrowIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2))) 163 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 164 165void ThrowWrappedIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2))) 166 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 167 168// LinkageError 169 170void ThrowLinkageError(ObjPtr<mirror::Class> referrer, const char* fmt, ...) 171 __attribute__((__format__(__printf__, 2, 3))) 172 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 173 174void 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 180void ThrowNegativeArraySizeException(int size) 181 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 182 183void ThrowNegativeArraySizeException(const char* msg) 184 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 185 186 187// NoSuchFieldError 188 189void 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 195void ThrowNoSuchFieldException(ObjPtr<mirror::Class> c, const StringPiece& name) 196 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 197 198// NoSuchMethodError 199 200void 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 208void ThrowNullPointerExceptionForFieldAccess(ArtField* field, 209 bool is_read) 210 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 211 212void ThrowNullPointerExceptionForMethodAccess(uint32_t method_idx, 213 InvokeType type) 214 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 215 216void ThrowNullPointerExceptionForMethodAccess(ArtMethod* method, 217 InvokeType type) 218 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 219 220void ThrowNullPointerExceptionFromDexPC(bool check_address = false, uintptr_t addr = 0) 221 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 222 223void ThrowNullPointerException(const char* msg) 224 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 225 226// RuntimeException 227 228void ThrowRuntimeException(const char* fmt, ...) 229 __attribute__((__format__(__printf__, 1, 2))) 230 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 231 232// SecurityException 233 234void ThrowSecurityException(const char* fmt, ...) 235 __attribute__((__format__(__printf__, 1, 2))) 236 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 237 238// Stack overflow. 239 240void ThrowStackOverflowError(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 241 242// StringIndexOutOfBoundsException 243 244void ThrowStringIndexOutOfBoundsException(int index, int length) 245 REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR; 246 247// VerifyError 248 249void 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 254void 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