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