From da0a69edb24122d3d35ce1483c5ab94de919d714 Mon Sep 17 00:00:00 2001 From: Richard Uhler Date: Tue, 11 Oct 2016 15:06:38 +0100 Subject: 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 --- runtime/java_vm_ext.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'runtime/java_vm_ext.h') diff --git a/runtime/java_vm_ext.h b/runtime/java_vm_ext.h index 05717f41e7..9e37f1178c 100644 --- a/runtime/java_vm_ext.h +++ b/runtime/java_vm_ext.h @@ -43,7 +43,14 @@ using GetEnvHook = jint (*)(JavaVMExt* vm, /*out*/void** new_env, jint version); class JavaVMExt : public JavaVM { public: - JavaVMExt(Runtime* runtime, const RuntimeArgumentMap& runtime_options); + // Creates a new JavaVMExt object. + // Returns nullptr on error, in which case error_msg is set to a message + // describing the error. + static std::unique_ptr Create(Runtime* runtime, + const RuntimeArgumentMap& runtime_options, + std::string* error_msg); + + ~JavaVMExt(); bool ForceCopy() const { @@ -192,6 +199,10 @@ class JavaVMExt : public JavaVM { static bool IsBadJniVersion(int version); private: + // The constructor should not be called directly. It may leave the object in + // an erroneous state, and the result needs to be checked. + JavaVMExt(Runtime* runtime, const RuntimeArgumentMap& runtime_options, std::string* error_msg); + // Return true if self can currently access weak globals. bool MayAccessWeakGlobalsUnlocked(Thread* self) const REQUIRES_SHARED(Locks::mutator_lock_); bool MayAccessWeakGlobals(Thread* self) const -- cgit v1.2.3-59-g8ed1b