summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Light <allight@google.com> 2017-08-16 15:16:13 -0700
committer Alex Light <allight@google.com> 2017-08-16 17:08:41 -0700
commit6ced091878e139764be6d954f5b35ce46d9ce1c0 (patch)
treee0a7022e5c830f831fdf07e09b8b59fc6b26bea6
parent675c779cb046bca49229e1e5268d0eb622159214 (diff)
Fix issue with RawMonitorWait.
Real world agents seem to expect that RawMonitorWait allows negative timeouts. We implement this by simply making negative timeouts be interpreted as having no timeout. Test: ./test.py --host -j50 Change-Id: I40fdb192b0a028065a9d8b6b51a8c87815903139
-rw-r--r--openjdkjvmti/ti_monitor.cc8
-rw-r--r--test/923-monitors/expected.txt2
2 files changed, 3 insertions, 7 deletions
diff --git a/openjdkjvmti/ti_monitor.cc b/openjdkjvmti/ti_monitor.cc
index 61bf533eb7..1ec566b33d 100644
--- a/openjdkjvmti/ti_monitor.cc
+++ b/openjdkjvmti/ti_monitor.cc
@@ -247,12 +247,8 @@ jvmtiError MonitorUtil::RawMonitorWait(jvmtiEnv* env ATTRIBUTE_UNUSED,
JvmtiMonitor* monitor = DecodeMonitor(id);
art::Thread* self = art::Thread::Current();
- // This is not in the spec, but it's the only thing that makes sense (and agrees with
- // Object.wait).
- if (millis < 0) {
- return ERR(ILLEGAL_ARGUMENT);
- }
-
+ // What millis < 0 means is not defined in the spec. Real world agents seem to assume that it is a
+ // valid call though. We treat it as though it was 0 and wait indefinitely.
bool result = (millis > 0)
? monitor->Wait(self, static_cast<uint64_t>(millis))
: monitor->Wait(self);
diff --git a/test/923-monitors/expected.txt b/test/923-monitors/expected.txt
index 5fbfb9866e..81a4fd094f 100644
--- a/test/923-monitors/expected.txt
+++ b/test/923-monitors/expected.txt
@@ -13,7 +13,7 @@ JVMTI_ERROR_NOT_MONITOR_OWNER
Wait
JVMTI_ERROR_NOT_MONITOR_OWNER
Wait
-JVMTI_ERROR_ILLEGAL_ARGUMENT
+JVMTI_ERROR_NOT_MONITOR_OWNER
Wait
JVMTI_ERROR_NOT_MONITOR_OWNER
Lock