diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-12-03 18:10:39 +0000 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-12-03 18:10:39 +0000 |
commit | 005f6978d34a3d431193d72fe1cfdd5d0911e8ec (patch) | |
tree | 8fc84261ed7ad96a35c6035ac7535757a316391e /test/004-JniTest | |
parent | add2f944284992106cd9a1f1df93a17d666eaaf6 (diff) | |
download | art-005f6978d34a3d431193d72fe1cfdd5d0911e8ec.tar.gz art-005f6978d34a3d431193d72fe1cfdd5d0911e8ec.tar.bz2 art-005f6978d34a3d431193d72fe1cfdd5d0911e8ec.zip |
Don't re-use arttest when calling loadLibrary.
When Android's build environment variables are set with envsetup.sh,
the test "works" ok, by getting a LinkageError because two class loaders
try to load the same library. I guess that is the reason for the
if (ExceptionCheck()) after the loading.
However, if the environment variables are set manually, there are
cases where the paths provided between a Java loadLibrary, and a
native loadLibrary are different, so we end up loading the library twice.
This makes the assertion line 32 fail on the second JNI_OnLoad call.
In my particular environment, ANDROID_BUILD_TOP was something lie
/foo/bar/..//.
This change stops re-using the same library, and makes the expected
outcome constant: the native call of loadLibrary with a non exist
library must throw a LinkageError.
Change-Id: I8721a03715e099c55fb8b2b87813f1e772c8e83d
Diffstat (limited to 'test/004-JniTest')
-rw-r--r-- | test/004-JniTest/jni_test.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/test/004-JniTest/jni_test.cc b/test/004-JniTest/jni_test.cc index c2877be02e..544cbc503e 100644 --- a/test/004-JniTest/jni_test.cc +++ b/test/004-JniTest/jni_test.cc @@ -294,20 +294,20 @@ static void testShallowGetCallingClassLoader(JNIEnv* env) { assert(!env->ExceptionCheck()); // Create a string object. - jobject library_string = env->NewStringUTF("arttest"); + jobject library_string = env->NewStringUTF("non_existing_library"); assert(library_string != nullptr); assert(!env->ExceptionCheck()); env->CallStaticVoidMethod(system_clazz, loadLibraryMethodId, library_string); - if (env->ExceptionCheck()) { - // At most we expect UnsatisfiedLinkError. - jthrowable thrown = env->ExceptionOccurred(); - env->ExceptionClear(); - - jclass unsatisfied_link_error_clazz = env->FindClass("java/lang/UnsatisfiedLinkError"); - jclass thrown_class = env->GetObjectClass(thrown); - assert(env->IsSameObject(unsatisfied_link_error_clazz, thrown_class)); - } + assert(env->ExceptionCheck()); + + // We expect UnsatisfiedLinkError. + jthrowable thrown = env->ExceptionOccurred(); + env->ExceptionClear(); + + jclass unsatisfied_link_error_clazz = env->FindClass("java/lang/UnsatisfiedLinkError"); + jclass thrown_class = env->GetObjectClass(thrown); + assert(env->IsSameObject(unsatisfied_link_error_clazz, thrown_class)); } } |