ART: Add system properties support
Add simple support for GetSystemProperties, GetSystemProperty and
SetSystemProperty. Add a test.
Bug: 31455788
Test: m test-art-host-run-test-922-properties
Change-Id: I02914f04643f0f8fab96f1b372925c2c5306fc9b
diff --git a/test/ti-agent/common_helper.cc b/test/ti-agent/common_helper.cc
index 01b6c98..6f98f10 100644
--- a/test/ti-agent/common_helper.cc
+++ b/test/ti-agent/common_helper.cc
@@ -40,6 +40,26 @@
env->AddCapabilities(&caps);
}
+bool JvmtiErrorToException(JNIEnv* env, jvmtiError error) {
+ if (error == JVMTI_ERROR_NONE) {
+ return false;
+ }
+
+ ScopedLocalRef<jclass> rt_exception(env, env->FindClass("java/lang/RuntimeException"));
+ if (rt_exception.get() == nullptr) {
+ // CNFE should be pending.
+ return true;
+ }
+
+ char* err;
+ jvmti_env->GetErrorName(error, &err);
+
+ env->ThrowNew(rt_exception.get(), err);
+
+ jvmti_env->Deallocate(reinterpret_cast<unsigned char*>(err));
+ return true;
+}
+
namespace common_redefine {
static void throwRedefinitionError(jvmtiEnv* jvmti, JNIEnv* env, jclass target, jvmtiError res) {
diff --git a/test/ti-agent/common_helper.h b/test/ti-agent/common_helper.h
index 76543fe..642ca03 100644
--- a/test/ti-agent/common_helper.h
+++ b/test/ti-agent/common_helper.h
@@ -65,6 +65,8 @@
void SetAllCapabilities(jvmtiEnv* env);
+bool JvmtiErrorToException(JNIEnv* env, jvmtiError error);
+
} // namespace art
#endif // ART_TEST_TI_AGENT_COMMON_HELPER_H_
diff --git a/test/ti-agent/common_load.cc b/test/ti-agent/common_load.cc
index d7579ca..e309a89 100644
--- a/test/ti-agent/common_load.cc
+++ b/test/ti-agent/common_load.cc
@@ -39,6 +39,7 @@
#include "913-heaps/heaps.h"
#include "918-fields/fields.h"
#include "920-objects/objects.h"
+#include "922-properties/properties.h"
namespace art {
@@ -76,6 +77,7 @@
{ "919-obsolete-fields", common_redefine::OnLoad, nullptr },
{ "920-objects", Test920Objects::OnLoad, nullptr },
{ "921-hello-failure", common_redefine::OnLoad, nullptr },
+ { "922-properties", Test922Properties::OnLoad, nullptr },
};
static AgentLib* FindAgent(char* name) {