#include "gc/space/space-inl.h"
#include "handle_scope.h"
#include "jdwp/object_registry.h"
-#include "method_helper-inl.h"
#include "mirror/art_field-inl.h"
#include "mirror/art_method-inl.h"
#include "mirror/class.h"
{
StackHandleScope<3> hs(soa.Self());
- MethodHelper mh(hs.NewHandle(m));
+ HandleWrapper<mirror::ArtMethod> h_m(hs.NewHandleWrapper(&m));
HandleWrapper<mirror::Object> h_obj(hs.NewHandleWrapper(&receiver));
HandleWrapper<mirror::Class> h_klass(hs.NewHandleWrapper(&c));
const DexFile::TypeList* types = m->GetParameterTypeList();
if (shorty[i + 1] == 'L') {
// Did we really get an argument of an appropriate reference type?
- mirror::Class* parameter_type = mh.GetClassFromTypeIdx(types->GetTypeItem(i).type_idx_);
+ mirror::Class* parameter_type =
+ h_m->GetClassFromTypeIndex(types->GetTypeItem(i).type_idx_, true);
mirror::Object* argument = gRegistry->Get<mirror::Object*>(arg_values[i], &error);
if (error != JDWP::ERR_NONE) {
return JDWP::ERR_INVALID_OBJECT;
v.l = gRegistry->GetJObject(arg_values[i]);
}
}
- // Update in case it moved.
- m = mh.GetMethod();
}
req->receiver = receiver;
#include "dex_file-inl.h"
#include "entrypoints/entrypoint_utils.h"
#include "jni_internal.h"
-#include "method_helper-inl.h"
#include "mirror/art_field-inl.h"
#include "mirror/art_method-inl.h"
#include "mirror/class-inl.h"
}
bool BuildArgArrayFromObjectArray(mirror::Object* receiver,
- mirror::ObjectArray<mirror::Object>* args, MethodHelper& mh)
+ mirror::ObjectArray<mirror::Object>* args,
+ Handle<mirror::ArtMethod> h_m)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- const DexFile::TypeList* classes = mh.GetMethod()->GetParameterTypeList();
+ const DexFile::TypeList* classes = h_m->GetParameterTypeList();
// Set receiver if non-null (method is not static)
if (receiver != nullptr) {
Append(receiver);
mirror::Object* arg = args->Get(args_offset);
if (((shorty_[i] == 'L') && (arg != nullptr)) || ((arg == nullptr && shorty_[i] != 'L'))) {
mirror::Class* dst_class =
- mh.GetClassFromTypeIdx(classes->GetTypeItem(args_offset).type_idx_);
+ h_m->GetClassFromTypeIndex(classes->GetTypeItem(args_offset).type_idx_, true);
if (UNLIKELY(arg == nullptr || !arg->InstanceOf(dst_class))) {
ThrowIllegalArgumentException(nullptr,
StringPrintf("method %s argument %zd has type %s, got %s",
- PrettyMethod(mh.GetMethod(), false).c_str(),
+ PrettyMethod(h_m.Get(), false).c_str(),
args_offset + 1, // Humans don't count from 0.
PrettyDescriptor(dst_class).c_str(),
PrettyTypeOf(arg).c_str()).c_str());
} else { \
ThrowIllegalArgumentException(nullptr, \
StringPrintf("method %s argument %zd has type %s, got %s", \
- PrettyMethod(mh.GetMethod(), false).c_str(), \
+ PrettyMethod(h_m.Get(), false).c_str(), \
args_offset + 1, \
expected, \
PrettyTypeOf(arg).c_str()).c_str()); \
#ifndef NDEBUG
default:
LOG(FATAL) << "Unexpected shorty character: " << shorty_[i];
+ UNREACHABLE();
#endif
}
#undef DO_FIRST_ARG
if (!m->IsStatic()) {
offset = 1;
}
- // TODO: If args contain object references, it may cause problems
+ // TODO: If args contain object references, it may cause problems.
Thread* self = Thread::Current();
StackHandleScope<1> hs(self);
Handle<mirror::ArtMethod> h_m(hs.NewHandle(m));
- MethodHelper mh(h_m);
for (uint32_t i = 0; i < num_params; i++) {
uint16_t type_idx = params->GetTypeItem(i).type_idx_;
- mirror::Class* param_type = mh.GetClassFromTypeIdx(type_idx);
+ mirror::Class* param_type = h_m->GetClassFromTypeIndex(type_idx, true);
if (param_type == nullptr) {
CHECK(self->IsExceptionPending());
LOG(ERROR) << "Internal error: unresolvable type for argument type in JNI invoke: "
// Check that the receiver is non-null and an instance of the field's declaring class.
receiver = soa.Decode<mirror::Object*>(javaReceiver);
if (!VerifyObjectIsClass(receiver, declaring_class)) {
- return NULL;
+ return nullptr;
}
// Find the actual implementation of the virtual method.
uint32_t classes_size = (classes == nullptr) ? 0 : classes->Size();
uint32_t arg_count = (objects != nullptr) ? objects->GetLength() : 0;
if (arg_count != classes_size) {
- ThrowIllegalArgumentException(NULL,
+ ThrowIllegalArgumentException(nullptr,
StringPrintf("Wrong number of arguments; expected %d, got %d",
classes_size, arg_count).c_str());
- return NULL;
+ return nullptr;
}
// If method is not set to be accessible, verify it can be accessed by the caller.
const char* shorty = m->GetShorty(&shorty_len);
ArgArray arg_array(shorty, shorty_len);
StackHandleScope<1> hs(soa.Self());
- MethodHelper mh(hs.NewHandle(m));
- if (!arg_array.BuildArgArrayFromObjectArray(receiver, objects, mh)) {
+ Handle<mirror::ArtMethod> h_m(hs.NewHandle(m));
+ if (!arg_array.BuildArgArrayFromObjectArray(receiver, objects, h_m)) {
CHECK(soa.Self()->IsExceptionPending());
return nullptr;
}
jmethodID mid = soa.Env()->GetMethodID(exception_class, "<init>", "(Ljava/lang/Throwable;)V");
jobject exception_instance = soa.Env()->NewObject(exception_class, mid, th);
soa.Env()->Throw(reinterpret_cast<jthrowable>(exception_instance));
- return NULL;
+ return nullptr;
}
// Box if necessary and return.
- return soa.AddLocalReference<jobject>(
- BoxPrimitive(Primitive::GetType(mh.GetMethod()->GetReturnTypeDescriptor()[0]), result));
+ return soa.AddLocalReference<jobject>(BoxPrimitive(Primitive::GetType(shorty[0]), result));
}
bool VerifyObjectIsClass(mirror::Object* o, mirror::Class* c) {
- if (o == NULL) {
- ThrowNullPointerException(NULL, "null receiver");
+ if (o == nullptr) {
+ ThrowNullPointerException(nullptr, "null receiver");
return false;
} else if (!o->InstanceOf(c)) {
std::string expected_class_name(PrettyDescriptor(c));
std::string actual_class_name(PrettyTypeOf(o));
- ThrowIllegalArgumentException(NULL,
+ ThrowIllegalArgumentException(nullptr,
StringPrintf("Expected receiver of type %s, but got %s",
expected_class_name.c_str(),
actual_class_name.c_str()).c_str());