diff options
author | Sebastien Hertz <shertz@google.com> | 2015-04-02 11:11:19 +0200 |
---|---|---|
committer | Sebastien Hertz <shertz@google.com> | 2015-04-03 09:31:59 +0200 |
commit | 2fd7e69505195cda4caaa3161aaf37315552a698 (patch) | |
tree | 2bd681443ad36a8616f237a12e56ecbdb7054f8e /runtime/interpreter | |
parent | c6e949a6d93fae2351fc59ed825657adee8185dc (diff) | |
download | art-2fd7e69505195cda4caaa3161aaf37315552a698.zip art-2fd7e69505195cda4caaa3161aaf37315552a698.tar.gz art-2fd7e69505195cda4caaa3161aaf37315552a698.tar.bz2 |
Use specific exception class to abort transaction
We used to throw a java.lang.InternalError when aborting a
transaction (when preinitializing image classes at compilation time).
We now use dedicated class dalvik.system.TransactionAbortError that
is only thrown by the compiler to abort a transaction. This class has
constructors taking a java.lang.Throwable "cause" so we can wrap
exceptions causing the transaction to abort (for instance class
java.lang.ClassNotFoundException) and give more information about the
cause of the transaction abort.
Bug: 20019689
Change-Id: I019a72a1c754d8bba6a7ad6bb0f02e4fd6668622
Diffstat (limited to 'runtime/interpreter')
-rw-r--r-- | runtime/interpreter/interpreter_common.cc | 2 | ||||
-rw-r--r-- | runtime/interpreter/unstarted_runtime.cc | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc index a310452..582843c 100644 --- a/runtime/interpreter/interpreter_common.cc +++ b/runtime/interpreter/interpreter_common.cc @@ -475,7 +475,7 @@ void AbortTransaction(Thread* self, const char* fmt, ...) { std::string abort_msg; StringAppendV(&abort_msg, fmt, args); // Throws an exception so we can abort the transaction and rollback every change. - Runtime::Current()->AbortTransactionAndThrowInternalError(self, abort_msg); + Runtime::Current()->AbortTransactionAndThrowAbortError(self, abort_msg); va_end(args); } diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc index 281f332..2aa4af4 100644 --- a/runtime/interpreter/unstarted_runtime.cc +++ b/runtime/interpreter/unstarted_runtime.cc @@ -37,6 +37,7 @@ #include "mirror/string-inl.h" #include "nth_caller_visitor.h" #include "thread.h" +#include "transaction.h" #include "well_known_classes.h" namespace art { @@ -87,13 +88,14 @@ static void UnstartedRuntimeFindClass(Thread* self, Handle<mirror::String> class // Common helper for class-loading cutouts in an unstarted runtime. We call Runtime methods that // rely on Java code to wrap errors in the correct exception class (i.e., NoClassDefFoundError into // ClassNotFoundException), so need to do the same. The only exception is if the exception is -// actually InternalError. This must not be wrapped, as it signals an initialization abort. +// actually the transaction abort exception. This must not be wrapped, as it signals an +// initialization abort. static void CheckExceptionGenerateClassNotFound(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (self->IsExceptionPending()) { - // If it is not an InternalError, wrap it. + // If it is not the transaction abort exception, wrap it. std::string type(PrettyTypeOf(self->GetException())); - if (type != "java.lang.InternalError") { + if (type != Transaction::kAbortExceptionDescriptor) { self->ThrowNewWrappedException("Ljava/lang/ClassNotFoundException;", "ClassNotFoundException"); } @@ -502,7 +504,7 @@ static void UnstartedDexCacheGetDexNative( } if (!have_dex) { self->ClearException(); - Runtime::Current()->AbortTransactionAndThrowInternalError(self, "Could not create Dex object"); + Runtime::Current()->AbortTransactionAndThrowAbortError(self, "Could not create Dex object"); } } @@ -570,7 +572,7 @@ static void UnstartedMemoryPeekArray( int64_t address_long = shadow_frame->GetVRegLong(arg_offset); mirror::Object* obj = shadow_frame->GetVRegReference(arg_offset + 2); if (obj == nullptr) { - Runtime::Current()->AbortTransactionAndThrowInternalError(self, "Null pointer in peekArray"); + Runtime::Current()->AbortTransactionAndThrowAbortError(self, "Null pointer in peekArray"); return; } mirror::Array* array = obj->AsArray(); @@ -580,7 +582,7 @@ static void UnstartedMemoryPeekArray( if (offset < 0 || offset + count > array->GetLength()) { std::string error_msg(StringPrintf("Array out of bounds in peekArray: %d/%d vs %d", offset, count, array->GetLength())); - Runtime::Current()->AbortTransactionAndThrowInternalError(self, error_msg.c_str()); + Runtime::Current()->AbortTransactionAndThrowAbortError(self, error_msg.c_str()); return; } |