summaryrefslogtreecommitdiff
path: root/runtime/java_vm_ext.cc
diff options
context:
space:
mode:
author Richard Uhler <ruhler@google.com> 2016-10-11 15:06:38 +0100
committer Richard Uhler <ruhler@google.com> 2016-10-19 16:37:47 +0100
commitda0a69edb24122d3d35ce1483c5ab94de919d714 (patch)
tree7216e6a19b1a9f3ca9da28d61c717ad9086d994e /runtime/java_vm_ext.cc
parent278ec18934045477f0340b4aa6564f003a1e190d (diff)
Return error message if IndirectReferenceTable construction fails.
Previously if there was an error when constructing the IndirectReferenceTable, the error message was lost. Now expose and include the error message when throwing an exception related to failures to construct the IndirectReferenceTable. The error message is propagated through JVMEnvExt, JavaVMExt, and Runtime::Init as well. Bug: 32013594 Test: Added new 151-OpenFileLimit runtest. Test: m test-art-host, m test-art-target Change-Id: I3692f6928c9570358571bce634569d6f14cdeb05
Diffstat (limited to 'runtime/java_vm_ext.cc')
-rw-r--r--runtime/java_vm_ext.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index 99edb7c569..eec1903dd2 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -411,7 +411,9 @@ const JNIInvokeInterface gJniInvokeInterface = {
JII::AttachCurrentThreadAsDaemon
};
-JavaVMExt::JavaVMExt(Runtime* runtime, const RuntimeArgumentMap& runtime_options)
+JavaVMExt::JavaVMExt(Runtime* runtime,
+ const RuntimeArgumentMap& runtime_options,
+ std::string* error_msg)
: runtime_(runtime),
check_jni_abort_hook_(nullptr),
check_jni_abort_hook_data_(nullptr),
@@ -420,10 +422,10 @@ JavaVMExt::JavaVMExt(Runtime* runtime, const RuntimeArgumentMap& runtime_options
tracing_enabled_(runtime_options.Exists(RuntimeArgumentMap::JniTrace)
|| VLOG_IS_ON(third_party_jni)),
trace_(runtime_options.GetOrDefault(RuntimeArgumentMap::JniTrace)),
- globals_(kGlobalsMax, kGlobal),
+ globals_(kGlobalsMax, kGlobal, error_msg),
libraries_(new Libraries),
unchecked_functions_(&gJniInvokeInterface),
- weak_globals_(kWeakGlobalsMax, kWeakGlobal),
+ weak_globals_(kWeakGlobalsMax, kWeakGlobal, error_msg),
allow_accessing_weak_globals_(true),
weak_globals_add_condition_("weak globals add condition",
(CHECK(Locks::jni_weak_globals_lock_ != nullptr),
@@ -436,6 +438,19 @@ JavaVMExt::JavaVMExt(Runtime* runtime, const RuntimeArgumentMap& runtime_options
JavaVMExt::~JavaVMExt() {
}
+// Checking "globals" and "weak_globals" usually requires locks, but we
+// don't need the locks to check for validity when constructing the
+// object. Use NO_THREAD_SAFETY_ANALYSIS for this.
+std::unique_ptr<JavaVMExt> JavaVMExt::Create(Runtime* runtime,
+ const RuntimeArgumentMap& runtime_options,
+ std::string* error_msg) NO_THREAD_SAFETY_ANALYSIS {
+ std::unique_ptr<JavaVMExt> java_vm(new JavaVMExt(runtime, runtime_options, error_msg));
+ if (java_vm && java_vm->globals_.IsValid() && java_vm->weak_globals_.IsValid()) {
+ return java_vm;
+ }
+ return nullptr;
+}
+
jint JavaVMExt::HandleGetEnv(/*out*/void** env, jint version) {
for (GetEnvHook hook : env_hooks_) {
jint res = hook(this, env, version);