java/9254: java::lang::Object::wait(), threads-win32.cc returns wrong return codes

erik.poupaert@chello.be erik.poupaert@chello.be
Thu Jan 9 19:56:00 GMT 2003


>Number:         9254
>Category:       java
>Synopsis:       java::lang::Object::wait(), threads-win32.cc returns wrong return codes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 09 11:56:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     erik.poupaert@chello.be
>Release:        unknown-1.0
>Organization:
>Environment:

>Description:
While posix-threads.cc/_JvCondWait() will return (_JV_NOT_OWNER,_JV_INTERRUPTED, 0), which are exactly the return codes that java::lang::Object::wait() checks on,
win32-threads.cc/_JvCondWait(), will return (GetLastError(),ETIMEOUT, 0).

It may be the reason why java.lang.Object.wait() doesn't work properly on win32. In the test case attached, at line 20, mWorkerLock.wait(), will only wait one time. From there on, it won't wait any longer, when invoked.
>How-To-Repeat:
See example.
>Fix:
The return codes for win32 must be mapped:
(GetLastError(),ETIMEOUT, 0)
to the tuple: 
(_JV_NOT_OWNER,_JV_INTERRUPTED, 0)
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: java/*; name="TestThreading.java"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="TestThreading.java"

DQppbXBvcnQgamF2YS5pby5JbnB1dFN0cmVhbVJlYWRlcjsNCmltcG9ydCBqYXZhLmlvLkJ1ZmZl
cmVkUmVhZGVyOw0KaW1wb3J0IGphdmEuaW8uSU9FeGNlcHRpb247DQoNCnB1YmxpYyBjbGFzcyBU
ZXN0VGhyZWFkaW5nDQp7DQoJcHJpdmF0ZSAgZmluYWwgT2JqZWN0IG1Xb3JrZXJMb2NrID0gbmV3
IE9iamVjdCgpOw0KCXByaXZhdGUgdm9sYXRpbGUgVGhyZWFkICBtV29ya2VyVGhyZWFkID0gbnVs
bDsNCglwcm90ZWN0ZWQgYm9vbGVhbiBtV29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