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