summaryrefslogtreecommitdiffstats
path: root/compiler/jni
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-07-17 11:09:10 -0700
committerIan Rogers <irogers@google.com>2014-08-08 08:29:53 -0700
commit68d8b42ddec39ec0174162d90d4abaa004d1983e (patch)
tree0bb6ccf3b996bb8363c10d07aa39cde221980602 /compiler/jni
parent9c522c2cbbf50dc687728747b37ad59985750b65 (diff)
downloadandroid_art-68d8b42ddec39ec0174162d90d4abaa004d1983e.tar.gz
android_art-68d8b42ddec39ec0174162d90d4abaa004d1983e.tar.bz2
android_art-68d8b42ddec39ec0174162d90d4abaa004d1983e.zip
Wire up check JNI force copy mode.
Increase check JNI checks. Break apart jni_internal.h in to jni_env_ext.h and java_vm_ext.h. Fix the abuse of ScopedObjectAccess/annotalysis by ScopedCheck in the case of VM routines. Make class loader override and shared library class loader JNI global references rather than mirror pointers. Clean-ups to native bridge. Change-Id: If7c6110b5aade7a402bfb67534af86a7b2cdeb55
Diffstat (limited to 'compiler/jni')
-rw-r--r--compiler/jni/jni_compiler_test.cc28
-rw-r--r--compiler/jni/quick/jni_compiler.cc2
2 files changed, 11 insertions, 19 deletions
diff --git a/compiler/jni/jni_compiler_test.cc b/compiler/jni/jni_compiler_test.cc
index 995ea46993..75d3030baf 100644
--- a/compiler/jni/jni_compiler_test.cc
+++ b/compiler/jni/jni_compiler_test.cc
@@ -155,13 +155,9 @@ TEST_F(JniCompilerTest, CompileAndRunIntMethodThroughStub) {
SetUpForTest(false, "bar", "(I)I", nullptr);
// calling through stub will link with &Java_MyClassNatives_bar
- ScopedObjectAccess soa(Thread::Current());
std::string reason;
- StackHandleScope<1> hs(soa.Self());
- Handle<mirror::ClassLoader> class_loader(
- hs.NewHandle(soa.Decode<mirror::ClassLoader*>(class_loader_)));
- ASSERT_TRUE(
- Runtime::Current()->GetJavaVM()->LoadNativeLibrary("", class_loader, &reason)) << reason;
+ ASSERT_TRUE(Runtime::Current()->GetJavaVM()->LoadNativeLibrary(env_, "", class_loader_, &reason))
+ << reason;
jint result = env_->CallNonvirtualIntMethod(jobj_, jklass_, jmethod_, 24);
EXPECT_EQ(25, result);
@@ -172,13 +168,9 @@ TEST_F(JniCompilerTest, CompileAndRunStaticIntMethodThroughStub) {
SetUpForTest(true, "sbar", "(I)I", nullptr);
// calling through stub will link with &Java_MyClassNatives_sbar
- ScopedObjectAccess soa(Thread::Current());
std::string reason;
- StackHandleScope<1> hs(soa.Self());
- Handle<mirror::ClassLoader> class_loader(
- hs.NewHandle(soa.Decode<mirror::ClassLoader*>(class_loader_)));
- ASSERT_TRUE(
- Runtime::Current()->GetJavaVM()->LoadNativeLibrary("", class_loader, &reason)) << reason;
+ ASSERT_TRUE(Runtime::Current()->GetJavaVM()->LoadNativeLibrary(env_, "", class_loader_, &reason))
+ << reason;
jint result = env_->CallStaticIntMethod(jklass_, jmethod_, 42);
EXPECT_EQ(43, result);
@@ -771,10 +763,10 @@ TEST_F(JniCompilerTest, UpcallReturnTypeChecking_Instance) {
check_jni_abort_catcher.Check("attempt to return an instance of java.lang.String from java.lang.Class MyClassNatives.instanceMethodThatShouldReturnClass()");
// Here, we just call the method incorrectly; we should catch that too.
- env_->CallVoidMethod(jobj_, jmethod_);
+ env_->CallObjectMethod(jobj_, jmethod_);
check_jni_abort_catcher.Check("attempt to return an instance of java.lang.String from java.lang.Class MyClassNatives.instanceMethodThatShouldReturnClass()");
- env_->CallStaticVoidMethod(jklass_, jmethod_);
- check_jni_abort_catcher.Check("calling non-static method java.lang.Class MyClassNatives.instanceMethodThatShouldReturnClass() with CallStaticVoidMethodV");
+ env_->CallStaticObjectMethod(jklass_, jmethod_);
+ check_jni_abort_catcher.Check("calling non-static method java.lang.Class MyClassNatives.instanceMethodThatShouldReturnClass() with CallStaticObjectMethodV");
}
TEST_F(JniCompilerTest, UpcallReturnTypeChecking_Static) {
@@ -789,10 +781,10 @@ TEST_F(JniCompilerTest, UpcallReturnTypeChecking_Static) {
check_jni_abort_catcher.Check("attempt to return an instance of java.lang.String from java.lang.Class MyClassNatives.staticMethodThatShouldReturnClass()");
// Here, we just call the method incorrectly; we should catch that too.
- env_->CallStaticVoidMethod(jklass_, jmethod_);
+ env_->CallStaticObjectMethod(jklass_, jmethod_);
check_jni_abort_catcher.Check("attempt to return an instance of java.lang.String from java.lang.Class MyClassNatives.staticMethodThatShouldReturnClass()");
- env_->CallVoidMethod(jobj_, jmethod_);
- check_jni_abort_catcher.Check("calling static method java.lang.Class MyClassNatives.staticMethodThatShouldReturnClass() with CallVoidMethodV");
+ env_->CallObjectMethod(jobj_, jmethod_);
+ check_jni_abort_catcher.Check("calling static method java.lang.Class MyClassNatives.staticMethodThatShouldReturnClass() with CallObjectMethodV");
}
// This should take jclass, but we're imitating a bug pattern.
diff --git a/compiler/jni/quick/jni_compiler.cc b/compiler/jni/quick/jni_compiler.cc
index 1a35da071c..8e870210b9 100644
--- a/compiler/jni/quick/jni_compiler.cc
+++ b/compiler/jni/quick/jni_compiler.cc
@@ -27,7 +27,7 @@
#include "dex_file-inl.h"
#include "driver/compiler_driver.h"
#include "entrypoints/quick/quick_entrypoints.h"
-#include "jni_internal.h"
+#include "jni_env_ext.h"
#include "mirror/art_method.h"
#include "utils/assembler.h"
#include "utils/managed_register.h"