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