From 1d99e4549309d05007d041d058b1878de88e9585 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 2 Jan 2014 17:36:41 -0800 Subject: Disallow JNI NewObjectArray of primitive types. Also, make jni_internal_test execute via the interpreter rather than compile methods. Add tests for passing negative array sizes to JNI routines new functions. Re-enable the tests NewStringNullCharsNonzeroLength and NewDirectBuffer_GetDirectBufferAddress_GetDirectBufferCapacity. Test and explicitly fail if the initial value argument to NewObjectArray isn't assignable to that type of array. Use unchecked ObjectArray::Set with NewObjectArray with an initial value. Change-Id: If3491cb5f974b42cf70c1b850819265f9963ee48 --- runtime/common_test.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'runtime/common_test.h') diff --git a/runtime/common_test.h b/runtime/common_test.h index a3cbde3740..ee95d5bbbd 100644 --- a/runtime/common_test.h +++ b/runtime/common_test.h @@ -296,7 +296,6 @@ class CommonTest : public testing::Test { void MakeExecutable(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(method != NULL); - LOG(INFO) << "MakeExecutable " << PrettyMethod(method); const CompiledMethod* compiled_method = NULL; if (!method->IsAbstract()) { @@ -325,7 +324,6 @@ class CommonTest : public testing::Test { const void* method_code; // No code? You must mean to go into the interpreter. method_code = GetCompiledCodeToInterpreterBridge(); - LOG(INFO) << "MakeExecutable " << PrettyMethod(method) << " code=" << method_code; OatFile::OatMethod oat_method = CreateOatMethod(method_code, kStackAlignment, 0, @@ -382,6 +380,20 @@ class CommonTest : public testing::Test { setenv("ANDROID_DATA", android_data.c_str(), 1); } + void MakeExecutable(mirror::ClassLoader* class_loader, const char* class_name) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + std::string class_descriptor(DotToDescriptor(class_name)); + SirtRef loader(Thread::Current(), class_loader); + mirror::Class* klass = class_linker_->FindClass(class_descriptor.c_str(), loader); + CHECK(klass != NULL) << "Class not found " << class_name; + for (size_t i = 0; i < klass->NumDirectMethods(); i++) { + MakeExecutable(klass->GetDirectMethod(i)); + } + for (size_t i = 0; i < klass->NumVirtualMethods(); i++) { + MakeExecutable(klass->GetVirtualMethod(i)); + } + } + protected: static bool IsHost() { return (getenv("ANDROID_BUILD_TOP") != NULL); -- cgit v1.2.3-59-g8ed1b