Revert "Avoid JNI usage error when JNI_OnLoad throws"
This reverts commit d111f90a386f7bad1474189390fce7a8d1ff1ab5.
Change-Id: Ia8461946088644e41e0f2e14d7e806a70dec41ab
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index f2e3353..b93b8f2 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -905,20 +905,8 @@
EnsureFrontOfChain(SIGSEGV);
}
- // Temporarily reset any pending exception around the call to
- // SetClassLoaderOverride: SetClassLoaderOverride creates a new
- // global reference, which is illegal while we have an
- // exception pending.
- jthrowable on_load_exception = env->ExceptionOccurred();
- env->ExceptionClear();
-
- // Restore the current class loader (which was overridden above) to the previous state.
self->SetClassLoaderOverride(old_class_loader.get());
- if (on_load_exception != nullptr) {
- env->Throw(on_load_exception);
- }
-
if (version == JNI_ERR) {
StringAppendF(error_msg, "JNI_ERR returned from JNI_OnLoad in \"%s\"", path.c_str());
} else if (JavaVMExt::IsBadJniVersion(version)) {
diff --git a/test/004-JniTest/jni_test.cc b/test/004-JniTest/jni_test.cc
index 20458e9..81be531 100644
--- a/test/004-JniTest/jni_test.cc
+++ b/test/004-JniTest/jni_test.cc
@@ -41,18 +41,6 @@
jvm = vm;
std::cout << "JNI_OnLoad called" << std::endl;
- // Test 985 sets this environment variable in its run script to test
- // for JNI_OnLoad failure. (We don't want to fail in the normal
- // case, and a separate test library is overkill.)
- if (getenv("ART_TEST_985_JNI_ONLOAD_THROW_THROW_IN_JNI_ONLOAD") != nullptr) {
- JNIEnv* env;
- jint res = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
- CHECK_EQ(res , JNI_OK);
- res = env->ThrowNew(env->FindClass("java/lang/IllegalStateException"),
- "message");
- CHECK_EQ(res, JNI_OK);
- }
-
return JNI_VERSION_1_6;
}
diff --git a/test/985-jni-onload-throw/expected.txt b/test/985-jni-onload-throw/expected.txt
deleted file mode 100644
index 6a5618e..0000000
--- a/test/985-jni-onload-throw/expected.txt
+++ /dev/null
@@ -1 +0,0 @@
-JNI_OnLoad called
diff --git a/test/985-jni-onload-throw/info.txt b/test/985-jni-onload-throw/info.txt
deleted file mode 100644
index d0174dd..0000000
--- a/test/985-jni-onload-throw/info.txt
+++ /dev/null
@@ -1 +0,0 @@
-Test that returning from JNI_OnLoad with exception pending works.
diff --git a/test/985-jni-onload-throw/run b/test/985-jni-onload-throw/run
deleted file mode 100644
index ebd61f9..0000000
--- a/test/985-jni-onload-throw/run
+++ /dev/null
@@ -1,3 +0,0 @@
-# The environment variable set below makes JNI_OnLoad
-# throw so that the test can try to catch the exception.
-ART_TEST_985_JNI_ONLOAD_THROW_THROW_IN_JNI_ONLOAD=1 exec ${RUN} "${@}"
diff --git a/test/985-jni-onload-throw/src/Main.java b/test/985-jni-onload-throw/src/Main.java
deleted file mode 100644
index ade6dcd..0000000
--- a/test/985-jni-onload-throw/src/Main.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class Main {
- public static void main(String[] args) {
- try {
- System.loadLibrary(args[0]);
- throw new AssertionError("loadLibrary did not throw");
- } catch (IllegalStateException ex) {
- if (!"message".equals(ex.getMessage())) {
- throw new AssertionError("exception thrown incorrectly");
- }
- }
- }
-}