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