Note that this is a cleanup change, and has no functionality change.
The ThrowLocation had no use anymore.
Change-Id: I3d2126af1dc673cec3a0453ff3d56a172663a5f6
thread.cc \
thread_list.cc \
thread_pool.cc \
- throw_location.cc \
trace.cc \
transaction.cc \
profiler.cc \
va_list args;
va_start(args, fmt);
Thread* self = Thread::Current();
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewExceptionV(throw_location, "Ljava/lang/NoClassDefFoundError;", fmt, args);
+ self->ThrowNewExceptionV("Ljava/lang/NoClassDefFoundError;", fmt, args);
va_end(args);
}
mirror::Throwable* pre_allocated = runtime->GetPreAllocatedNoClassDefFoundError();
self->SetException(pre_allocated);
} else {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
if (c->GetVerifyErrorClass() != NULL) {
// TODO: change the verifier to store an _instance_, with a useful detail message?
std::string temp;
- self->ThrowNewException(throw_location, c->GetVerifyErrorClass()->GetDescriptor(&temp),
+ self->ThrowNewException(c->GetVerifyErrorClass()->GetDescriptor(&temp),
PrettyDescriptor(c).c_str());
} else {
- self->ThrowNewException(throw_location, "Ljava/lang/NoClassDefFoundError;",
+ self->ThrowNewException("Ljava/lang/NoClassDefFoundError;",
PrettyDescriptor(c).c_str());
}
}
// We only wrap non-Error exceptions; an Error can just be used as-is.
if (!is_error) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewWrappedException(throw_location, "Ljava/lang/ExceptionInInitializerError;",
- nullptr);
+ self->ThrowNewWrappedException("Ljava/lang/ExceptionInInitializerError;", nullptr);
}
VlogClassInitializationFailure(klass);
}
return nullptr;
} else if (result.get() == nullptr) {
// broken loader - throw NPE to be compatible with Dalvik
- ThrowNullPointerException(nullptr, StringPrintf("ClassLoader.loadClass returned null for %s",
- class_name_string.c_str()).c_str());
+ ThrowNullPointerException(StringPrintf("ClassLoader.loadClass returned null for %s",
+ class_name_string.c_str()).c_str());
return nullptr;
} else {
// success, return mirror::Class*
}
}
-static void ThrowException(const ThrowLocation* throw_location, const char* exception_descriptor,
+static void ThrowException(const char* exception_descriptor,
mirror::Class* referrer, const char* fmt, va_list* args = NULL)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
std::ostringstream msg;
}
AddReferrerLocation(msg, referrer);
Thread* self = Thread::Current();
- if (throw_location == NULL) {
- ThrowLocation computed_throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewException(computed_throw_location, exception_descriptor, msg.str().c_str());
- } else {
- self->ThrowNewException(*throw_location, exception_descriptor, msg.str().c_str());
- }
+ self->ThrowNewException(exception_descriptor, msg.str().c_str());
}
-static void ThrowWrappedException(const ThrowLocation* throw_location,
- const char* exception_descriptor,
+static void ThrowWrappedException(const char* exception_descriptor,
mirror::Class* referrer, const char* fmt, va_list* args = NULL)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
std::ostringstream msg;
}
AddReferrerLocation(msg, referrer);
Thread* self = Thread::Current();
- if (throw_location == NULL) {
- ThrowLocation computed_throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewWrappedException(computed_throw_location, exception_descriptor, msg.str().c_str());
- } else {
- self->ThrowNewWrappedException(*throw_location, exception_descriptor, msg.str().c_str());
- }
+ self->ThrowNewWrappedException(exception_descriptor, msg.str().c_str());
}
// AbstractMethodError
void ThrowAbstractMethodError(mirror::ArtMethod* method) {
- ThrowException(NULL, "Ljava/lang/AbstractMethodError;", NULL,
+ ThrowException("Ljava/lang/AbstractMethodError;", NULL,
StringPrintf("abstract method \"%s\"",
PrettyMethod(method).c_str()).c_str());
}
// ArithmeticException
void ThrowArithmeticExceptionDivideByZero() {
- ThrowException(NULL, "Ljava/lang/ArithmeticException;", NULL, "divide by zero");
+ ThrowException("Ljava/lang/ArithmeticException;", NULL, "divide by zero");
}
// ArrayIndexOutOfBoundsException
void ThrowArrayIndexOutOfBoundsException(int index, int length) {
- ThrowException(NULL, "Ljava/lang/ArrayIndexOutOfBoundsException;", NULL,
+ ThrowException("Ljava/lang/ArrayIndexOutOfBoundsException;", NULL,
StringPrintf("length=%d; index=%d", length, index).c_str());
}
// ArrayStoreException
void ThrowArrayStoreException(mirror::Class* element_class, mirror::Class* array_class) {
- ThrowException(NULL, "Ljava/lang/ArrayStoreException;", NULL,
+ ThrowException("Ljava/lang/ArrayStoreException;", NULL,
StringPrintf("%s cannot be stored in an array of type %s",
PrettyDescriptor(element_class).c_str(),
PrettyDescriptor(array_class).c_str()).c_str());
// ClassCastException
void ThrowClassCastException(mirror::Class* dest_type, mirror::Class* src_type) {
- ThrowException(NULL, "Ljava/lang/ClassCastException;", NULL,
+ ThrowException("Ljava/lang/ClassCastException;", NULL,
StringPrintf("%s cannot be cast to %s",
PrettyDescriptor(src_type).c_str(),
PrettyDescriptor(dest_type).c_str()).c_str());
}
-void ThrowClassCastException(const ThrowLocation* throw_location, const char* msg) {
- ThrowException(throw_location, "Ljava/lang/ClassCastException;", NULL, msg);
+void ThrowClassCastException(const char* msg) {
+ ThrowException("Ljava/lang/ClassCastException;", NULL, msg);
}
// ClassCircularityError
void ThrowClassCircularityError(mirror::Class* c) {
std::ostringstream msg;
msg << PrettyDescriptor(c);
- ThrowException(NULL, "Ljava/lang/ClassCircularityError;", c, msg.str().c_str());
+ ThrowException("Ljava/lang/ClassCircularityError;", c, msg.str().c_str());
}
// ClassFormatError
void ThrowClassFormatError(mirror::Class* referrer, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowException(NULL, "Ljava/lang/ClassFormatError;", referrer, fmt, &args);
+ ThrowException("Ljava/lang/ClassFormatError;", referrer, fmt, &args);
va_end(args);}
// IllegalAccessError
std::ostringstream msg;
msg << "Illegal class access: '" << PrettyDescriptor(referrer) << "' attempting to access '"
<< PrettyDescriptor(accessed) << "'";
- ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
+ ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
}
void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed,
msg << "Illegal class access ('" << PrettyDescriptor(referrer) << "' attempting to access '"
<< PrettyDescriptor(accessed) << "') in attempt to invoke " << type
<< " method " << PrettyMethod(called).c_str();
- ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
+ ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
}
void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::ArtMethod* accessed) {
std::ostringstream msg;
msg << "Method '" << PrettyMethod(accessed) << "' is inaccessible to class '"
<< PrettyDescriptor(referrer) << "'";
- ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
+ ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
}
void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::ArtField* accessed) {
std::ostringstream msg;
msg << "Field '" << PrettyField(accessed, false) << "' is inaccessible to class '"
<< PrettyDescriptor(referrer) << "'";
- ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
+ ThrowException("Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str());
}
void ThrowIllegalAccessErrorFinalField(mirror::ArtMethod* referrer,
std::ostringstream msg;
msg << "Final field '" << PrettyField(accessed, false) << "' cannot be written to by method '"
<< PrettyMethod(referrer) << "'";
- ThrowException(NULL, "Ljava/lang/IllegalAccessError;",
+ ThrowException("Ljava/lang/IllegalAccessError;",
referrer != NULL ? referrer->GetClass() : NULL,
msg.str().c_str());
}
void ThrowIllegalAccessError(mirror::Class* referrer, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, fmt, &args);
+ ThrowException("Ljava/lang/IllegalAccessError;", referrer, fmt, &args);
va_end(args);
}
// IllegalAccessException
-void ThrowIllegalAccessException(const ThrowLocation* throw_location, const char* msg) {
- ThrowException(throw_location, "Ljava/lang/IllegalAccessException;", NULL, msg);
+void ThrowIllegalAccessException(const char* msg) {
+ ThrowException("Ljava/lang/IllegalAccessException;", NULL, msg);
}
// IllegalArgumentException
-void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const char* msg) {
- ThrowException(throw_location, "Ljava/lang/IllegalArgumentException;", NULL, msg);
+void ThrowIllegalArgumentException(const char* msg) {
+ ThrowException("Ljava/lang/IllegalArgumentException;", NULL, msg);
}
std::ostringstream msg;
msg << "The method '" << PrettyMethod(method) << "' was expected to be of type "
<< expected_type << " but instead was found to be of type " << found_type;
- ThrowException(NULL, "Ljava/lang/IncompatibleClassChangeError;",
+ ThrowException("Ljava/lang/IncompatibleClassChangeError;",
referrer != NULL ? referrer->GetClass() : NULL,
msg.str().c_str());
}
<< "' does not implement interface '"
<< PrettyDescriptor(interface_method->GetDeclaringClass())
<< "' in call to '" << PrettyMethod(interface_method) << "'";
- ThrowException(NULL, "Ljava/lang/IncompatibleClassChangeError;",
+ ThrowException("Ljava/lang/IncompatibleClassChangeError;",
referrer != NULL ? referrer->GetClass() : NULL,
msg.str().c_str());
}
msg << "Expected '" << PrettyField(resolved_field) << "' to be a "
<< (is_static ? "static" : "instance") << " field" << " rather than a "
<< (is_static ? "instance" : "static") << " field";
- ThrowException(NULL, "Ljava/lang/IncompatibleClassChangeError;", referrer->GetClass(),
+ ThrowException("Ljava/lang/IncompatibleClassChangeError;", referrer->GetClass(),
msg.str().c_str());
}
void ThrowIncompatibleClassChangeError(mirror::Class* referrer, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowException(NULL, "Ljava/lang/IncompatibleClassChangeError;", referrer, fmt, &args);
+ ThrowException("Ljava/lang/IncompatibleClassChangeError;", referrer, fmt, &args);
va_end(args);
}
void ThrowIOException(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowException(NULL, "Ljava/io/IOException;", NULL, fmt, &args);
+ ThrowException("Ljava/io/IOException;", NULL, fmt, &args);
va_end(args);
}
void ThrowWrappedIOException(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowWrappedException(NULL, "Ljava/io/IOException;", NULL, fmt, &args);
+ ThrowWrappedException("Ljava/io/IOException;", NULL, fmt, &args);
va_end(args);
}
void ThrowLinkageError(mirror::Class* referrer, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowException(NULL, "Ljava/lang/LinkageError;", referrer, fmt, &args);
+ ThrowException("Ljava/lang/LinkageError;", referrer, fmt, &args);
va_end(args);
}
// NegativeArraySizeException
void ThrowNegativeArraySizeException(int size) {
- ThrowException(NULL, "Ljava/lang/NegativeArraySizeException;", NULL,
+ ThrowException("Ljava/lang/NegativeArraySizeException;", NULL,
StringPrintf("%d", size).c_str());
}
void ThrowNegativeArraySizeException(const char* msg) {
- ThrowException(NULL, "Ljava/lang/NegativeArraySizeException;", NULL, msg);
+ ThrowException("Ljava/lang/NegativeArraySizeException;", NULL, msg);
}
// NoSuchFieldError
std::string temp;
msg << "No " << scope << "field " << name << " of type " << type
<< " in class " << c->GetDescriptor(&temp) << " or its superclasses";
- ThrowException(NULL, "Ljava/lang/NoSuchFieldError;", c, msg.str().c_str());
+ ThrowException("Ljava/lang/NoSuchFieldError;", c, msg.str().c_str());
}
// NoSuchMethodError
std::string temp;
msg << "No " << type << " method " << name << signature
<< " in class " << c->GetDescriptor(&temp) << " or its super classes";
- ThrowException(NULL, "Ljava/lang/NoSuchMethodError;", c, msg.str().c_str());
+ ThrowException("Ljava/lang/NoSuchMethodError;", c, msg.str().c_str());
}
void ThrowNoSuchMethodError(uint32_t method_idx) {
- Thread* self = Thread::Current();
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- mirror::DexCache* dex_cache = throw_location.GetMethod()->GetDeclaringClass()->GetDexCache();
+ mirror::ArtMethod* method = Thread::Current()->GetCurrentMethod(nullptr);
+ mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache();
const DexFile& dex_file = *dex_cache->GetDexFile();
std::ostringstream msg;
msg << "No method '" << PrettyMethod(method_idx, dex_file, true) << "'";
- ThrowException(&throw_location, "Ljava/lang/NoSuchMethodError;",
- throw_location.GetMethod()->GetDeclaringClass(), msg.str().c_str());
+ ThrowException("Ljava/lang/NoSuchMethodError;",
+ method->GetDeclaringClass(), msg.str().c_str());
}
// NullPointerException
-void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location,
- mirror::ArtField* field, bool is_read) {
+void ThrowNullPointerExceptionForFieldAccess(mirror::ArtField* field, bool is_read) {
std::ostringstream msg;
msg << "Attempt to " << (is_read ? "read from" : "write to")
<< " field '" << PrettyField(field, true) << "' on a null object reference";
- ThrowException(&throw_location, "Ljava/lang/NullPointerException;", NULL, msg.str().c_str());
+ ThrowException("Ljava/lang/NullPointerException;", NULL, msg.str().c_str());
}
-static void ThrowNullPointerExceptionForMethodAccessImpl(const ThrowLocation& throw_location,
- uint32_t method_idx,
+static void ThrowNullPointerExceptionForMethodAccessImpl(uint32_t method_idx,
const DexFile& dex_file,
InvokeType type)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
std::ostringstream msg;
msg << "Attempt to invoke " << type << " method '"
<< PrettyMethod(method_idx, dex_file, true) << "' on a null object reference";
- ThrowException(&throw_location, "Ljava/lang/NullPointerException;", NULL, msg.str().c_str());
+ ThrowException("Ljava/lang/NullPointerException;", NULL, msg.str().c_str());
}
-void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
- uint32_t method_idx,
+void ThrowNullPointerExceptionForMethodAccess(uint32_t method_idx,
InvokeType type) {
- mirror::DexCache* dex_cache = throw_location.GetMethod()->GetDeclaringClass()->GetDexCache();
+ mirror::DexCache* dex_cache =
+ Thread::Current()->GetCurrentMethod(nullptr)->GetDeclaringClass()->GetDexCache();
const DexFile& dex_file = *dex_cache->GetDexFile();
- ThrowNullPointerExceptionForMethodAccessImpl(throw_location, method_idx,
- dex_file, type);
+ ThrowNullPointerExceptionForMethodAccessImpl(method_idx, dex_file, type);
}
-void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
- mirror::ArtMethod* method,
+void ThrowNullPointerExceptionForMethodAccess(mirror::ArtMethod* method,
InvokeType type) {
mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache();
const DexFile& dex_file = *dex_cache->GetDexFile();
- ThrowNullPointerExceptionForMethodAccessImpl(throw_location, method->GetDexMethodIndex(),
+ ThrowNullPointerExceptionForMethodAccessImpl(method->GetDexMethodIndex(),
dex_file, type);
}
-void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) {
- const DexFile::CodeItem* code = throw_location.GetMethod()->GetCodeItem();
- uint32_t throw_dex_pc = throw_location.GetDexPc();
+void ThrowNullPointerExceptionFromDexPC() {
+ uint32_t throw_dex_pc;
+ mirror::ArtMethod* method = Thread::Current()->GetCurrentMethod(&throw_dex_pc);
+ const DexFile::CodeItem* code = method->GetCodeItem();
CHECK_LT(throw_dex_pc, code->insns_size_in_code_units_);
const Instruction* instr = Instruction::At(&code->insns_[throw_dex_pc]);
switch (instr->Opcode()) {
case Instruction::INVOKE_DIRECT:
- ThrowNullPointerExceptionForMethodAccess(throw_location, instr->VRegB_35c(), kDirect);
+ ThrowNullPointerExceptionForMethodAccess(instr->VRegB_35c(), kDirect);
break;
case Instruction::INVOKE_DIRECT_RANGE:
- ThrowNullPointerExceptionForMethodAccess(throw_location, instr->VRegB_3rc(), kDirect);
+ ThrowNullPointerExceptionForMethodAccess(instr->VRegB_3rc(), kDirect);
break;
case Instruction::INVOKE_VIRTUAL:
- ThrowNullPointerExceptionForMethodAccess(throw_location, instr->VRegB_35c(), kVirtual);
+ ThrowNullPointerExceptionForMethodAccess(instr->VRegB_35c(), kVirtual);
break;
case Instruction::INVOKE_VIRTUAL_RANGE:
- ThrowNullPointerExceptionForMethodAccess(throw_location, instr->VRegB_3rc(), kVirtual);
+ ThrowNullPointerExceptionForMethodAccess(instr->VRegB_3rc(), kVirtual);
break;
case Instruction::INVOKE_INTERFACE:
- ThrowNullPointerExceptionForMethodAccess(throw_location, instr->VRegB_35c(), kInterface);
+ ThrowNullPointerExceptionForMethodAccess(instr->VRegB_35c(), kInterface);
break;
case Instruction::INVOKE_INTERFACE_RANGE:
- ThrowNullPointerExceptionForMethodAccess(throw_location, instr->VRegB_3rc(), kInterface);
+ ThrowNullPointerExceptionForMethodAccess(instr->VRegB_3rc(), kInterface);
break;
case Instruction::INVOKE_VIRTUAL_QUICK:
case Instruction::INVOKE_VIRTUAL_RANGE_QUICK: {
// Since we replaced the method index, we ask the verifier to tell us which
// method is invoked at this location.
- mirror::ArtMethod* method =
- verifier::MethodVerifier::FindInvokedMethodAtDexPc(throw_location.GetMethod(),
- throw_location.GetDexPc());
- if (method != NULL) {
+ mirror::ArtMethod* invoked_method =
+ verifier::MethodVerifier::FindInvokedMethodAtDexPc(method, throw_dex_pc);
+ if (invoked_method != NULL) {
// NPE with precise message.
- ThrowNullPointerExceptionForMethodAccess(throw_location, method, kVirtual);
+ ThrowNullPointerExceptionForMethodAccess(invoked_method, kVirtual);
} else {
// NPE with imprecise message.
- ThrowNullPointerException(&throw_location,
- "Attempt to invoke a virtual method on a null object reference");
+ ThrowNullPointerException("Attempt to invoke a virtual method on a null object reference");
}
break;
}
case Instruction::IGET_CHAR:
case Instruction::IGET_SHORT: {
mirror::ArtField* field =
- Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(),
- throw_location.GetMethod(), false);
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, true /* read */);
+ Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(), method, false);
+ ThrowNullPointerExceptionForFieldAccess(field, true /* read */);
break;
}
case Instruction::IGET_QUICK:
// Since we replaced the field index, we ask the verifier to tell us which
// field is accessed at this location.
mirror::ArtField* field =
- verifier::MethodVerifier::FindAccessedFieldAtDexPc(throw_location.GetMethod(),
- throw_location.GetDexPc());
+ verifier::MethodVerifier::FindAccessedFieldAtDexPc(method, throw_dex_pc);
if (field != NULL) {
// NPE with precise message.
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, true /* read */);
+ ThrowNullPointerExceptionForFieldAccess(field, true /* read */);
} else {
// NPE with imprecise message.
- ThrowNullPointerException(&throw_location,
- "Attempt to read from a field on a null object reference");
+ ThrowNullPointerException("Attempt to read from a field on a null object reference");
}
break;
}
case Instruction::IPUT_CHAR:
case Instruction::IPUT_SHORT: {
mirror::ArtField* field =
- Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(),
- throw_location.GetMethod(), false);
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, false /* write */);
+ Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(), method, false);
+ ThrowNullPointerExceptionForFieldAccess(field, false /* write */);
break;
}
case Instruction::IPUT_QUICK:
// Since we replaced the field index, we ask the verifier to tell us which
// field is accessed at this location.
mirror::ArtField* field =
- verifier::MethodVerifier::FindAccessedFieldAtDexPc(throw_location.GetMethod(),
- throw_location.GetDexPc());
+ verifier::MethodVerifier::FindAccessedFieldAtDexPc(method, throw_dex_pc);
if (field != NULL) {
// NPE with precise message.
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, false /* write */);
+ ThrowNullPointerExceptionForFieldAccess(field, false /* write */);
} else {
// NPE with imprecise message.
- ThrowNullPointerException(&throw_location,
- "Attempt to write to a field on a null object reference");
+ ThrowNullPointerException("Attempt to write to a field on a null object reference");
}
break;
}
case Instruction::AGET_BYTE:
case Instruction::AGET_CHAR:
case Instruction::AGET_SHORT:
- ThrowException(&throw_location, "Ljava/lang/NullPointerException;", NULL,
+ ThrowException("Ljava/lang/NullPointerException;", NULL,
"Attempt to read from null array");
break;
case Instruction::APUT:
case Instruction::APUT_BYTE:
case Instruction::APUT_CHAR:
case Instruction::APUT_SHORT:
- ThrowException(&throw_location, "Ljava/lang/NullPointerException;", NULL,
+ ThrowException("Ljava/lang/NullPointerException;", NULL,
"Attempt to write to null array");
break;
case Instruction::ARRAY_LENGTH:
- ThrowException(&throw_location, "Ljava/lang/NullPointerException;", NULL,
+ ThrowException("Ljava/lang/NullPointerException;", NULL,
"Attempt to get length of null array");
break;
default: {
// TODO: We should have covered all the cases where we expect a NPE above, this
// message/logging is so we can improve any cases we've missed in the future.
- const DexFile& dex_file =
- *throw_location.GetMethod()->GetDeclaringClass()->GetDexCache()->GetDexFile();
- ThrowException(&throw_location, "Ljava/lang/NullPointerException;", NULL,
+ const DexFile* dex_file =
+ method->GetDeclaringClass()->GetDexCache()->GetDexFile();
+ ThrowException("Ljava/lang/NullPointerException;", NULL,
StringPrintf("Null pointer exception during instruction '%s'",
- instr->DumpString(&dex_file).c_str()).c_str());
+ instr->DumpString(dex_file).c_str()).c_str());
break;
}
}
}
-void ThrowNullPointerException(const ThrowLocation* throw_location, const char* msg) {
- ThrowException(throw_location, "Ljava/lang/NullPointerException;", NULL, msg);
+void ThrowNullPointerException(const char* msg) {
+ ThrowException("Ljava/lang/NullPointerException;", NULL, msg);
}
// RuntimeException
void ThrowRuntimeException(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowException(NULL, "Ljava/lang/RuntimeException;", NULL, fmt, &args);
+ ThrowException("Ljava/lang/RuntimeException;", NULL, fmt, &args);
va_end(args);
}
void ThrowVerifyError(mirror::Class* referrer, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowException(NULL, "Ljava/lang/VerifyError;", referrer, fmt, &args);
+ ThrowException("Ljava/lang/VerifyError;", referrer, fmt, &args);
va_end(args);
}
} // namespace mirror
class Signature;
class StringPiece;
-class ThrowLocation;
// AbstractMethodError
void ThrowClassCastException(mirror::Class* dest_type, mirror::Class* src_type)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
-void ThrowClassCastException(const ThrowLocation* throw_location, const char* msg)
+void ThrowClassCastException(const char* msg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
// ClassFormatError
// IllegalAccessException
-void ThrowIllegalAccessException(const ThrowLocation* throw_location, const char* msg)
+void ThrowIllegalAccessException(const char* msg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
// IllegalArgumentException
-void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const char* msg)
+void ThrowIllegalArgumentException(const char* msg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
// IncompatibleClassChangeError
// NullPointerException
-void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location,
- mirror::ArtField* field,
+void ThrowNullPointerExceptionForFieldAccess(mirror::ArtField* field,
bool is_read)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
-void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
- uint32_t method_idx,
+void ThrowNullPointerExceptionForMethodAccess(uint32_t method_idx,
InvokeType type)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
-void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location,
- mirror::ArtMethod* method,
+void ThrowNullPointerExceptionForMethodAccess(mirror::ArtMethod* method,
InvokeType type)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
-void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location)
+void ThrowNullPointerExceptionFromDexPC()
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
-void ThrowNullPointerException(const ThrowLocation* throw_location, const char* msg)
+void ThrowNullPointerException(const char* msg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) COLD_ATTR;
// RuntimeException
#include "ScopedPrimitiveArray.h"
#include "handle_scope-inl.h"
#include "thread_list.h"
-#include "throw_location.h"
#include "utf.h"
#include "verifier/method_verifier-inl.h"
#include "well_known_classes.h"
class ScopedObjectAccessUnchecked;
class StackVisitor;
class Thread;
-class ThrowLocation;
/*
* Invoke-during-breakpoint support.
}
if (kAccessCheck) {
if (UNLIKELY(!klass->IsInstantiable())) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewException(throw_location, "Ljava/lang/InstantiationError;",
- PrettyDescriptor(klass).c_str());
+ self->ThrowNewException("Ljava/lang/InstantiationError;", PrettyDescriptor(klass).c_str());
*slow_path = true;
return nullptr; // Failure
}
} else {
if (UNLIKELY(resolved_field->IsPrimitiveType() != is_primitive ||
resolved_field->FieldSize() != expected_size)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- DCHECK(throw_location.GetMethod() == referrer);
- self->ThrowNewExceptionF(throw_location, "Ljava/lang/NoSuchFieldError;",
+ self->ThrowNewExceptionF("Ljava/lang/NoSuchFieldError;",
"Attempted read of %zd-bit %s on field '%s'",
expected_size * (32 / sizeof(int32_t)),
is_primitive ? "primitive" : "non-primitive",
} else if (UNLIKELY(*this_object == nullptr && type != kStatic)) {
// Maintain interpreter-like semantics where NullPointerException is thrown
// after potential NoSuchMethodError from class linker.
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- DCHECK_EQ(*referrer, throw_location.GetMethod());
- ThrowNullPointerExceptionForMethodAccess(throw_location, method_idx, type);
+ ThrowNullPointerExceptionForMethodAccess(method_idx, type);
return nullptr; // Failure.
} else if (access_check) {
// Incompatible class change should have been handled in resolve method.
ThrowRuntimeException("Bad filled array request for type %s",
PrettyDescriptor(klass).c_str());
} else {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- DCHECK(throw_location.GetMethod() == referrer);
self->ThrowNewExceptionF(
- throw_location, "Ljava/lang/InternalError;",
+ "Ljava/lang/InternalError;",
"Found type %s; filled-new-array not implemented for anything but 'int'",
PrettyDescriptor(klass).c_str());
}
// This can cause thread suspension.
mirror::Class* result_type = h_interface_method->GetReturnType();
mirror::Object* result_ref = soa.Decode<mirror::Object*>(result);
- mirror::Object* rcvr = soa.Decode<mirror::Object*>(rcvr_jobj);
- mirror::ArtMethod* proxy_method;
- if (h_interface_method->GetDeclaringClass()->IsInterface()) {
- proxy_method = rcvr->GetClass()->FindVirtualMethodForInterface(h_interface_method.Get());
- } else {
- // Proxy dispatch to a method defined in Object.
- DCHECK(h_interface_method->GetDeclaringClass()->IsObjectClass());
- proxy_method = h_interface_method.Get();
- }
- ThrowLocation throw_location(rcvr, proxy_method, -1);
JValue result_unboxed;
- if (!UnboxPrimitiveForResult(throw_location, result_ref, result_type, &result_unboxed)) {
+ if (!UnboxPrimitiveForResult(result_ref, result_type, &result_unboxed)) {
DCHECK(soa.Self()->IsExceptionPending());
return zero;
}
declares_exception = declared_exception->IsAssignableFrom(exception_class);
}
if (!declares_exception) {
- ThrowLocation throw_location(rcvr, proxy_method, -1);
- soa.Self()->ThrowNewWrappedException(throw_location,
- "Ljava/lang/reflect/UndeclaredThrowableException;",
+ soa.Self()->ThrowNewWrappedException("Ljava/lang/reflect/UndeclaredThrowableException;",
NULL);
}
}
bool FillArrayData(mirror::Object* obj, const Instruction::ArrayDataPayload* payload) {
DCHECK_EQ(payload->ident, static_cast<uint16_t>(Instruction::kArrayDataSignature));
if (UNLIKELY(obj == nullptr)) {
- ThrowNullPointerException(nullptr, "null array in FILL_ARRAY_DATA");
+ ThrowNullPointerException("null array in FILL_ARRAY_DATA");
return false;
}
mirror::Array* array = obj->AsArray();
DCHECK(!array->IsObjectArray());
if (UNLIKELY(static_cast<int32_t>(payload->element_count) > array->GetLength())) {
Thread* self = Thread::Current();
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewExceptionF(throw_location,
- "Ljava/lang/ArrayIndexOutOfBoundsException;",
+ self->ThrowNewExceptionF("Ljava/lang/ArrayIndexOutOfBoundsException;",
"failed FILL_ARRAY_DATA; length=%d, index=%d",
array->GetLength(), payload->element_count);
return false;
sizeof(int8_t));
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, true);
+ ThrowNullPointerExceptionForFieldAccess(field, true);
} else {
return field->GetByte(obj);
}
sizeof(int8_t));
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, true);
+ ThrowNullPointerExceptionForFieldAccess(field, true);
} else {
return field->GetBoolean(obj);
}
sizeof(int16_t));
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, true);
+ ThrowNullPointerExceptionForFieldAccess(field, true);
} else {
return field->GetShort(obj);
}
sizeof(int16_t));
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, true);
+ ThrowNullPointerExceptionForFieldAccess(field, true);
} else {
return field->GetChar(obj);
}
sizeof(int32_t));
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, true);
+ ThrowNullPointerExceptionForFieldAccess(field, true);
} else {
return field->Get32(obj);
}
sizeof(int64_t));
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, true);
+ ThrowNullPointerExceptionForFieldAccess(field, true);
} else {
return field->Get64(obj);
}
sizeof(mirror::HeapReference<mirror::Object>));
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, true);
+ ThrowNullPointerExceptionForFieldAccess(field, true);
} else {
return field->GetObj(obj);
}
}
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, false);
+ ThrowNullPointerExceptionForFieldAccess(field, false);
} else {
Primitive::Type type = field->GetTypeAsPrimitiveType();
// Compiled code can't use transactional mode.
}
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, false);
+ ThrowNullPointerExceptionForFieldAccess(field, false);
} else {
Primitive::Type type = field->GetTypeAsPrimitiveType();
// Compiled code can't use transactional mode.
}
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, false);
+ ThrowNullPointerExceptionForFieldAccess(field, false);
} else {
// Compiled code can't use transactional mode.
field->Set32<false>(obj, new_value);
sizeof(int64_t));
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, false);
+ ThrowNullPointerExceptionForFieldAccess(field, false);
} else {
// Compiled code can't use transactional mode.
field->Set64<false>(obj, new_value);
sizeof(mirror::HeapReference<mirror::Object>));
if (LIKELY(field != nullptr)) {
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionForFieldAccess(throw_location, field, false);
+ ThrowNullPointerExceptionForFieldAccess(field, false);
} else {
// Compiled code can't use transactional mode.
field->SetObj<false>(obj, new_value);
NO_THREAD_SAFETY_ANALYSIS /* EXCLUSIVE_LOCK_FUNCTION(Monitor::monitor_lock_) */ {
ScopedQuickEntrypointChecks sqec(self);
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location(self->GetCurrentLocationForThrow());
- ThrowNullPointerException(&throw_location,
- "Null reference used for synchronization (monitor-enter)");
+ ThrowNullPointerException("Null reference used for synchronization (monitor-enter)");
return -1; // Failure.
} else {
if (kIsDebugBuild) {
NO_THREAD_SAFETY_ANALYSIS /* UNLOCK_FUNCTION(Monitor::monitor_lock_) */ {
ScopedQuickEntrypointChecks sqec(self);
if (UNLIKELY(obj == nullptr)) {
- ThrowLocation throw_location(self->GetCurrentLocationForThrow());
- ThrowNullPointerException(&throw_location,
- "Null reference used for synchronization (monitor-exit)");
+ ThrowNullPointerException("Null reference used for synchronization (monitor-exit)");
return -1; // Failure.
} else {
// MonitorExit may throw exception.
*/
ScopedQuickEntrypointChecks sqec(self);
if (exception == nullptr) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewException(throw_location, "Ljava/lang/NullPointerException;",
- "throw with null exception");
+ self->ThrowNewException("Ljava/lang/NullPointerException;", "throw with null exception");
} else {
self->SetException(exception);
}
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
ScopedQuickEntrypointChecks sqec(self);
self->NoteSignalBeingHandled();
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- ThrowNullPointerExceptionFromDexPC(throw_location);
+ ThrowNullPointerExceptionFromDexPC();
self->NoteSignalHandlerDone();
self->QuickDeliverException();
}
} // namespace mirror
union JValue;
class Thread;
-class ThrowLocation;
namespace instrumentation {
namespace art {
namespace interpreter {
-void ThrowNullPointerExceptionFromInterpreter(const ShadowFrame& shadow_frame) {
- ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow());
+void ThrowNullPointerExceptionFromInterpreter() {
+ ThrowNullPointerExceptionFromDexPC();
}
template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check>
} else {
obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data));
if (UNLIKELY(obj == nullptr)) {
- ThrowNullPointerExceptionForFieldAccess(shadow_frame.GetCurrentLocationForThrow(), f, true);
+ ThrowNullPointerExceptionForFieldAccess(f, true);
return false;
}
}
if (UNLIKELY(obj == nullptr)) {
// We lost the reference to the field index so we cannot get a more
// precised exception message.
- ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow());
+ ThrowNullPointerExceptionFromDexPC();
return false;
}
MemberOffset field_offset(inst->VRegC_22c());
} else {
obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data));
if (UNLIKELY(obj == nullptr)) {
- ThrowNullPointerExceptionForFieldAccess(shadow_frame.GetCurrentLocationForThrow(),
- f, false);
+ ThrowNullPointerExceptionForFieldAccess(f, false);
return false;
}
}
if (!reg->VerifierInstanceOf(field_class)) {
// This should never happen.
std::string temp1, temp2, temp3;
- self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(),
- "Ljava/lang/VirtualMachineError;",
+ self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;",
"Put '%s' that is not instance of field '%s' in '%s'",
reg->GetClass()->GetDescriptor(&temp1),
field_class->GetDescriptor(&temp2),
if (UNLIKELY(obj == nullptr)) {
// We lost the reference to the field index so we cannot get a more
// precised exception message.
- ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow());
+ ThrowNullPointerExceptionFromDexPC();
return false;
}
MemberOffset field_offset(inst->VRegC_22c());
if (!o->VerifierInstanceOf(arg_type)) {
// This should never happen.
std::string temp1, temp2;
- self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(),
- "Ljava/lang/VirtualMachineError;",
+ self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;",
"Invoking %s with bad arg %d, type '%s' not instance of '%s'",
new_shadow_frame->GetMethod()->GetName(), shorty_pos,
o->GetClass()->GetDescriptor(&temp1),
ThrowRuntimeException("Bad filled array request for type %s",
PrettyDescriptor(componentClass).c_str());
} else {
- self->ThrowNewExceptionF(shadow_frame.GetCurrentLocationForThrow(),
- "Ljava/lang/InternalError;",
+ self->ThrowNewExceptionF("Ljava/lang/InternalError;",
"Found type %s; filled-new-array not implemented for anything but 'int'",
PrettyDescriptor(componentClass).c_str());
}
// If it is not an InternalError, wrap it.
std::string type(PrettyTypeOf(self->GetException()));
if (type != "java.lang.InternalError") {
- self->ThrowNewWrappedException(self->GetCurrentLocationForThrow(),
- "Ljava/lang/ClassNotFoundException;",
+ self->ThrowNewWrappedException("Ljava/lang/ClassNotFoundException;",
"ClassNotFoundException");
}
}
ok = true;
}
} else {
- self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(), "Ljava/lang/InternalError;",
+ self->ThrowNewExceptionF("Ljava/lang/InternalError;",
"Could not find default constructor for '%s'",
PrettyClass(h_klass.Get()).c_str());
}
std::string error_msg = StringPrintf("Failed in Class.newInstance for '%s' with %s",
PrettyClass(h_klass.Get()).c_str(),
PrettyTypeOf(self->GetException()).c_str());
- self->ThrowNewWrappedException(self->GetCurrentLocationForThrow(),
- "Ljava/lang/InternalError;",
- error_msg.c_str());
+ self->ThrowNewWrappedException("Ljava/lang/InternalError;", error_msg.c_str());
}
} else if (name == "java.lang.reflect.Field java.lang.Class.getDeclaredField(java.lang.String)") {
// Special managed code cut-out to allow field lookup in a un-started runtime that'd fail
dst->Set(dstPos + i, src->Get(srcPos + i));
}
} else {
- self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(), "Ljava/lang/InternalError;",
+ self->ThrowNewExceptionF("Ljava/lang/InternalError;",
"Unimplemented System.arraycopy for type '%s'",
PrettyDescriptor(ctype).c_str());
}
}
if (!ok) {
- self->ThrowNewException(self->GetCurrentLocationForThrow(), "Ljava/lang/InternalError;",
- "Unimplemented ThreadLocal.get");
+ self->ThrowNewException("Ljava/lang/InternalError;", "Unimplemented ThreadLocal.get");
}
} else {
// Not special, continue with regular interpreter execution.
extern JValue ExecuteGotoImpl(Thread* self, const DexFile::CodeItem* code_item,
ShadowFrame& shadow_frame, JValue result_register);
-void ThrowNullPointerExceptionFromInterpreter(const ShadowFrame& shadow_frame)
+void ThrowNullPointerExceptionFromInterpreter()
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
static inline void DoMonitorEnter(Thread* self, Object* ref) NO_THREAD_SAFETY_ANALYSIS {
if (UNLIKELY(receiver == nullptr)) {
// We lost the reference to the method index so we cannot get a more
// precised exception message.
- ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow());
+ ThrowNullPointerExceptionFromDexPC();
return false;
}
const uint32_t vtable_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c();
if (!obj_result->VerifierInstanceOf(return_type)) {
// This should never happen.
std::string temp1, temp2;
- self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(),
- "Ljava/lang/VirtualMachineError;",
+ self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;",
"Returning '%s' that is not instance of return type '%s'",
obj_result->GetClass()->GetDescriptor(&temp1),
return_type->GetDescriptor(&temp2));
HANDLE_INSTRUCTION_START(MONITOR_ENTER) {
Object* obj = shadow_frame.GetVRegReference(inst->VRegA_11x(inst_data));
if (UNLIKELY(obj == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
DoMonitorEnter(self, obj);
HANDLE_INSTRUCTION_START(MONITOR_EXIT) {
Object* obj = shadow_frame.GetVRegReference(inst->VRegA_11x(inst_data));
if (UNLIKELY(obj == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
DoMonitorExit(self, obj);
HANDLE_INSTRUCTION_START(ARRAY_LENGTH) {
Object* array = shadow_frame.GetVRegReference(inst->VRegB_12x(inst_data));
if (UNLIKELY(array == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
shadow_frame.SetVReg(inst->VRegA_12x(inst_data), array->AsArray()->GetLength());
HANDLE_INSTRUCTION_START(THROW) {
Object* exception = shadow_frame.GetVRegReference(inst->VRegA_11x(inst_data));
if (UNLIKELY(exception == NULL)) {
- ThrowNullPointerException(NULL, "throw with null exception");
+ ThrowNullPointerException("throw with null exception");
} else if (do_assignability_check && !exception->GetClass()->IsThrowableClass()) {
// This should never happen.
std::string temp;
- self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(),
- "Ljava/lang/VirtualMachineError;",
+ self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;",
"Throwing '%s' that is not instance of Throwable",
exception->GetClass()->GetDescriptor(&temp));
} else {
HANDLE_INSTRUCTION_START(AGET_BOOLEAN) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
HANDLE_INSTRUCTION_START(AGET_BYTE) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
HANDLE_INSTRUCTION_START(AGET_CHAR) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
HANDLE_INSTRUCTION_START(AGET_SHORT) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
HANDLE_INSTRUCTION_START(AGET) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
HANDLE_INSTRUCTION_START(AGET_WIDE) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
HANDLE_INSTRUCTION_START(AGET_OBJECT) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
HANDLE_INSTRUCTION_START(APUT_BOOLEAN) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
uint8_t val = shadow_frame.GetVReg(inst->VRegA_23x(inst_data));
HANDLE_INSTRUCTION_START(APUT_BYTE) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int8_t val = shadow_frame.GetVReg(inst->VRegA_23x(inst_data));
HANDLE_INSTRUCTION_START(APUT_CHAR) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
uint16_t val = shadow_frame.GetVReg(inst->VRegA_23x(inst_data));
HANDLE_INSTRUCTION_START(APUT_SHORT) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int16_t val = shadow_frame.GetVReg(inst->VRegA_23x(inst_data));
HANDLE_INSTRUCTION_START(APUT) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int32_t val = shadow_frame.GetVReg(inst->VRegA_23x(inst_data));
HANDLE_INSTRUCTION_START(APUT_WIDE) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int64_t val = shadow_frame.GetVRegLong(inst->VRegA_23x(inst_data));
HANDLE_INSTRUCTION_START(APUT_OBJECT) {
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
int32_t index = shadow_frame.GetVReg(inst->VRegC_23x());
if (!obj_result->VerifierInstanceOf(return_type)) {
// This should never happen.
std::string temp1, temp2;
- self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(),
- "Ljava/lang/VirtualMachineError;",
+ self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;",
"Returning '%s' that is not instance of return type '%s'",
obj_result->GetClass()->GetDescriptor(&temp1),
return_type->GetDescriptor(&temp2));
PREAMBLE();
Object* obj = shadow_frame.GetVRegReference(inst->VRegA_11x(inst_data));
if (UNLIKELY(obj == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
DoMonitorEnter(self, obj);
PREAMBLE();
Object* obj = shadow_frame.GetVRegReference(inst->VRegA_11x(inst_data));
if (UNLIKELY(obj == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
DoMonitorExit(self, obj);
PREAMBLE();
Object* array = shadow_frame.GetVRegReference(inst->VRegB_12x(inst_data));
if (UNLIKELY(array == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
} else {
shadow_frame.SetVReg(inst->VRegA_12x(inst_data), array->AsArray()->GetLength());
PREAMBLE();
Object* exception = shadow_frame.GetVRegReference(inst->VRegA_11x(inst_data));
if (UNLIKELY(exception == NULL)) {
- ThrowNullPointerException(NULL, "throw with null exception");
+ ThrowNullPointerException("throw with null exception");
} else if (do_assignability_check && !exception->GetClass()->IsThrowableClass()) {
// This should never happen.
std::string temp;
- self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(),
- "Ljava/lang/VirtualMachineError;",
+ self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;",
"Throwing '%s' that is not instance of Throwable",
exception->GetClass()->GetDescriptor(&temp));
} else {
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
PREAMBLE();
Object* a = shadow_frame.GetVRegReference(inst->VRegB_23x());
if (UNLIKELY(a == NULL)) {
- ThrowNullPointerExceptionFromInterpreter(shadow_frame);
+ ThrowNullPointerExceptionFromInterpreter();
HANDLE_PENDING_EXCEPTION();
break;
}
}
// Throwing can cause libraries_lock to be reacquired.
if (native_method == nullptr) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewException(throw_location, "Ljava/lang/UnsatisfiedLinkError;", detail.c_str());
+ self->ThrowNewException("Ljava/lang/UnsatisfiedLinkError;", detail.c_str());
}
return native_method;
}
} // namespace mirror
union JValue;
class Thread;
-class ThrowLocation;
namespace jit {
static void ThrowNoSuchMethodError(ScopedObjectAccess& soa, mirror::Class* c,
const char* name, const char* sig, const char* kind)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
std::string temp;
- soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/NoSuchMethodError;",
+ soa.Self()->ThrowNewExceptionF("Ljava/lang/NoSuchMethodError;",
"no %s method \"%s.%s%s\"",
kind, c->GetDescriptor(&temp), name, sig);
}
LOG(return_errors ? ERROR : FATAL) << "Failed to register native method in "
<< PrettyDescriptor(c) << " in " << c->GetDexCache()->GetLocation()->ToModifiedUtf8()
<< ": " << kind << " is null at index " << idx;
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
- soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/NoSuchMethodError;",
+ soa.Self()->ThrowNewExceptionF("Ljava/lang/NoSuchMethodError;",
"%s is null at index %d", kind, idx);
}
Handle<mirror::Throwable> cause(hs2.NewHandle(soa.Self()->GetException()));
soa.Self()->ClearException();
std::string temp;
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
- soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/NoSuchFieldError;",
+ soa.Self()->ThrowNewExceptionF("Ljava/lang/NoSuchFieldError;",
"no type \"%s\" found and so no field \"%s\" "
"could be found in class \"%s\" or its superclasses", sig, name,
c->GetDescriptor(&temp));
field = c->FindInstanceField(name, field_type->GetDescriptor(&temp));
}
if (field == nullptr) {
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
- soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/NoSuchFieldError;",
+ soa.Self()->ThrowNewExceptionF("Ljava/lang/NoSuchFieldError;",
"no \"%s\" field \"%s\" in class \"%s\" or its superclasses",
sig, name, c->GetDescriptor(&temp));
return nullptr;
jsize length, const char* identifier)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
std::string type(PrettyTypeOf(array));
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
- soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/ArrayIndexOutOfBoundsException;",
+ soa.Self()->ThrowNewExceptionF("Ljava/lang/ArrayIndexOutOfBoundsException;",
"%s offset=%d length=%d %s.length=%d",
type.c_str(), start, length, identifier, array->GetLength());
}
static void ThrowSIOOBE(ScopedObjectAccess& soa, jsize start, jsize length,
jsize array_length)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
- soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/StringIndexOutOfBoundsException;",
+ soa.Self()->ThrowNewExceptionF("Ljava/lang/StringIndexOutOfBoundsException;",
"offset=%d length=%d string.length()=%d", start, length,
array_length);
}
std::string actualSrcType(PrettyTypeOf(o));
std::string dstType(PrettyTypeOf(this));
Thread* self = Thread::Current();
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
if (throw_exception) {
- self->ThrowNewExceptionF(throw_location, "Ljava/lang/ArrayStoreException;",
+ self->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
"source[%d] of type %s cannot be stored in destination array of type %s",
src_pos + i, actualSrcType.c_str(), dstType.c_str());
} else {
va_list args;
va_start(args, fmt);
Thread* self = Thread::Current();
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewExceptionV(throw_location, "Ljava/lang/IllegalMonitorStateException;", fmt, args);
+ self->ThrowNewExceptionV("Ljava/lang/IllegalMonitorStateException;", fmt, args);
if (!Runtime::Current()->IsStarted() || VLOG_IS_ON(monitor)) {
std::ostringstream ss;
self->Dump(ss);
// Enforce the timeout range.
if (ms < 0 || ns < 0 || ns > 999999) {
monitor_lock_.Unlock(self);
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewExceptionF(throw_location, "Ljava/lang/IllegalArgumentException;",
+ self->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
"timeout arguments out of range: ms=%" PRId64 " ns=%d", ms, ns);
return;
}
self->SetInterruptedLocked(false);
}
if (interruptShouldThrow) {
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewException(throw_location, "Ljava/lang/InterruptedException;", NULL);
+ self->ThrowNewException("Ljava/lang/InterruptedException;", NULL);
}
}
}
int fd = dup(originalFd);
if (fd < 0) {
ScopedObjectAccess soa(env);
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
- soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/RuntimeException;",
+ soa.Self()->ThrowNewExceptionF("Ljava/lang/RuntimeException;",
"dup(%d) failed: %s", originalFd, strerror(errno));
return;
}
static void ThrowUnsupportedOperationException(JNIEnv* env) {
ScopedObjectAccess soa(env);
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
- soa.Self()->ThrowNewException(throw_location, "Ljava/lang/UnsupportedOperationException;", NULL);
+ soa.Self()->ThrowNewException("Ljava/lang/UnsupportedOperationException;", NULL);
}
static void VMDebug_startInstructionCounting(JNIEnv* env, jclass) {
// Only one of these may be NULL.
if (javaFilename == NULL && javaFd == NULL) {
ScopedObjectAccess soa(env);
- ThrowNullPointerException(NULL, "fileName == null && fd == null");
+ ThrowNullPointerException("fileName == null && fd == null");
return;
}
}
mirror::Class* element_class = soa.Decode<mirror::Class*>(javaElementClass);
if (UNLIKELY(element_class == nullptr)) {
- ThrowNullPointerException(NULL, "element class == null");
+ ThrowNullPointerException("element class == null");
return nullptr;
}
Runtime* runtime = Runtime::Current();
}
mirror::Class* element_class = soa.Decode<mirror::Class*>(javaElementClass);
if (UNLIKELY(element_class == nullptr)) {
- ThrowNullPointerException(NULL, "element class == null");
+ ThrowNullPointerException("element class == null");
return nullptr;
}
Runtime* runtime = Runtime::Current();
ScopedFastNativeObjectAccess soa(env);
mirror::Array* array = soa.Decode<mirror::Array*>(javaArray);
if (!array->IsArrayInstance()) {
- ThrowIllegalArgumentException(NULL, "not an array");
+ ThrowIllegalArgumentException("not an array");
return 0;
}
if (Runtime::Current()->GetHeap()->IsMovableObject(array)) {
// is especially handy for array types, since we want to avoid
// auto-generating bogus array classes.
if (!IsValidBinaryClassName(name.c_str())) {
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
- soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/ClassNotFoundException;",
+ soa.Self()->ThrowNewExceptionF("Ljava/lang/ClassNotFoundException;",
"Invalid name: %s", name.c_str());
return nullptr;
}
static jint String_compareTo(JNIEnv* env, jobject javaThis, jobject javaRhs) {
ScopedFastNativeObjectAccess soa(env);
if (UNLIKELY(javaRhs == NULL)) {
- ThrowNullPointerException(NULL, "rhs == null");
+ ThrowNullPointerException("rhs == null");
return -1;
} else {
return soa.Decode<mirror::String*>(javaThis)->CompareTo(soa.Decode<mirror::String*>(javaRhs));
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
std::string actualType(PrettyTypeOf(array));
Thread* self = Thread::Current();
- ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewExceptionF(throw_location, "Ljava/lang/ArrayStoreException;",
+ self->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
"%s of type %s is not an array", identifier, actualType.c_str());
}
// Null pointer checks.
if (UNLIKELY(javaSrc == nullptr)) {
- ThrowNullPointerException(nullptr, "src == null");
+ ThrowNullPointerException("src == null");
return;
}
if (UNLIKELY(javaDst == nullptr)) {
- ThrowNullPointerException(nullptr, "dst == null");
+ ThrowNullPointerException("dst == null");
return;
}
if (UNLIKELY(srcPos < 0) || UNLIKELY(dstPos < 0) || UNLIKELY(count < 0) ||
UNLIKELY(srcPos > srcArray->GetLength() - count) ||
UNLIKELY(dstPos > dstArray->GetLength() - count)) {
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
- soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/ArrayIndexOutOfBoundsException;",
+ soa.Self()->ThrowNewExceptionF("Ljava/lang/ArrayIndexOutOfBoundsException;",
"src.length=%d srcPos=%d dst.length=%d dstPos=%d length=%d",
srcArray->GetLength(), srcPos, dstArray->GetLength(), dstPos,
count);
srcComponentType->IsPrimitive())) {
std::string srcType(PrettyTypeOf(srcArray));
std::string dstType(PrettyTypeOf(dstArray));
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
- soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/ArrayStoreException;",
+ soa.Self()->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
"Incompatible types: src=%s, dst=%s",
srcType.c_str(), dstType.c_str());
return;
ScopedObjectAccess soa(env);
mirror::Object* object = soa.Decode<mirror::Object*>(java_object);
if (object == NULL) {
- ThrowNullPointerException(NULL, "object == null");
+ ThrowNullPointerException("object == null");
return JNI_FALSE;
}
MutexLock mu(soa.Self(), *Locks::thread_list_lock_);
StackHandleScope<1> hs(soa.Self());
Handle<mirror::Class> c(hs.NewHandle(m->GetDeclaringClass()));
if (UNLIKELY(c->IsAbstract())) {
- ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow();
- soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/InstantiationException;",
+ soa.Self()->ThrowNewExceptionF("Ljava/lang/InstantiationException;",
"Can't instantiate %s %s",
c->IsInterface() ? "interface" : "abstract class",
PrettyDescriptor(c.Get()).c_str());
mirror::Object* obj)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
if (kIsSet && field->IsFinal()) {
- ThrowIllegalAccessException(nullptr,
+ ThrowIllegalAccessException(
StringPrintf("Cannot set %s field %s of class %s",
PrettyJavaAccessFlags(field->GetAccessFlags()).c_str(),
PrettyField(field).c_str(),
mirror::Class* calling_class = nullptr;
if (!VerifyAccess(self, obj, field->GetDeclaringClass(), field->GetAccessFlags(),
&calling_class)) {
- ThrowIllegalAccessException(nullptr,
+ ThrowIllegalAccessException(
StringPrintf("Class %s cannot access %s field %s of class %s",
calling_class == nullptr ? "null" : PrettyClass(calling_class).c_str(),
PrettyJavaAccessFlags(field->GetAccessFlags()).c_str(),
// Never okay.
break;
}
- ThrowIllegalArgumentException(nullptr, StringPrintf("Not a primitive field: %s",
- PrettyField(f).c_str()).c_str());
+ ThrowIllegalArgumentException(StringPrintf("Not a primitive field: %s",
+ PrettyField(f).c_str()).c_str());
return false;
}
}
// Widen it if necessary (and possible).
JValue wide_value;
- if (!ConvertPrimitiveValue(nullptr, false, field_type, kPrimitiveType, field_value,
+ if (!ConvertPrimitiveValue(false, field_type, kPrimitiveType, field_value,
&wide_value)) {
DCHECK(soa.Self()->IsExceptionPending());
return JValue();
FALLTHROUGH_INTENDED;
case Primitive::kPrimVoid:
// Never okay.
- ThrowIllegalArgumentException(nullptr, StringPrintf("Not a primitive field: %s",
- PrettyField(f).c_str()).c_str());
+ ThrowIllegalArgumentException(StringPrintf("Not a primitive field: %s",
+ PrettyField(f).c_str()).c_str());
return;
}
}
}
Primitive::Type field_type = f->GetTypeAsPrimitiveType();
if (UNLIKELY(field_type == Primitive::kPrimNot)) {
- ThrowIllegalArgumentException(nullptr, StringPrintf("Not a primitive field: %s",
- PrettyField(f).c_str()).c_str());
+ ThrowIllegalArgumentException(StringPrintf("Not a primitive field: %s",
+ PrettyField(f).c_str()).c_str());
return;
}
// Widen the value if necessary (and possible).
JValue wide_value;
- if (!ConvertPrimitiveValue(nullptr, false, kPrimitiveType, field_type, new_value, &wide_value)) {
+ if (!ConvertPrimitiveValue(false, kPrimitiveType, field_type, new_value, &wide_value)) {
DCHECK(soa.Self()->IsExceptionPending());
return;
}
} // namespace mirror
class Context;
class Thread;
-class ThrowLocation;
class ShadowFrame;
// Manages exception delivery for Quick backend.
namespace art {
-inline bool ConvertPrimitiveValue(const ThrowLocation* throw_location, bool unbox_for_result,
+inline bool ConvertPrimitiveValue(bool unbox_for_result,
Primitive::Type srcType, Primitive::Type dstType,
const JValue& src, JValue* dst) {
DCHECK(srcType != Primitive::kPrimNot && dstType != Primitive::kPrimNot);
break;
}
if (!unbox_for_result) {
- ThrowIllegalArgumentException(throw_location,
- StringPrintf("Invalid primitive conversion from %s to %s",
+ ThrowIllegalArgumentException(StringPrintf("Invalid primitive conversion from %s to %s",
PrettyDescriptor(srcType).c_str(),
PrettyDescriptor(dstType).c_str()).c_str());
} else {
- ThrowClassCastException(throw_location,
- StringPrintf("Couldn't convert result of type %s to %s",
+ ThrowClassCastException(StringPrintf("Couldn't convert result of type %s to %s",
PrettyDescriptor(srcType).c_str(),
PrettyDescriptor(dstType).c_str()).c_str());
}
static void ThrowIllegalPrimitiveArgumentException(const char* expected,
const char* found_descriptor)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- ThrowIllegalArgumentException(nullptr,
+ ThrowIllegalArgumentException(
StringPrintf("Invalid primitive conversion from %s to %s", expected,
PrettyDescriptor(found_descriptor).c_str()).c_str());
}
mirror::Class* dst_class =
h_m->GetClassFromTypeIndex(classes->GetTypeItem(args_offset).type_idx_, true);
if (UNLIKELY(arg == nullptr || !arg->InstanceOf(dst_class))) {
- ThrowIllegalArgumentException(nullptr,
+ ThrowIllegalArgumentException(
StringPrintf("method %s argument %zd has type %s, got %s",
PrettyMethod(h_m.Get(), false).c_str(),
args_offset + 1, // Humans don't count from 0.
ThrowIllegalPrimitiveArgumentException(expected, \
arg->GetClass<>()->GetDescriptor(&temp)); \
} else { \
- ThrowIllegalArgumentException(nullptr, \
+ ThrowIllegalArgumentException(\
StringPrintf("method %s argument %zd has type %s, got %s", \
PrettyMethod(h_m.Get(), false).c_str(), \
args_offset + 1, \
uint32_t classes_size = (classes == nullptr) ? 0 : classes->Size();
uint32_t arg_count = (objects != nullptr) ? objects->GetLength() : 0;
if (arg_count != classes_size) {
- ThrowIllegalArgumentException(nullptr,
- StringPrintf("Wrong number of arguments; expected %d, got %d",
+ ThrowIllegalArgumentException(StringPrintf("Wrong number of arguments; expected %d, got %d",
classes_size, arg_count).c_str());
return nullptr;
}
mirror::Class* calling_class = nullptr;
if (!accessible && !VerifyAccess(soa.Self(), receiver, declaring_class, m->GetAccessFlags(),
&calling_class)) {
- ThrowIllegalAccessException(nullptr,
+ ThrowIllegalAccessException(
StringPrintf("Class %s cannot access %s method %s of class %s",
calling_class == nullptr ? "null" : PrettyClass(calling_class).c_str(),
PrettyJavaAccessFlags(m->GetAccessFlags()).c_str(),
bool VerifyObjectIsClass(mirror::Object* o, mirror::Class* c) {
if (o == nullptr) {
- ThrowNullPointerException(nullptr, "null receiver");
+ ThrowNullPointerException("null receiver");
return false;
} else if (!o->InstanceOf(c)) {
std::string expected_class_name(PrettyDescriptor(c));
std::string actual_class_name(PrettyTypeOf(o));
- ThrowIllegalArgumentException(nullptr,
- StringPrintf("Expected receiver of type %s, but got %s",
+ ThrowIllegalArgumentException(StringPrintf("Expected receiver of type %s, but got %s",
expected_class_name.c_str(),
actual_class_name.c_str()).c_str());
return false;
return "result";
}
-static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* o,
+static bool UnboxPrimitive(mirror::Object* o,
mirror::Class* dst_class, mirror::ArtField* f,
JValue* unboxed_value)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
if (!dst_class->IsPrimitive()) {
if (UNLIKELY(o != nullptr && !o->InstanceOf(dst_class))) {
if (!unbox_for_result) {
- ThrowIllegalArgumentException(throw_location,
- StringPrintf("%s has type %s, got %s",
+ ThrowIllegalArgumentException(StringPrintf("%s has type %s, got %s",
UnboxingFailureKind(f).c_str(),
PrettyDescriptor(dst_class).c_str(),
PrettyTypeOf(o).c_str()).c_str());
} else {
- ThrowClassCastException(throw_location,
- StringPrintf("Couldn't convert result of type %s to %s",
+ ThrowClassCastException(StringPrintf("Couldn't convert result of type %s to %s",
PrettyTypeOf(o).c_str(),
PrettyDescriptor(dst_class).c_str()).c_str());
}
return true;
}
if (UNLIKELY(dst_class->GetPrimitiveType() == Primitive::kPrimVoid)) {
- ThrowIllegalArgumentException(throw_location,
- StringPrintf("Can't unbox %s to void",
+ ThrowIllegalArgumentException(StringPrintf("Can't unbox %s to void",
UnboxingFailureKind(f).c_str()).c_str());
return false;
}
if (UNLIKELY(o == nullptr)) {
if (!unbox_for_result) {
- ThrowIllegalArgumentException(throw_location,
- StringPrintf("%s has type %s, got null",
+ ThrowIllegalArgumentException(StringPrintf("%s has type %s, got null",
UnboxingFailureKind(f).c_str(),
PrettyDescriptor(dst_class).c_str()).c_str());
} else {
- ThrowNullPointerException(throw_location,
- StringPrintf("Expected to unbox a '%s' primitive type but was returned null",
+ ThrowNullPointerException(StringPrintf("Expected to unbox a '%s' primitive type but was returned null",
PrettyDescriptor(dst_class).c_str()).c_str());
}
return false;
boxed_value.SetS(primitive_field->GetShort(o));
} else {
std::string temp;
- ThrowIllegalArgumentException(throw_location,
+ ThrowIllegalArgumentException(
StringPrintf("%s has type %s, got %s", UnboxingFailureKind(f).c_str(),
PrettyDescriptor(dst_class).c_str(),
PrettyDescriptor(o->GetClass()->GetDescriptor(&temp)).c_str()).c_str());
return false;
}
- return ConvertPrimitiveValue(throw_location, unbox_for_result,
+ return ConvertPrimitiveValue(unbox_for_result,
src_class->GetPrimitiveType(), dst_class->GetPrimitiveType(),
boxed_value, unboxed_value);
}
bool UnboxPrimitiveForField(mirror::Object* o, mirror::Class* dst_class, mirror::ArtField* f,
JValue* unboxed_value) {
DCHECK(f != nullptr);
- return UnboxPrimitive(nullptr, o, dst_class, f, unboxed_value);
+ return UnboxPrimitive(o, dst_class, f, unboxed_value);
}
-bool UnboxPrimitiveForResult(const ThrowLocation& throw_location, mirror::Object* o,
+bool UnboxPrimitiveForResult(mirror::Object* o,
mirror::Class* dst_class, JValue* unboxed_value) {
- return UnboxPrimitive(&throw_location, o, dst_class, nullptr, unboxed_value);
+ return UnboxPrimitive(o, dst_class, nullptr, unboxed_value);
}
bool VerifyAccess(Thread* self, mirror::Object* obj, mirror::Class* declaring_class,
union JValue;
class ScopedObjectAccessAlreadyRunnable;
class ShadowFrame;
-class ThrowLocation;
mirror::Object* BoxPrimitive(Primitive::Type src_class, const JValue& value)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
bool UnboxPrimitiveForField(mirror::Object* o, mirror::Class* dst_class, mirror::ArtField* f,
JValue* unboxed_value)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-bool UnboxPrimitiveForResult(const ThrowLocation& throw_location, mirror::Object* o,
- mirror::Class* dst_class, JValue* unboxed_value)
+bool UnboxPrimitiveForResult(mirror::Object* o, mirror::Class* dst_class, JValue* unboxed_value)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-ALWAYS_INLINE bool ConvertPrimitiveValue(const ThrowLocation* throw_location, bool unbox_for_result,
+ALWAYS_INLINE bool ConvertPrimitiveValue(bool unbox_for_result,
Primitive::Type src_class, Primitive::Type dst_class,
const JValue& src, JValue* dst)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
}
// Pre-allocate an OutOfMemoryError for the double-OOME case.
- self->ThrowNewException(ThrowLocation(), "Ljava/lang/OutOfMemoryError;",
+ self->ThrowNewException("Ljava/lang/OutOfMemoryError;",
"OutOfMemoryError thrown while trying to throw OutOfMemoryError; "
"no stack trace available");
pre_allocated_OutOfMemoryError_ = GcRoot<mirror::Throwable>(self->GetException());
// Pre-allocate a NoClassDefFoundError for the common case of failing to find a system class
// ahead of checking the application's class loader.
- self->ThrowNewException(ThrowLocation(), "Ljava/lang/NoClassDefFoundError;",
+ self->ThrowNewException("Ljava/lang/NoClassDefFoundError;",
"Class not found using the boot class loader; no stack trace available");
pre_allocated_NoClassDefFoundError_ = GcRoot<mirror::Throwable>(self->GetException());
self->ClearException();
#include "runtime.h"
#include "thread.h"
#include "thread_list.h"
-#include "throw_location.h"
#include "verify_object-inl.h"
#include "vmap_table.h"
}
}
-ThrowLocation ShadowFrame::GetCurrentLocationForThrow() const {
- return ThrowLocation(GetThisObject(), GetMethod(), GetDexPC());
-}
-
size_t ManagedStack::NumJniShadowFrameReferences() const {
size_t count = 0;
for (const ManagedStack* current_fragment = this; current_fragment != NULL;
#include "gc_root.h"
#include "mirror/object_reference.h"
#include "read_barrier.h"
-#include "throw_location.h"
#include "utils.h"
#include "verify_object.h"
class ShadowFrame;
class HandleScope;
class ScopedObjectAccess;
+class StackVisitor;
class Thread;
// The kind of vreg being accessed in calls to Set/GetVReg.
mirror::Object* GetThisObject(uint16_t num_ins) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- ThrowLocation GetCurrentLocationForThrow() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-
bool Contains(StackReference<mirror::Object>* shadow_frame_entry_obj) const {
if (HasReferenceArray()) {
return ((&References()[0] <= shadow_frame_entry_obj) &&
return result;
}
-void Thread::ThrowNewExceptionF(const ThrowLocation& throw_location,
- const char* exception_class_descriptor, const char* fmt, ...) {
+void Thread::ThrowNewExceptionF(const char* exception_class_descriptor, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowNewExceptionV(throw_location, exception_class_descriptor,
- fmt, args);
+ ThrowNewExceptionV(exception_class_descriptor, fmt, args);
va_end(args);
}
-void Thread::ThrowNewExceptionV(const ThrowLocation& throw_location,
- const char* exception_class_descriptor,
+void Thread::ThrowNewExceptionV(const char* exception_class_descriptor,
const char* fmt, va_list ap) {
std::string msg;
StringAppendV(&msg, fmt, ap);
- ThrowNewException(throw_location, exception_class_descriptor, msg.c_str());
+ ThrowNewException(exception_class_descriptor, msg.c_str());
}
-void Thread::ThrowNewException(const ThrowLocation& throw_location,
- const char* exception_class_descriptor,
+void Thread::ThrowNewException(const char* exception_class_descriptor,
const char* msg) {
// Callers should either clear or call ThrowNewWrappedException.
AssertNoPendingExceptionForNewException(msg);
- ThrowNewWrappedException(throw_location, exception_class_descriptor, msg);
+ ThrowNewWrappedException(exception_class_descriptor, msg);
}
static mirror::ClassLoader* GetCurrentClassLoader(Thread* self)
: nullptr;
}
-void Thread::ThrowNewWrappedException(const ThrowLocation& throw_location ATTRIBUTE_UNUSED,
- const char* exception_class_descriptor,
+void Thread::ThrowNewWrappedException(const char* exception_class_descriptor,
const char* msg) {
DCHECK_EQ(this, Thread::Current());
ScopedObjectAccessUnchecked soa(this);
msg, (tls32_.throwing_OutOfMemoryError ? " (recursive case)" : ""));
if (!tls32_.throwing_OutOfMemoryError) {
tls32_.throwing_OutOfMemoryError = true;
- ThrowNewException(GetCurrentLocationForThrow(), "Ljava/lang/OutOfMemoryError;", msg);
+ ThrowNewException("Ljava/lang/OutOfMemoryError;", msg);
tls32_.throwing_OutOfMemoryError = false;
} else {
Dump(LOG(WARNING)); // The pre-allocated OOME has no stack, so help out and log one.
return visitor.method_;
}
-ThrowLocation Thread::GetCurrentLocationForThrow() {
- Context* context = GetLongJumpContext();
- CurrentMethodVisitor visitor(this, context, true);
- visitor.WalkStack(false);
- ReleaseLongJumpContext(context);
- return ThrowLocation(visitor.this_object_, visitor.method_, visitor.dex_pc_);
-}
-
bool Thread::HoldsLock(mirror::Object* object) const {
if (object == nullptr) {
return false;
#include "runtime_stats.h"
#include "stack.h"
#include "thread_state.h"
-#include "throw_location.h"
namespace art {
bool IsExceptionThrownByCurrentMethod(mirror::Throwable* exception) const
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- ThrowLocation GetCurrentLocationForThrow() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-
void SetTopOfStack(StackReference<mirror::ArtMethod>* top_method) {
tlsPtr_.managed_stack.SetTopQuickFrame(top_method);
}
}
// If 'msg' is NULL, no detail message is set.
- void ThrowNewException(const ThrowLocation& throw_location,
- const char* exception_class_descriptor, const char* msg)
+ void ThrowNewException(const char* exception_class_descriptor, const char* msg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// If 'msg' is NULL, no detail message is set. An exception must be pending, and will be
// used as the new exception's cause.
- void ThrowNewWrappedException(const ThrowLocation& throw_location,
- const char* exception_class_descriptor,
- const char* msg)
+ void ThrowNewWrappedException(const char* exception_class_descriptor, const char* msg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- void ThrowNewExceptionF(const ThrowLocation& throw_location,
- const char* exception_class_descriptor, const char* fmt, ...)
- __attribute__((format(printf, 4, 5)))
+ void ThrowNewExceptionF(const char* exception_class_descriptor, const char* fmt, ...)
+ __attribute__((format(printf, 3, 4)))
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- void ThrowNewExceptionV(const ThrowLocation& throw_location,
- const char* exception_class_descriptor, const char* fmt, va_list ap)
+ void ThrowNewExceptionV(const char* exception_class_descriptor, const char* fmt, va_list ap)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// OutOfMemoryError is special, because we need to pre-allocate an instance.
+++ /dev/null
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "throw_location.h"
-
-#include "mirror/art_method-inl.h"
-#include "mirror/class-inl.h"
-#include "mirror/object-inl.h"
-#include "utils.h"
-
-namespace art {
-
-std::string ThrowLocation::Dump() const {
- if (method_ != nullptr) {
- return StringPrintf("%s:%d", PrettyMethod(method_).c_str(),
- method_->GetLineNumFromDexPC(dex_pc_));
- } else {
- return "unknown throw location";
- }
-}
-
-void ThrowLocation::VisitRoots(RootCallback* visitor, void* arg) {
- if (this_object_ != nullptr) {
- visitor(&this_object_, arg, RootInfo(kRootVMInternal));
- DCHECK(this_object_ != nullptr);
- }
- if (method_ != nullptr) {
- visitor(reinterpret_cast<mirror::Object**>(&method_), arg, RootInfo(kRootVMInternal));
- DCHECK(method_ != nullptr);
- }
-}
-
-} // namespace art
+++ /dev/null
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ART_RUNTIME_THROW_LOCATION_H_
-#define ART_RUNTIME_THROW_LOCATION_H_
-
-#include "object_callbacks.h"
-#include "base/macros.h"
-#include "base/mutex.h"
-#include "gc_root.h"
-
-#include <stdint.h>
-#include <string>
-
-namespace art {
-
-namespace mirror {
-class ArtMethod;
-class Object;
-} // mirror
-
-class PACKED(4) ThrowLocation {
- public:
- ThrowLocation() {
- Clear();
- }
-
- ThrowLocation(mirror::Object* throw_this_object, mirror::ArtMethod* throw_method,
- uint32_t throw_dex_pc) :
- this_object_(throw_this_object),
- method_(throw_method),
- dex_pc_(throw_dex_pc)
-#ifdef __LP64__
- , pad_(0)
-#endif
-
- {
-#ifdef __LP64__
- UNUSED(pad_);
-#endif
- }
-
- mirror::Object* GetThis() const {
- return this_object_;
- }
-
- mirror::ArtMethod* GetMethod() const {
- return method_;
- }
-
- uint32_t GetDexPc() const {
- return dex_pc_;
- }
-
- void Clear() {
- this_object_ = NULL;
- method_ = NULL;
- dex_pc_ = -1;
- }
-
- std::string Dump() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-
- void VisitRoots(RootCallback* visitor, void* arg);
-
- private:
- // The 'this' reference of the throwing method.
- mirror::Object* this_object_;
- // The throwing method.
- mirror::ArtMethod* method_;
- // The instruction within the throwing method.
- uint32_t dex_pc_;
- // Ensure 8byte alignment on 64bit.
-#ifdef __LP64__
- uint32_t pad_;
-#endif
-};
-
-} // namespace art
-
-#endif // ART_RUNTIME_THROW_LOCATION_H_
CHECK(IsAborted()) << "Rethrow InternalError while transaction is not aborted";
}
std::string abort_msg(GetAbortMessage());
- self->ThrowNewException(self->GetCurrentLocationForThrow(), "Ljava/lang/InternalError;",
- abort_msg.c_str());
+ self->ThrowNewException("Ljava/lang/InternalError;", abort_msg.c_str());
}
bool Transaction::IsAborted() {