diff options
Diffstat (limited to 'runtime/common_throws.cc')
| -rw-r--r-- | runtime/common_throws.cc | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/runtime/common_throws.cc b/runtime/common_throws.cc index 1b6f317053..8f65c66441 100644 --- a/runtime/common_throws.cc +++ b/runtime/common_throws.cc @@ -53,6 +53,11 @@ static void AddReferrerLocation(std::ostream& os, ObjPtr<mirror::Class> referrer } } +static void ThrowException(const char* exception_descriptor) REQUIRES_SHARED(Locks::mutator_lock_) { + Thread* self = Thread::Current(); + self->ThrowNewException(exception_descriptor, nullptr); +} + static void ThrowException(const char* exception_descriptor, ObjPtr<mirror::Class> referrer, const char* fmt, @@ -243,6 +248,11 @@ void ThrowIllegalArgumentException(const char* msg) { ThrowException("Ljava/lang/IllegalArgumentException;", nullptr, msg); } +// IllegalStateException + +void ThrowIllegalStateException(const char* msg) { + ThrowException("Ljava/lang/IllegalStateException;", nullptr, msg); +} // IncompatibleClassChangeError @@ -314,6 +324,13 @@ void ThrowIncompatibleClassChangeErrorForMethodConflict(ArtMethod* method) { ArtMethod::PrettyMethod(method).c_str()).c_str()); } +// IndexOutOfBoundsException + +void ThrowIndexOutOfBoundsException(int index, int length) { + ThrowException("Ljava/lang/IndexOutOfBoundsException;", nullptr, + StringPrintf("length=%d; index=%d", length, index).c_str()); +} + // InternalError void ThrowInternalError(const char* fmt, ...) { @@ -721,6 +738,12 @@ void ThrowNullPointerException(const char* msg) { ThrowException("Ljava/lang/NullPointerException;", nullptr, msg); } +// ReadOnlyBufferException + +void ThrowReadOnlyBufferException() { + Thread::Current()->ThrowNewException("Ljava/nio/ReadOnlyBufferException;", nullptr); +} + // RuntimeException void ThrowRuntimeException(const char* fmt, ...) { @@ -844,6 +867,12 @@ void ThrowStringIndexOutOfBoundsException(int index, int length) { StringPrintf("length=%d; index=%d", length, index).c_str()); } +// UnsupportedOperationException + +void ThrowUnsupportedOperationException() { + ThrowException("Ljava/lang/UnsupportedOperationException;"); +} + // VerifyError void ThrowVerifyError(ObjPtr<mirror::Class> referrer, const char* fmt, ...) { @@ -855,13 +884,13 @@ void ThrowVerifyError(ObjPtr<mirror::Class> referrer, const char* fmt, ...) { // WrongMethodTypeException -void ThrowWrongMethodTypeException(mirror::MethodType* callee_type, - mirror::MethodType* callsite_type) { +void ThrowWrongMethodTypeException(mirror::MethodType* expected_type, + mirror::MethodType* actual_type) { ThrowException("Ljava/lang/invoke/WrongMethodTypeException;", nullptr, StringPrintf("Expected %s but was %s", - callee_type->PrettyDescriptor().c_str(), - callsite_type->PrettyDescriptor().c_str()).c_str()); + expected_type->PrettyDescriptor().c_str(), + actual_type->PrettyDescriptor().c_str()).c_str()); } } // namespace art |