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