Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 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 | #include "common_throws.h" |
| 18 | |
Ian Rogers | 22d5e73 | 2014-07-15 22:23:51 -0700 | [diff] [blame] | 19 | #include <sstream> |
| 20 | |
Andreas Gampe | 103992b | 2016-01-04 15:32:43 -0800 | [diff] [blame] | 21 | #include "ScopedLocalRef.h" |
| 22 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 23 | #include "art_field-inl.h" |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 24 | #include "art_method-inl.h" |
Elliott Hughes | 07ed66b | 2012-12-12 18:34:25 -0800 | [diff] [blame] | 25 | #include "base/logging.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 26 | #include "class_linker-inl.h" |
Ian Rogers | 4f6ad8a | 2013-03-18 15:27:28 -0700 | [diff] [blame] | 27 | #include "dex_file-inl.h" |
Sebastien Hertz | 75b2a4a | 2013-05-21 09:25:10 +0200 | [diff] [blame] | 28 | #include "dex_instruction-inl.h" |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 29 | #include "invoke_type.h" |
Ian Rogers | 4f6ad8a | 2013-03-18 15:27:28 -0700 | [diff] [blame] | 30 | #include "mirror/class-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 31 | #include "mirror/object-inl.h" |
| 32 | #include "mirror/object_array-inl.h" |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 33 | #include "thread.h" |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 34 | #include "verifier/method_verifier.h" |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 35 | |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 36 | namespace art { |
| 37 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 38 | static void AddReferrerLocation(std::ostream& os, mirror::Class* referrer) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 39 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 40 | if (referrer != nullptr) { |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 41 | std::string location(referrer->GetLocation()); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 42 | if (!location.empty()) { |
| 43 | os << " (declaration of '" << PrettyDescriptor(referrer) |
| 44 | << "' appears in " << location << ")"; |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 49 | static void ThrowException(const char* exception_descriptor, |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 50 | mirror::Class* referrer, const char* fmt, va_list* args = nullptr) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 51 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 52 | std::ostringstream msg; |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 53 | if (args != nullptr) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 54 | std::string vmsg; |
| 55 | StringAppendV(&vmsg, fmt, *args); |
| 56 | msg << vmsg; |
| 57 | } else { |
| 58 | msg << fmt; |
| 59 | } |
| 60 | AddReferrerLocation(msg, referrer); |
| 61 | Thread* self = Thread::Current(); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 62 | self->ThrowNewException(exception_descriptor, msg.str().c_str()); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 65 | static void ThrowWrappedException(const char* exception_descriptor, |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 66 | mirror::Class* referrer, const char* fmt, va_list* args = nullptr) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 67 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 329d188 | 2014-04-08 10:32:19 -0700 | [diff] [blame] | 68 | std::ostringstream msg; |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 69 | if (args != nullptr) { |
Andreas Gampe | 329d188 | 2014-04-08 10:32:19 -0700 | [diff] [blame] | 70 | std::string vmsg; |
| 71 | StringAppendV(&vmsg, fmt, *args); |
| 72 | msg << vmsg; |
| 73 | } else { |
| 74 | msg << fmt; |
| 75 | } |
| 76 | AddReferrerLocation(msg, referrer); |
| 77 | Thread* self = Thread::Current(); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 78 | self->ThrowNewWrappedException(exception_descriptor, msg.str().c_str()); |
Andreas Gampe | 329d188 | 2014-04-08 10:32:19 -0700 | [diff] [blame] | 79 | } |
| 80 | |
Sebastien Hertz | 56adf60 | 2013-07-09 17:27:07 +0200 | [diff] [blame] | 81 | // AbstractMethodError |
| 82 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 83 | void ThrowAbstractMethodError(ArtMethod* method) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 84 | ThrowException("Ljava/lang/AbstractMethodError;", nullptr, |
Sebastien Hertz | 56adf60 | 2013-07-09 17:27:07 +0200 | [diff] [blame] | 85 | StringPrintf("abstract method \"%s\"", |
| 86 | PrettyMethod(method).c_str()).c_str()); |
| 87 | } |
| 88 | |
Alex Light | 705ad49 | 2015-09-21 11:36:30 -0700 | [diff] [blame] | 89 | void ThrowAbstractMethodError(uint32_t method_idx, const DexFile& dex_file) { |
| 90 | ThrowException("Ljava/lang/AbstractMethodError;", /* referrer */ nullptr, |
| 91 | StringPrintf("abstract method \"%s\"", |
| 92 | PrettyMethod(method_idx, |
| 93 | dex_file, |
| 94 | /* with_signature */ true).c_str()).c_str()); |
| 95 | } |
| 96 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 97 | // ArithmeticException |
| 98 | |
Sebastien Hertz | 0a3b863 | 2013-06-26 11:16:01 +0200 | [diff] [blame] | 99 | void ThrowArithmeticExceptionDivideByZero() { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 100 | ThrowException("Ljava/lang/ArithmeticException;", nullptr, "divide by zero"); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | // ArrayIndexOutOfBoundsException |
| 104 | |
| 105 | void ThrowArrayIndexOutOfBoundsException(int index, int length) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 106 | ThrowException("Ljava/lang/ArrayIndexOutOfBoundsException;", nullptr, |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 107 | StringPrintf("length=%d; index=%d", length, index).c_str()); |
| 108 | } |
| 109 | |
| 110 | // ArrayStoreException |
| 111 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 112 | void ThrowArrayStoreException(mirror::Class* element_class, mirror::Class* array_class) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 113 | ThrowException("Ljava/lang/ArrayStoreException;", nullptr, |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 114 | StringPrintf("%s cannot be stored in an array of type %s", |
| 115 | PrettyDescriptor(element_class).c_str(), |
| 116 | PrettyDescriptor(array_class).c_str()).c_str()); |
| 117 | } |
| 118 | |
| 119 | // ClassCastException |
| 120 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 121 | void ThrowClassCastException(mirror::Class* dest_type, mirror::Class* src_type) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 122 | ThrowException("Ljava/lang/ClassCastException;", nullptr, |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 123 | StringPrintf("%s cannot be cast to %s", |
| 124 | PrettyDescriptor(src_type).c_str(), |
| 125 | PrettyDescriptor(dest_type).c_str()).c_str()); |
| 126 | } |
| 127 | |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 128 | void ThrowClassCastException(const char* msg) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 129 | ThrowException("Ljava/lang/ClassCastException;", nullptr, msg); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | // ClassCircularityError |
| 133 | |
| 134 | void ThrowClassCircularityError(mirror::Class* c) { |
| 135 | std::ostringstream msg; |
| 136 | msg << PrettyDescriptor(c); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 137 | ThrowException("Ljava/lang/ClassCircularityError;", c, msg.str().c_str()); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 138 | } |
| 139 | |
Roland Levillain | 989ab3b | 2016-05-18 15:52:54 +0100 | [diff] [blame] | 140 | void ThrowClassCircularityError(mirror::Class* c, const char* fmt, ...) { |
| 141 | va_list args; |
| 142 | va_start(args, fmt); |
| 143 | ThrowException("Ljava/lang/ClassCircularityError;", c, fmt, &args); |
| 144 | va_end(args); |
| 145 | } |
| 146 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 147 | // ClassFormatError |
| 148 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 149 | void ThrowClassFormatError(mirror::Class* referrer, const char* fmt, ...) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 150 | va_list args; |
| 151 | va_start(args, fmt); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 152 | ThrowException("Ljava/lang/ClassFormatError;", referrer, fmt, &args); |
Roland Levillain | ab880f4 | 2016-05-12 16:24:36 +0100 | [diff] [blame] | 153 | va_end(args); |
| 154 | } |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 155 | |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 156 | // IllegalAccessError |
| 157 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 158 | void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* accessed) { |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 159 | std::ostringstream msg; |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 160 | msg << "Illegal class access: '" << PrettyDescriptor(referrer) << "' attempting to access '" |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 161 | << PrettyDescriptor(accessed) << "'"; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 162 | ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 165 | void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 166 | ArtMethod* called, |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 167 | InvokeType type) { |
| 168 | std::ostringstream msg; |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 169 | msg << "Illegal class access ('" << PrettyDescriptor(referrer) << "' attempting to access '" |
| 170 | << PrettyDescriptor(accessed) << "') in attempt to invoke " << type |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 171 | << " method " << PrettyMethod(called).c_str(); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 172 | ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 175 | void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, ArtMethod* accessed) { |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 176 | std::ostringstream msg; |
| 177 | msg << "Method '" << PrettyMethod(accessed) << "' is inaccessible to class '" |
| 178 | << PrettyDescriptor(referrer) << "'"; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 179 | ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 182 | void ThrowIllegalAccessErrorField(mirror::Class* referrer, ArtField* accessed) { |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 183 | std::ostringstream msg; |
| 184 | msg << "Field '" << PrettyField(accessed, false) << "' is inaccessible to class '" |
| 185 | << PrettyDescriptor(referrer) << "'"; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 186 | ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 189 | void ThrowIllegalAccessErrorFinalField(ArtMethod* referrer, ArtField* accessed) { |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 190 | std::ostringstream msg; |
| 191 | msg << "Final field '" << PrettyField(accessed, false) << "' cannot be written to by method '" |
| 192 | << PrettyMethod(referrer) << "'"; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 193 | ThrowException("Ljava/lang/IllegalAccessError;", |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 194 | referrer != nullptr ? referrer->GetDeclaringClass() : nullptr, |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 195 | msg.str().c_str()); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 198 | void ThrowIllegalAccessError(mirror::Class* referrer, const char* fmt, ...) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 199 | va_list args; |
| 200 | va_start(args, fmt); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 201 | ThrowException("Ljava/lang/IllegalAccessError;", referrer, fmt, &args); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 202 | va_end(args); |
| 203 | } |
| 204 | |
Jeff Hao | 11d5d8f | 2014-03-26 15:08:20 -0700 | [diff] [blame] | 205 | // IllegalAccessException |
| 206 | |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 207 | void ThrowIllegalAccessException(const char* msg) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 208 | ThrowException("Ljava/lang/IllegalAccessException;", nullptr, msg); |
Jeff Hao | 11d5d8f | 2014-03-26 15:08:20 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 211 | // IllegalArgumentException |
| 212 | |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 213 | void ThrowIllegalArgumentException(const char* msg) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 214 | ThrowException("Ljava/lang/IllegalArgumentException;", nullptr, msg); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 218 | // IncompatibleClassChangeError |
| 219 | |
| 220 | void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 221 | ArtMethod* method, ArtMethod* referrer) { |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 222 | std::ostringstream msg; |
| 223 | msg << "The method '" << PrettyMethod(method) << "' was expected to be of type " |
| 224 | << expected_type << " but instead was found to be of type " << found_type; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 225 | ThrowException("Ljava/lang/IncompatibleClassChangeError;", |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 226 | referrer != nullptr ? referrer->GetDeclaringClass() : nullptr, |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 227 | msg.str().c_str()); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Alex Light | 705ad49 | 2015-09-21 11:36:30 -0700 | [diff] [blame] | 230 | void ThrowIncompatibleClassChangeErrorClassForInterfaceSuper(ArtMethod* method, |
| 231 | mirror::Class* target_class, |
| 232 | mirror::Object* this_object, |
| 233 | ArtMethod* referrer) { |
| 234 | // Referrer is calling interface_method on this_object, however, the interface_method isn't |
| 235 | // implemented by this_object. |
| 236 | CHECK(this_object != nullptr); |
| 237 | std::ostringstream msg; |
| 238 | msg << "Class '" << PrettyDescriptor(this_object->GetClass()) |
| 239 | << "' does not implement interface '" << PrettyDescriptor(target_class) << "' in call to '" |
| 240 | << PrettyMethod(method) << "'"; |
| 241 | ThrowException("Ljava/lang/IncompatibleClassChangeError;", |
| 242 | referrer != nullptr ? referrer->GetDeclaringClass() : nullptr, |
| 243 | msg.str().c_str()); |
| 244 | } |
| 245 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 246 | void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(ArtMethod* interface_method, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 247 | mirror::Object* this_object, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 248 | ArtMethod* referrer) { |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 249 | // Referrer is calling interface_method on this_object, however, the interface_method isn't |
| 250 | // implemented by this_object. |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 251 | CHECK(this_object != nullptr); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 252 | std::ostringstream msg; |
| 253 | msg << "Class '" << PrettyDescriptor(this_object->GetClass()) |
| 254 | << "' does not implement interface '" |
| 255 | << PrettyDescriptor(interface_method->GetDeclaringClass()) |
| 256 | << "' in call to '" << PrettyMethod(interface_method) << "'"; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 257 | ThrowException("Ljava/lang/IncompatibleClassChangeError;", |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 258 | referrer != nullptr ? referrer->GetDeclaringClass() : nullptr, |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 259 | msg.str().c_str()); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 262 | void ThrowIncompatibleClassChangeErrorField(ArtField* resolved_field, bool is_static, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 263 | ArtMethod* referrer) { |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 264 | std::ostringstream msg; |
| 265 | msg << "Expected '" << PrettyField(resolved_field) << "' to be a " |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 266 | << (is_static ? "static" : "instance") << " field" << " rather than a " |
| 267 | << (is_static ? "instance" : "static") << " field"; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 268 | ThrowException("Ljava/lang/IncompatibleClassChangeError;", referrer->GetDeclaringClass(), |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 269 | msg.str().c_str()); |
| 270 | } |
| 271 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 272 | void ThrowIncompatibleClassChangeError(mirror::Class* referrer, const char* fmt, ...) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 273 | va_list args; |
| 274 | va_start(args, fmt); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 275 | ThrowException("Ljava/lang/IncompatibleClassChangeError;", referrer, fmt, &args); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 276 | va_end(args); |
| 277 | } |
| 278 | |
Alex Light | 9139e00 | 2015-10-09 15:59:48 -0700 | [diff] [blame] | 279 | void ThrowIncompatibleClassChangeErrorForMethodConflict(ArtMethod* method) { |
| 280 | DCHECK(method != nullptr); |
| 281 | ThrowException("Ljava/lang/IncompatibleClassChangeError;", |
| 282 | /*referrer*/nullptr, |
| 283 | StringPrintf("Conflicting default method implementations %s", |
| 284 | PrettyMethod(method).c_str()).c_str()); |
| 285 | } |
| 286 | |
| 287 | |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 288 | // IOException |
| 289 | |
| 290 | void ThrowIOException(const char* fmt, ...) { |
| 291 | va_list args; |
| 292 | va_start(args, fmt); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 293 | ThrowException("Ljava/io/IOException;", nullptr, fmt, &args); |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 294 | va_end(args); |
| 295 | } |
| 296 | |
Andreas Gampe | 329d188 | 2014-04-08 10:32:19 -0700 | [diff] [blame] | 297 | void ThrowWrappedIOException(const char* fmt, ...) { |
| 298 | va_list args; |
| 299 | va_start(args, fmt); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 300 | ThrowWrappedException("Ljava/io/IOException;", nullptr, fmt, &args); |
Andreas Gampe | 329d188 | 2014-04-08 10:32:19 -0700 | [diff] [blame] | 301 | va_end(args); |
| 302 | } |
| 303 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 304 | // LinkageError |
| 305 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 306 | void ThrowLinkageError(mirror::Class* referrer, const char* fmt, ...) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 307 | va_list args; |
| 308 | va_start(args, fmt); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 309 | ThrowException("Ljava/lang/LinkageError;", referrer, fmt, &args); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 310 | va_end(args); |
| 311 | } |
| 312 | |
Vladimir Marko | d5e5a0e | 2015-05-08 12:26:59 +0100 | [diff] [blame] | 313 | void ThrowWrappedLinkageError(mirror::Class* referrer, const char* fmt, ...) { |
| 314 | va_list args; |
| 315 | va_start(args, fmt); |
| 316 | ThrowWrappedException("Ljava/lang/LinkageError;", referrer, fmt, &args); |
| 317 | va_end(args); |
| 318 | } |
| 319 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 320 | // NegativeArraySizeException |
| 321 | |
| 322 | void ThrowNegativeArraySizeException(int size) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 323 | ThrowException("Ljava/lang/NegativeArraySizeException;", nullptr, |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 324 | StringPrintf("%d", size).c_str()); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | void ThrowNegativeArraySizeException(const char* msg) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 328 | ThrowException("Ljava/lang/NegativeArraySizeException;", nullptr, msg); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | // NoSuchFieldError |
| 332 | |
| 333 | void ThrowNoSuchFieldError(const StringPiece& scope, mirror::Class* c, |
Mathieu Chartier | 4e06778 | 2015-05-13 13:13:24 -0700 | [diff] [blame] | 334 | const StringPiece& type, const StringPiece& name) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 335 | std::ostringstream msg; |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 336 | std::string temp; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 337 | msg << "No " << scope << "field " << name << " of type " << type |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 338 | << " in class " << c->GetDescriptor(&temp) << " or its superclasses"; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 339 | ThrowException("Ljava/lang/NoSuchFieldError;", c, msg.str().c_str()); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 340 | } |
| 341 | |
Mathieu Chartier | 4e06778 | 2015-05-13 13:13:24 -0700 | [diff] [blame] | 342 | void ThrowNoSuchFieldException(mirror::Class* c, const StringPiece& name) { |
| 343 | std::ostringstream msg; |
| 344 | std::string temp; |
| 345 | msg << "No field " << name << " in class " << c->GetDescriptor(&temp); |
| 346 | ThrowException("Ljava/lang/NoSuchFieldException;", c, msg.str().c_str()); |
| 347 | } |
| 348 | |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 349 | // NoSuchMethodError |
| 350 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 351 | void ThrowNoSuchMethodError(InvokeType type, mirror::Class* c, const StringPiece& name, |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 352 | const Signature& signature) { |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 353 | std::ostringstream msg; |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 354 | std::string temp; |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 355 | msg << "No " << type << " method " << name << signature |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 356 | << " in class " << c->GetDescriptor(&temp) << " or its super classes"; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 357 | ThrowException("Ljava/lang/NoSuchMethodError;", c, msg.str().c_str()); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 358 | } |
| 359 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 360 | void ThrowNoSuchMethodError(uint32_t method_idx) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 361 | ArtMethod* method = Thread::Current()->GetCurrentMethod(nullptr); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 362 | mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache(); |
Ian Rogers | 4445a7e | 2012-10-05 17:19:13 -0700 | [diff] [blame] | 363 | const DexFile& dex_file = *dex_cache->GetDexFile(); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 364 | std::ostringstream msg; |
| 365 | msg << "No method '" << PrettyMethod(method_idx, dex_file, true) << "'"; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 366 | ThrowException("Ljava/lang/NoSuchMethodError;", |
| 367 | method->GetDeclaringClass(), msg.str().c_str()); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | // NullPointerException |
| 371 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 372 | void ThrowNullPointerExceptionForFieldAccess(ArtField* field, bool is_read) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 373 | std::ostringstream msg; |
| 374 | msg << "Attempt to " << (is_read ? "read from" : "write to") |
| 375 | << " field '" << PrettyField(field, true) << "' on a null object reference"; |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 376 | ThrowException("Ljava/lang/NullPointerException;", nullptr, msg.str().c_str()); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 377 | } |
| 378 | |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 379 | static void ThrowNullPointerExceptionForMethodAccessImpl(uint32_t method_idx, |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 380 | const DexFile& dex_file, |
| 381 | InvokeType type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 382 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 383 | std::ostringstream msg; |
| 384 | msg << "Attempt to invoke " << type << " method '" |
| 385 | << PrettyMethod(method_idx, dex_file, true) << "' on a null object reference"; |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 386 | ThrowException("Ljava/lang/NullPointerException;", nullptr, msg.str().c_str()); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 387 | } |
| 388 | |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 389 | void ThrowNullPointerExceptionForMethodAccess(uint32_t method_idx, |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 390 | InvokeType type) { |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 391 | mirror::DexCache* dex_cache = |
| 392 | Thread::Current()->GetCurrentMethod(nullptr)->GetDeclaringClass()->GetDexCache(); |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 393 | const DexFile& dex_file = *dex_cache->GetDexFile(); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 394 | ThrowNullPointerExceptionForMethodAccessImpl(method_idx, dex_file, type); |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 395 | } |
| 396 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 397 | void ThrowNullPointerExceptionForMethodAccess(ArtMethod* method, |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 398 | InvokeType type) { |
| 399 | mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache(); |
| 400 | const DexFile& dex_file = *dex_cache->GetDexFile(); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 401 | ThrowNullPointerExceptionForMethodAccessImpl(method->GetDexMethodIndex(), |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 402 | dex_file, type); |
| 403 | } |
| 404 | |
Vladimir Marko | 953437b | 2016-08-24 08:30:46 +0000 | [diff] [blame] | 405 | static bool IsValidReadBarrierImplicitCheck(uintptr_t addr) { |
| 406 | DCHECK(kEmitCompilerReadBarrier); |
| 407 | uint32_t monitor_offset = mirror::Object::MonitorOffset().Uint32Value(); |
| 408 | if (kUseBakerReadBarrier && (kRuntimeISA == kX86 || kRuntimeISA == kX86_64)) { |
| 409 | constexpr uint32_t gray_byte_position = LockWord::kReadBarrierStateShift / kBitsPerByte; |
| 410 | monitor_offset += gray_byte_position; |
| 411 | } |
| 412 | return addr == monitor_offset; |
| 413 | } |
| 414 | |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 415 | static bool IsValidImplicitCheck(uintptr_t addr, ArtMethod* method, const Instruction& instr) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 416 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 417 | if (!CanDoImplicitNullCheckOn(addr)) { |
| 418 | return false; |
| 419 | } |
| 420 | |
| 421 | switch (instr.Opcode()) { |
| 422 | case Instruction::INVOKE_DIRECT: |
| 423 | case Instruction::INVOKE_DIRECT_RANGE: |
| 424 | case Instruction::INVOKE_VIRTUAL: |
| 425 | case Instruction::INVOKE_VIRTUAL_RANGE: |
| 426 | case Instruction::INVOKE_INTERFACE: |
| 427 | case Instruction::INVOKE_INTERFACE_RANGE: |
| 428 | case Instruction::INVOKE_VIRTUAL_QUICK: |
| 429 | case Instruction::INVOKE_VIRTUAL_RANGE_QUICK: { |
| 430 | // Without inlining, we could just check that the offset is the class offset. |
| 431 | // However, when inlining, the compiler can (validly) merge the null check with a field access |
| 432 | // on the same object. Note that the stack map at the NPE will reflect the invoke's location, |
| 433 | // which is the caller. |
| 434 | return true; |
| 435 | } |
| 436 | |
Vladimir Marko | 953437b | 2016-08-24 08:30:46 +0000 | [diff] [blame] | 437 | case Instruction::IGET_OBJECT: |
| 438 | if (kEmitCompilerReadBarrier && IsValidReadBarrierImplicitCheck(addr)) { |
| 439 | return true; |
| 440 | } |
| 441 | FALLTHROUGH_INTENDED; |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 442 | case Instruction::IGET: |
| 443 | case Instruction::IGET_WIDE: |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 444 | case Instruction::IGET_BOOLEAN: |
| 445 | case Instruction::IGET_BYTE: |
| 446 | case Instruction::IGET_CHAR: |
| 447 | case Instruction::IGET_SHORT: |
| 448 | case Instruction::IPUT: |
| 449 | case Instruction::IPUT_WIDE: |
| 450 | case Instruction::IPUT_OBJECT: |
| 451 | case Instruction::IPUT_BOOLEAN: |
| 452 | case Instruction::IPUT_BYTE: |
| 453 | case Instruction::IPUT_CHAR: |
| 454 | case Instruction::IPUT_SHORT: { |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 455 | ArtField* field = |
| 456 | Runtime::Current()->GetClassLinker()->ResolveField(instr.VRegC_22c(), method, false); |
Vladimir Marko | 953437b | 2016-08-24 08:30:46 +0000 | [diff] [blame] | 457 | return (addr == 0) || (addr == field->GetOffset().Uint32Value()); |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 458 | } |
| 459 | |
Vladimir Marko | 953437b | 2016-08-24 08:30:46 +0000 | [diff] [blame] | 460 | case Instruction::IGET_OBJECT_QUICK: |
| 461 | if (kEmitCompilerReadBarrier && IsValidReadBarrierImplicitCheck(addr)) { |
| 462 | return true; |
| 463 | } |
| 464 | FALLTHROUGH_INTENDED; |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 465 | case Instruction::IGET_QUICK: |
| 466 | case Instruction::IGET_BOOLEAN_QUICK: |
| 467 | case Instruction::IGET_BYTE_QUICK: |
| 468 | case Instruction::IGET_CHAR_QUICK: |
| 469 | case Instruction::IGET_SHORT_QUICK: |
| 470 | case Instruction::IGET_WIDE_QUICK: |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 471 | case Instruction::IPUT_QUICK: |
| 472 | case Instruction::IPUT_BOOLEAN_QUICK: |
| 473 | case Instruction::IPUT_BYTE_QUICK: |
| 474 | case Instruction::IPUT_CHAR_QUICK: |
| 475 | case Instruction::IPUT_SHORT_QUICK: |
| 476 | case Instruction::IPUT_WIDE_QUICK: |
| 477 | case Instruction::IPUT_OBJECT_QUICK: { |
Vladimir Marko | 953437b | 2016-08-24 08:30:46 +0000 | [diff] [blame] | 478 | return (addr == 0u) || (addr == instr.VRegC_22c()); |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 479 | } |
| 480 | |
Vladimir Marko | 953437b | 2016-08-24 08:30:46 +0000 | [diff] [blame] | 481 | case Instruction::AGET_OBJECT: |
| 482 | if (kEmitCompilerReadBarrier && IsValidReadBarrierImplicitCheck(addr)) { |
| 483 | return true; |
| 484 | } |
| 485 | FALLTHROUGH_INTENDED; |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 486 | case Instruction::AGET: |
| 487 | case Instruction::AGET_WIDE: |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 488 | case Instruction::AGET_BOOLEAN: |
| 489 | case Instruction::AGET_BYTE: |
| 490 | case Instruction::AGET_CHAR: |
| 491 | case Instruction::AGET_SHORT: |
| 492 | case Instruction::APUT: |
| 493 | case Instruction::APUT_WIDE: |
| 494 | case Instruction::APUT_OBJECT: |
| 495 | case Instruction::APUT_BOOLEAN: |
| 496 | case Instruction::APUT_BYTE: |
| 497 | case Instruction::APUT_CHAR: |
Nicolas Geoffray | 350cc99 | 2016-06-29 21:45:10 +0100 | [diff] [blame] | 498 | case Instruction::APUT_SHORT: |
| 499 | case Instruction::FILL_ARRAY_DATA: |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 500 | case Instruction::ARRAY_LENGTH: { |
Nicolas Geoffray | 350cc99 | 2016-06-29 21:45:10 +0100 | [diff] [blame] | 501 | // The length access should crash. We currently do not do implicit checks on |
| 502 | // the array access itself. |
Vladimir Marko | 953437b | 2016-08-24 08:30:46 +0000 | [diff] [blame] | 503 | return (addr == 0u) || (addr == mirror::Array::LengthOffset().Uint32Value()); |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | default: { |
| 507 | // We have covered all the cases where an NPE could occur. |
| 508 | // Note that this must be kept in sync with the compiler, and adding |
| 509 | // any new way to do implicit checks in the compiler should also update |
| 510 | // this code. |
| 511 | return false; |
| 512 | } |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | void ThrowNullPointerExceptionFromDexPC(bool check_address, uintptr_t addr) { |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 517 | uint32_t throw_dex_pc; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 518 | ArtMethod* method = Thread::Current()->GetCurrentMethod(&throw_dex_pc); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 519 | const DexFile::CodeItem* code = method->GetCodeItem(); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 520 | CHECK_LT(throw_dex_pc, code->insns_size_in_code_units_); |
| 521 | const Instruction* instr = Instruction::At(&code->insns_[throw_dex_pc]); |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 522 | if (check_address && !IsValidImplicitCheck(addr, method, *instr)) { |
| 523 | const DexFile* dex_file = method->GetDeclaringClass()->GetDexCache()->GetDexFile(); |
| 524 | LOG(FATAL) << "Invalid address for an implicit NullPointerException check: " |
| 525 | << "0x" << std::hex << addr << std::dec |
| 526 | << ", at " |
| 527 | << instr->DumpString(dex_file) |
| 528 | << " in " |
| 529 | << PrettyMethod(method); |
| 530 | } |
| 531 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 532 | switch (instr->Opcode()) { |
| 533 | case Instruction::INVOKE_DIRECT: |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 534 | ThrowNullPointerExceptionForMethodAccess(instr->VRegB_35c(), kDirect); |
Sebastien Hertz | 75b2a4a | 2013-05-21 09:25:10 +0200 | [diff] [blame] | 535 | break; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 536 | case Instruction::INVOKE_DIRECT_RANGE: |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 537 | ThrowNullPointerExceptionForMethodAccess(instr->VRegB_3rc(), kDirect); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 538 | break; |
| 539 | case Instruction::INVOKE_VIRTUAL: |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 540 | ThrowNullPointerExceptionForMethodAccess(instr->VRegB_35c(), kVirtual); |
Sebastien Hertz | 75b2a4a | 2013-05-21 09:25:10 +0200 | [diff] [blame] | 541 | break; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 542 | case Instruction::INVOKE_VIRTUAL_RANGE: |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 543 | ThrowNullPointerExceptionForMethodAccess(instr->VRegB_3rc(), kVirtual); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 544 | break; |
| 545 | case Instruction::INVOKE_INTERFACE: |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 546 | ThrowNullPointerExceptionForMethodAccess(instr->VRegB_35c(), kInterface); |
Sebastien Hertz | 75b2a4a | 2013-05-21 09:25:10 +0200 | [diff] [blame] | 547 | break; |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 548 | case Instruction::INVOKE_INTERFACE_RANGE: |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 549 | ThrowNullPointerExceptionForMethodAccess(instr->VRegB_3rc(), kInterface); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 550 | break; |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 551 | case Instruction::INVOKE_VIRTUAL_QUICK: |
| 552 | case Instruction::INVOKE_VIRTUAL_RANGE_QUICK: { |
| 553 | // Since we replaced the method index, we ask the verifier to tell us which |
| 554 | // method is invoked at this location. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 555 | ArtMethod* invoked_method = |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 556 | verifier::MethodVerifier::FindInvokedMethodAtDexPc(method, throw_dex_pc); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 557 | if (invoked_method != nullptr) { |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 558 | // NPE with precise message. |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 559 | ThrowNullPointerExceptionForMethodAccess(invoked_method, kVirtual); |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 560 | } else { |
| 561 | // NPE with imprecise message. |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 562 | ThrowNullPointerException("Attempt to invoke a virtual method on a null object reference"); |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 563 | } |
| 564 | break; |
| 565 | } |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 566 | case Instruction::IGET: |
| 567 | case Instruction::IGET_WIDE: |
| 568 | case Instruction::IGET_OBJECT: |
| 569 | case Instruction::IGET_BOOLEAN: |
| 570 | case Instruction::IGET_BYTE: |
| 571 | case Instruction::IGET_CHAR: |
| 572 | case Instruction::IGET_SHORT: { |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 573 | ArtField* field = |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 574 | Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(), method, false); |
| 575 | ThrowNullPointerExceptionForFieldAccess(field, true /* read */); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 576 | break; |
| 577 | } |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 578 | case Instruction::IGET_QUICK: |
Mathieu Chartier | ffc605c | 2014-12-10 10:35:44 -0800 | [diff] [blame] | 579 | case Instruction::IGET_BOOLEAN_QUICK: |
| 580 | case Instruction::IGET_BYTE_QUICK: |
| 581 | case Instruction::IGET_CHAR_QUICK: |
| 582 | case Instruction::IGET_SHORT_QUICK: |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 583 | case Instruction::IGET_WIDE_QUICK: |
| 584 | case Instruction::IGET_OBJECT_QUICK: { |
| 585 | // Since we replaced the field index, we ask the verifier to tell us which |
| 586 | // field is accessed at this location. |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 587 | ArtField* field = |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 588 | verifier::MethodVerifier::FindAccessedFieldAtDexPc(method, throw_dex_pc); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 589 | if (field != nullptr) { |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 590 | // NPE with precise message. |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 591 | ThrowNullPointerExceptionForFieldAccess(field, true /* read */); |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 592 | } else { |
| 593 | // NPE with imprecise message. |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 594 | ThrowNullPointerException("Attempt to read from a field on a null object reference"); |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 595 | } |
| 596 | break; |
| 597 | } |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 598 | case Instruction::IPUT: |
| 599 | case Instruction::IPUT_WIDE: |
| 600 | case Instruction::IPUT_OBJECT: |
| 601 | case Instruction::IPUT_BOOLEAN: |
| 602 | case Instruction::IPUT_BYTE: |
| 603 | case Instruction::IPUT_CHAR: |
| 604 | case Instruction::IPUT_SHORT: { |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 605 | ArtField* field = |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 606 | Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(), method, false); |
| 607 | ThrowNullPointerExceptionForFieldAccess(field, false /* write */); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 608 | break; |
| 609 | } |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 610 | case Instruction::IPUT_QUICK: |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 611 | case Instruction::IPUT_BOOLEAN_QUICK: |
| 612 | case Instruction::IPUT_BYTE_QUICK: |
| 613 | case Instruction::IPUT_CHAR_QUICK: |
| 614 | case Instruction::IPUT_SHORT_QUICK: |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 615 | case Instruction::IPUT_WIDE_QUICK: |
| 616 | case Instruction::IPUT_OBJECT_QUICK: { |
| 617 | // Since we replaced the field index, we ask the verifier to tell us which |
| 618 | // field is accessed at this location. |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 619 | ArtField* field = |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 620 | verifier::MethodVerifier::FindAccessedFieldAtDexPc(method, throw_dex_pc); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 621 | if (field != nullptr) { |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 622 | // NPE with precise message. |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 623 | ThrowNullPointerExceptionForFieldAccess(field, false /* write */); |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 624 | } else { |
| 625 | // NPE with imprecise message. |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 626 | ThrowNullPointerException("Attempt to write to a field on a null object reference"); |
Sebastien Hertz | 2d6ba51 | 2013-05-17 11:31:37 +0200 | [diff] [blame] | 627 | } |
| 628 | break; |
| 629 | } |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 630 | case Instruction::AGET: |
| 631 | case Instruction::AGET_WIDE: |
| 632 | case Instruction::AGET_OBJECT: |
| 633 | case Instruction::AGET_BOOLEAN: |
| 634 | case Instruction::AGET_BYTE: |
| 635 | case Instruction::AGET_CHAR: |
| 636 | case Instruction::AGET_SHORT: |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 637 | ThrowException("Ljava/lang/NullPointerException;", nullptr, |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 638 | "Attempt to read from null array"); |
| 639 | break; |
| 640 | case Instruction::APUT: |
| 641 | case Instruction::APUT_WIDE: |
| 642 | case Instruction::APUT_OBJECT: |
| 643 | case Instruction::APUT_BOOLEAN: |
| 644 | case Instruction::APUT_BYTE: |
| 645 | case Instruction::APUT_CHAR: |
| 646 | case Instruction::APUT_SHORT: |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 647 | ThrowException("Ljava/lang/NullPointerException;", nullptr, |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 648 | "Attempt to write to null array"); |
| 649 | break; |
| 650 | case Instruction::ARRAY_LENGTH: |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 651 | ThrowException("Ljava/lang/NullPointerException;", nullptr, |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 652 | "Attempt to get length of null array"); |
| 653 | break; |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 654 | case Instruction::FILL_ARRAY_DATA: { |
| 655 | ThrowException("Ljava/lang/NullPointerException;", nullptr, |
| 656 | "Attempt to write to null array"); |
| 657 | break; |
| 658 | } |
Nicolas Geoffray | 7f0ae73 | 2016-06-29 14:54:35 +0100 | [diff] [blame] | 659 | case Instruction::MONITOR_ENTER: |
| 660 | case Instruction::MONITOR_EXIT: { |
| 661 | ThrowException("Ljava/lang/NullPointerException;", nullptr, |
| 662 | "Attempt to do a synchronize operation on a null object"); |
| 663 | break; |
| 664 | } |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 665 | default: { |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 666 | const DexFile* dex_file = |
| 667 | method->GetDeclaringClass()->GetDexCache()->GetDexFile(); |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 668 | LOG(FATAL) << "NullPointerException at an unexpected instruction: " |
| 669 | << instr->DumpString(dex_file) |
| 670 | << " in " |
| 671 | << PrettyMethod(method); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 672 | break; |
| 673 | } |
| 674 | } |
| 675 | } |
| 676 | |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 677 | void ThrowNullPointerException(const char* msg) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 678 | ThrowException("Ljava/lang/NullPointerException;", nullptr, msg); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | // RuntimeException |
| 682 | |
| 683 | void ThrowRuntimeException(const char* fmt, ...) { |
| 684 | va_list args; |
| 685 | va_start(args, fmt); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 686 | ThrowException("Ljava/lang/RuntimeException;", nullptr, fmt, &args); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 687 | va_end(args); |
| 688 | } |
| 689 | |
Andreas Gampe | 103992b | 2016-01-04 15:32:43 -0800 | [diff] [blame] | 690 | // Stack overflow. |
| 691 | |
| 692 | void ThrowStackOverflowError(Thread* self) { |
| 693 | if (self->IsHandlingStackOverflow()) { |
| 694 | LOG(ERROR) << "Recursive stack overflow."; |
| 695 | // We don't fail here because SetStackEndForStackOverflow will print better diagnostics. |
| 696 | } |
| 697 | |
| 698 | self->SetStackEndForStackOverflow(); // Allow space on the stack for constructor to execute. |
| 699 | JNIEnvExt* env = self->GetJniEnv(); |
| 700 | std::string msg("stack size "); |
| 701 | msg += PrettySize(self->GetStackSize()); |
| 702 | |
| 703 | // Avoid running Java code for exception initialization. |
| 704 | // TODO: Checks to make this a bit less brittle. |
| 705 | |
| 706 | std::string error_msg; |
| 707 | |
| 708 | // Allocate an uninitialized object. |
| 709 | ScopedLocalRef<jobject> exc(env, |
| 710 | env->AllocObject(WellKnownClasses::java_lang_StackOverflowError)); |
| 711 | if (exc.get() != nullptr) { |
| 712 | // "Initialize". |
| 713 | // StackOverflowError -> VirtualMachineError -> Error -> Throwable -> Object. |
| 714 | // Only Throwable has "custom" fields: |
| 715 | // String detailMessage. |
| 716 | // Throwable cause (= this). |
| 717 | // List<Throwable> suppressedExceptions (= Collections.emptyList()). |
| 718 | // Object stackState; |
| 719 | // StackTraceElement[] stackTrace; |
| 720 | // Only Throwable has a non-empty constructor: |
| 721 | // this.stackTrace = EmptyArray.STACK_TRACE_ELEMENT; |
| 722 | // fillInStackTrace(); |
| 723 | |
| 724 | // detailMessage. |
| 725 | // TODO: Use String::FromModifiedUTF...? |
| 726 | ScopedLocalRef<jstring> s(env, env->NewStringUTF(msg.c_str())); |
| 727 | if (s.get() != nullptr) { |
| 728 | env->SetObjectField(exc.get(), WellKnownClasses::java_lang_Throwable_detailMessage, s.get()); |
| 729 | |
| 730 | // cause. |
| 731 | env->SetObjectField(exc.get(), WellKnownClasses::java_lang_Throwable_cause, exc.get()); |
| 732 | |
| 733 | // suppressedExceptions. |
| 734 | ScopedLocalRef<jobject> emptylist(env, env->GetStaticObjectField( |
| 735 | WellKnownClasses::java_util_Collections, |
| 736 | WellKnownClasses::java_util_Collections_EMPTY_LIST)); |
| 737 | CHECK(emptylist.get() != nullptr); |
| 738 | env->SetObjectField(exc.get(), |
| 739 | WellKnownClasses::java_lang_Throwable_suppressedExceptions, |
| 740 | emptylist.get()); |
| 741 | |
| 742 | // stackState is set as result of fillInStackTrace. fillInStackTrace calls |
| 743 | // nativeFillInStackTrace. |
| 744 | ScopedLocalRef<jobject> stack_state_val(env, nullptr); |
| 745 | { |
| 746 | ScopedObjectAccessUnchecked soa(env); |
| 747 | stack_state_val.reset(soa.Self()->CreateInternalStackTrace<false>(soa)); |
| 748 | } |
| 749 | if (stack_state_val.get() != nullptr) { |
| 750 | env->SetObjectField(exc.get(), |
| 751 | WellKnownClasses::java_lang_Throwable_stackState, |
| 752 | stack_state_val.get()); |
| 753 | |
| 754 | // stackTrace. |
| 755 | ScopedLocalRef<jobject> stack_trace_elem(env, env->GetStaticObjectField( |
| 756 | WellKnownClasses::libcore_util_EmptyArray, |
| 757 | WellKnownClasses::libcore_util_EmptyArray_STACK_TRACE_ELEMENT)); |
| 758 | env->SetObjectField(exc.get(), |
| 759 | WellKnownClasses::java_lang_Throwable_stackTrace, |
| 760 | stack_trace_elem.get()); |
| 761 | } else { |
| 762 | error_msg = "Could not create stack trace."; |
| 763 | } |
| 764 | // Throw the exception. |
| 765 | self->SetException(reinterpret_cast<mirror::Throwable*>(self->DecodeJObject(exc.get()))); |
| 766 | } else { |
| 767 | // Could not allocate a string object. |
| 768 | error_msg = "Couldn't throw new StackOverflowError because JNI NewStringUTF failed."; |
| 769 | } |
| 770 | } else { |
| 771 | error_msg = "Could not allocate StackOverflowError object."; |
| 772 | } |
| 773 | |
| 774 | if (!error_msg.empty()) { |
| 775 | LOG(WARNING) << error_msg; |
| 776 | CHECK(self->IsExceptionPending()); |
| 777 | } |
| 778 | |
| 779 | bool explicit_overflow_check = Runtime::Current()->ExplicitStackOverflowChecks(); |
| 780 | self->ResetDefaultStackEnd(); // Return to default stack size. |
| 781 | |
| 782 | // And restore protection if implicit checks are on. |
| 783 | if (!explicit_overflow_check) { |
| 784 | self->ProtectStack(); |
| 785 | } |
| 786 | } |
| 787 | |
Vladimir Marko | 87f3fcb | 2016-04-28 15:52:11 +0100 | [diff] [blame] | 788 | // StringIndexOutOfBoundsException |
| 789 | |
| 790 | void ThrowStringIndexOutOfBoundsException(int index, int length) { |
| 791 | ThrowException("Ljava/lang/StringIndexOutOfBoundsException;", nullptr, |
| 792 | StringPrintf("length=%d; index=%d", length, index).c_str()); |
| 793 | } |
| 794 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 795 | // VerifyError |
| 796 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 797 | void ThrowVerifyError(mirror::Class* referrer, const char* fmt, ...) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 798 | va_list args; |
| 799 | va_start(args, fmt); |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 800 | ThrowException("Ljava/lang/VerifyError;", referrer, fmt, &args); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 801 | va_end(args); |
Ian Rogers | 87e552d | 2012-08-31 15:54:48 -0700 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | } // namespace art |