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 23namespace art { 24namespace mirror { 25 class Class; 26 class Object; 27} // namespace mirror 28class ArtField; 29class ArtMethod; 30class Signature; 31class StringPiece; 32 33// AbstractMethodError 34 35void ThrowAbstractMethodError(ArtMethod* method) 36 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 37 38// ArithmeticException 39 40void ThrowArithmeticExceptionDivideByZero() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 41 42// ArrayIndexOutOfBoundsException 43 44void ThrowArrayIndexOutOfBoundsException(int index, int length) 45 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 46 47// ArrayStoreException 48 49void ThrowArrayStoreException(mirror::Class* element_class, mirror::Class* array_class) 50 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 51 52// ClassCircularityError 53 54void ThrowClassCircularityError(mirror::Class* c) 55 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 56 57// ClassCastException 58 59void ThrowClassCastException(mirror::Class* dest_type, mirror::Class* src_type) 60 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 61 62void ThrowClassCastException(const char* msg) 63 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 64 65// ClassFormatError 66 67void ThrowClassFormatError(mirror::Class* referrer, const char* fmt, ...) 68 __attribute__((__format__(__printf__, 2, 3))) 69 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 70 71// IllegalAccessError 72 73void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* accessed) 74 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 75 76void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed, 77 ArtMethod* called, 78 InvokeType type) 79 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 80 81void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, ArtMethod* accessed) 82 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 83 84void ThrowIllegalAccessErrorField(mirror::Class* referrer, ArtField* accessed) 85 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 86 87void ThrowIllegalAccessErrorFinalField(ArtMethod* referrer, ArtField* accessed) 88 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 89 90void ThrowIllegalAccessError(mirror::Class* referrer, const char* fmt, ...) 91 __attribute__((__format__(__printf__, 2, 3))) 92 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 93 94// IllegalAccessException 95 96void ThrowIllegalAccessException(const char* msg) 97 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 98 99// IllegalArgumentException 100 101void ThrowIllegalArgumentException(const char* msg) 102 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 103 104// IncompatibleClassChangeError 105 106void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type, 107 ArtMethod* method, ArtMethod* referrer) 108 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 109 110void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(ArtMethod* interface_method, 111 mirror::Object* this_object, 112 ArtMethod* referrer) 113 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 114 115void ThrowIncompatibleClassChangeErrorField(ArtField* resolved_field, bool is_static, 116 ArtMethod* referrer) 117 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 118 119void ThrowIncompatibleClassChangeError(mirror::Class* referrer, const char* fmt, ...) 120 __attribute__((__format__(__printf__, 2, 3))) 121 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; 127 128void ThrowWrappedIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2))) 129 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 130 131// LinkageError 132 133void ThrowLinkageError(mirror::Class* referrer, const char* fmt, ...) 134 __attribute__((__format__(__printf__, 2, 3))) 135 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 136 137void ThrowWrappedLinkageError(mirror::Class* referrer, const char* fmt, ...) 138 __attribute__((__format__(__printf__, 2, 3))) 139 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 140 141// NegativeArraySizeException 142 143void ThrowNegativeArraySizeException(int size) 144 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 145 146void ThrowNegativeArraySizeException(const char* msg) 147 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 148 149 150// NoSuchFieldError 151 152void ThrowNoSuchFieldError(const StringPiece& scope, mirror::Class* c, 153 const StringPiece& type, const StringPiece& name) 154 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 155 156void ThrowNoSuchFieldException(mirror::Class* c, const StringPiece& name) 157 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 158 159// NoSuchMethodError 160 161void ThrowNoSuchMethodError(InvokeType type, mirror::Class* c, const StringPiece& name, 162 const Signature& signature) 163 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 164 165void ThrowNoSuchMethodError(uint32_t method_idx) 166 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 167 168// NullPointerException 169 170void ThrowNullPointerExceptionForFieldAccess(ArtField* field, 171 bool is_read) 172 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 173 174void ThrowNullPointerExceptionForMethodAccess(uint32_t method_idx, 175 InvokeType type) 176 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 177 178void ThrowNullPointerExceptionForMethodAccess(ArtMethod* method, 179 InvokeType type) 180 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 181 182void ThrowNullPointerExceptionFromDexPC() 183 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 184 185void ThrowNullPointerException(const char* msg) 186 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 187 188// RuntimeException 189 190void ThrowRuntimeException(const char* fmt, ...) 191 __attribute__((__format__(__printf__, 1, 2))) 192 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 193 194// VerifyError 195 196void ThrowVerifyError(mirror::Class* referrer, const char* fmt, ...) 197 __attribute__((__format__(__printf__, 2, 3))) 198 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR; 199 200} // namespace art 201 202#endif // ART_RUNTIME_COMMON_THROWS_H_ 203