Home | History | Annotate | Download | only in runtime
      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 "obj_ptr.h"
     22 
     23 namespace art {
     24 namespace mirror {
     25 class Class;
     26 class Object;
     27 class MethodType;
     28 }  // namespace mirror
     29 class ArtField;
     30 class ArtMethod;
     31 class DexFile;
     32 enum InvokeType : uint32_t;
     33 class Signature;
     34 class StringPiece;
     35 
     36 // AbstractMethodError
     37 
     38 void ThrowAbstractMethodError(ArtMethod* method)
     39     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     40 
     41 void ThrowAbstractMethodError(uint32_t method_idx, const DexFile& dex_file)
     42     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     43 
     44 // ArithmeticException
     45 
     46 void ThrowArithmeticExceptionDivideByZero() REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     47 
     48 // ArrayIndexOutOfBoundsException
     49 
     50 void ThrowArrayIndexOutOfBoundsException(int index, int length)
     51     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     52 
     53 // ArrayStoreException
     54 
     55 void ThrowArrayStoreException(ObjPtr<mirror::Class> element_class,
     56                               ObjPtr<mirror::Class> array_class)
     57     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     58 
     59 // BootstrapMethodError
     60 
     61 void ThrowBootstrapMethodError(const char* fmt, ...)
     62     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     63 
     64 void ThrowWrappedBootstrapMethodError(const char* fmt, ...)
     65     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     66 
     67 // ClassCircularityError
     68 
     69 void ThrowClassCircularityError(ObjPtr<mirror::Class> c)
     70     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     71 
     72 void ThrowClassCircularityError(ObjPtr<mirror::Class> c, const char* fmt, ...)
     73     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     74 
     75 // ClassCastException
     76 
     77 void ThrowClassCastException(ObjPtr<mirror::Class> dest_type, ObjPtr<mirror::Class> src_type)
     78     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     79 
     80 void ThrowClassCastException(const char* msg)
     81     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     82 
     83 // ClassFormatError
     84 
     85 void 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 
     91 void ThrowIllegalAccessErrorClass(ObjPtr<mirror::Class> referrer, ObjPtr<mirror::Class> accessed)
     92     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
     93 
     94 void 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 
    100 void ThrowIllegalAccessErrorMethod(ObjPtr<mirror::Class> referrer, ArtMethod* accessed)
    101     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    102 
    103 void ThrowIllegalAccessErrorField(ObjPtr<mirror::Class> referrer, ArtField* accessed)
    104     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    105 
    106 void ThrowIllegalAccessErrorFinalField(ArtMethod* referrer, ArtField* accessed)
    107     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    108 
    109 void 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 
    115 void ThrowIllegalAccessException(const char* msg)
    116     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    117 
    118 // IllegalArgumentException
    119 
    120 void ThrowIllegalArgumentException(const char* msg)
    121     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    122 
    123 // IllegalAccessException
    124 
    125 void ThrowIllegalStateException(const char* msg)
    126     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    127 
    128 // IncompatibleClassChangeError
    129 
    130 void ThrowIncompatibleClassChangeError(InvokeType expected_type,
    131                                        InvokeType found_type,
    132                                        ArtMethod* method,
    133                                        ArtMethod* referrer)
    134     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    135 
    136 void ThrowIncompatibleClassChangeErrorClassForInterfaceSuper(ArtMethod* method,
    137                                                              ObjPtr<mirror::Class> target_class,
    138                                                              ObjPtr<mirror::Object> this_object,
    139                                                              ArtMethod* referrer)
    140     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    141 
    142 void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(ArtMethod* interface_method,
    143                                                                 ObjPtr<mirror::Object> this_object,
    144                                                                 ArtMethod* referrer)
    145     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    146 
    147 void ThrowIncompatibleClassChangeErrorField(ArtField* resolved_field,
    148                                             bool is_static,
    149                                             ArtMethod* referrer)
    150     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    151 
    152 void ThrowIncompatibleClassChangeError(ObjPtr<mirror::Class> referrer, const char* fmt, ...)
    153     __attribute__((__format__(__printf__, 2, 3)))
    154     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    155 
    156 void ThrowIncompatibleClassChangeErrorForMethodConflict(ArtMethod* method)
    157     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    158 
    159 // IndexOutOfBoundsException
    160 
    161 void ThrowIndexOutOfBoundsException(int index, int length)
    162     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    163 
    164 // InternalError
    165 
    166 void ThrowInternalError(const char* fmt, ...)
    167     __attribute__((__format__(__printf__, 1, 2)))
    168     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    169 
    170 // IOException
    171 
    172 void ThrowIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2)))
    173     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    174 
    175 void ThrowWrappedIOException(const char* fmt, ...) __attribute__((__format__(__printf__, 1, 2)))
    176     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    177 
    178 // LinkageError
    179 
    180 void ThrowLinkageError(ObjPtr<mirror::Class> referrer, const char* fmt, ...)
    181     __attribute__((__format__(__printf__, 2, 3)))
    182     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    183 
    184 void ThrowWrappedLinkageError(ObjPtr<mirror::Class> referrer, const char* fmt, ...)
    185     __attribute__((__format__(__printf__, 2, 3)))
    186     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    187 
    188 // NegativeArraySizeException
    189 
    190 void ThrowNegativeArraySizeException(int size)
    191     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    192 
    193 void ThrowNegativeArraySizeException(const char* msg)
    194     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    195 
    196 
    197 // NoSuchFieldError
    198 
    199 void ThrowNoSuchFieldError(const StringPiece& scope,
    200                            ObjPtr<mirror::Class> c,
    201                            const StringPiece& type,
    202                            const StringPiece& name)
    203     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    204 
    205 void ThrowNoSuchFieldException(ObjPtr<mirror::Class> c, const StringPiece& name)
    206     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    207 
    208 // NoSuchMethodError
    209 
    210 void ThrowNoSuchMethodError(InvokeType type,
    211                             ObjPtr<mirror::Class> c,
    212                             const StringPiece& name,
    213                             const Signature& signature)
    214     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    215 
    216 // NullPointerException
    217 
    218 void ThrowNullPointerExceptionForFieldAccess(ArtField* field,
    219                                              bool is_read)
    220     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    221 
    222 void ThrowNullPointerExceptionForMethodAccess(uint32_t method_idx,
    223                                               InvokeType type)
    224     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    225 
    226 void ThrowNullPointerExceptionForMethodAccess(ArtMethod* method,
    227                                               InvokeType type)
    228     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    229 
    230 void ThrowNullPointerExceptionFromDexPC(bool check_address = false, uintptr_t addr = 0)
    231     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    232 
    233 void ThrowNullPointerException(const char* msg)
    234     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    235 
    236 // ReadOnlyBufferException
    237 
    238 void ThrowReadOnlyBufferException() REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    239 
    240 // RuntimeException
    241 
    242 void ThrowRuntimeException(const char* fmt, ...)
    243     __attribute__((__format__(__printf__, 1, 2)))
    244     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    245 
    246 // SecurityException
    247 
    248 void ThrowSecurityException(const char* fmt, ...)
    249     __attribute__((__format__(__printf__, 1, 2)))
    250     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    251 
    252 // Stack overflow.
    253 
    254 void ThrowStackOverflowError(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    255 
    256 // StringIndexOutOfBoundsException
    257 
    258 void ThrowStringIndexOutOfBoundsException(int index, int length)
    259     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    260 
    261 // UnsupportedOperationException
    262 
    263 void ThrowUnsupportedOperationException() REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    264 
    265 // VerifyError
    266 
    267 void ThrowVerifyError(ObjPtr<mirror::Class> referrer, const char* fmt, ...)
    268     __attribute__((__format__(__printf__, 2, 3)))
    269     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    270 
    271 // WrongMethodTypeException
    272 
    273 void ThrowWrongMethodTypeException(mirror::MethodType* callee_type,
    274                                    mirror::MethodType* callsite_type)
    275     REQUIRES_SHARED(Locks::mutator_lock_) COLD_ATTR;
    276 
    277 }  // namespace art
    278 
    279 #endif  // ART_RUNTIME_COMMON_THROWS_H_
    280