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
diff --git a/runtime/common_test.h b/runtime/common_test.h
index a3cbde3..ee95d5b 100644
--- a/runtime/common_test.h
+++ b/runtime/common_test.h
@@ -296,7 +296,6 @@
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 @@
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 @@
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<mirror::ClassLoader> 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);