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
diff --git a/runtime/indirect_reference_table.h b/runtime/indirect_reference_table.h
index 1762b10..363280a 100644
--- a/runtime/indirect_reference_table.h
+++ b/runtime/indirect_reference_table.h
@@ -257,12 +257,24 @@
class IndirectReferenceTable {
public:
- // WARNING: When using with abort_on_error = false, the object may be in a partially
- // initialized state. Use IsValid() to check.
- IndirectReferenceTable(size_t max_count, IndirectRefKind kind, bool abort_on_error = true);
+ /*
+ * WARNING: Construction of the IndirectReferenceTable may fail.
+ * error_msg must not be null. If error_msg is set by the constructor, then
+ * construction has failed and the IndirectReferenceTable will be in an
+ * invalid state. Use IsValid to check whether the object is in an invalid
+ * state.
+ */
+ IndirectReferenceTable(size_t max_count, IndirectRefKind kind, std::string* error_msg);
~IndirectReferenceTable();
+ /*
+ * Checks whether construction of the IndirectReferenceTable succeeded.
+ *
+ * This object must only be used if IsValid() returns true. It is safe to
+ * call IsValid from multiple threads without locking or other explicit
+ * synchronization.
+ */
bool IsValid() const;
/*