Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4546581
Votes 2
Synopsis GetCurrentContendedMonitor, GetOwnedMonitorInfo, GetMonitorInfo not implemented
Category hotspot:jvmdi
Reported Against 1.3 , 1.3.1 , kestrel , merlin-rc1 , merlin-beta , merlin-beta2
Release Fixed 1.4.2(mantis)
State 10-Fix Delivered, Verified, bug
Priority: 4-Low
Related Bugs 4327280 , 4762695 , 4762902 , 4763264 , 4769391 , 4769558 , 4769563
Submit Date 04-DEC-2001
Description
.




The following three JVMDI methods are not implemented:

GetCurrentContendedMonitor
GetOwnedMonitorInfo
GetMonitorInfo

This bug affects the following tests from testbase_nsk:

nsk/jvmdi/GetCurrentContendedMonitor/contmon001
nsk/jvmdi/GetCurrentContendedMonitor/contmon002
nsk/jvmdi/GetOwnedMonitorInfo/ownmoninf001
nsk/jvmdi/GetOwnedMonitorInfo/ownmoninf002

======================================================================

 xxxxx@xxxxx  2002-10-25

When I implemented the feature, I found the following additional
tests by grepping for each interface name:

nsk/jdi/VirtualMachine/canGetCurrentContendedMonitor/cangccm001
nsk/jdi/VirtualMachine/canGetMonitorInfo/cangetmonitorinfo001
nsk/jdi/VirtualMachine/canGetOwnedMonitorInfo/cangetinfo001
nsk/jvmdi/GetCurrentContendedMonitor/contmon003
nsk/jvmdi/GetMonitorInfo/getmoninfo001
nsk/jvmdi/GetMonitorInfo/getmoninfo002
nsk/jvmdi/GetMonitorInfo/getmoninfo003
nsk/jvmdi/GetMonitorInfo/getmoninfo004
nsk/jvmdi/GetMonitorInfo/getmoninfo005
nsk/jvmdi/GetOwnedMonitorInfo/ownmoninf003

During my pre-integration NSK run for my 2002.10.24 batch, the following
tests failed:

nsk/jdi/ThreadReference/ownedMonitors/ownedmonitors001
nsk/jdi/ThreadReference/ownedMonitors/ownedmonitors002
nsk/jdwp/ObjectReference/MonitorInfo/monitorinfo001
nsk/jdwp/ThreadReference/CurrentContendedMonitor/curcontmonitor001
nsk/jdwp/ThreadReference/OwnedMonitors/ownmonitors001
Work Around
N/A
Evaluation
 xxxxx@xxxxx  2002-10-11

The JVM/DI GetMonitorInfo() API returns a pointer to the following struct:

typedef struct {
    jthread owner;
    jint entry_count;
    jint waiter_count;
    jthread *waiters;
} JVMDI_monitor_info;

The owner field is pretty obvious, but the  xxxxx  fields are not. The
entry_count field could be the number of times the monitor is entered
by the owning thread (recursion count) or it could be the number of
threads waiting to enter (contention count). The waiter_count field
specified the number of jthread pointers in the waiters array. However,
is the waiters array the threads waiting to enter the monitor, the
threads doing an Object.wait() or both?

The resolve this mystery, I'm using the JDI spec for ObjectReference:

public int entryCount() 
    Returns the number times this object's monitor has been entered by
    the current owning thread.

public List waitingThreads()
    Returns a List containing a ThreadReference for each thread currently
    waiting for this object's monitor. See
    ThreadReference.currentContendedMonitor() for information about when
    a thread is considered to be waiting for a monitor.

ThreadReference.currentContendedMonitor() says:
    The thread can be waiting for a monitor through entry into a
    synchronized method, the synchronized statement, or Object.wait(long).

I'm planning to implement the GetMonitorInfo() API to meet the expectations
of JDI's use of the interface.

 xxxxx@xxxxx  2002-10-14

GetCurrentContendedMonitor() returns a jobject for two conditions:

- the specified thread is waiting to enter
- the specified thread is waiting to regain through java.lang.Object.wait

The first condition is clear. The second needs clarification. An
Object.wait() call has two parts: the wait for notification (or
timeout) part and the reenter part. I believe the phrase "waiting to
regain" is intended to apply to the reenter part. However, the JDI
spec needs to be checked to see what is expected by the higher layers.

ThreadReference.currentContendedMonitor() says:

    Returns an ObjectReference for the monitor, if any, for which this
    thread is currently waiting. The thread can be waiting for a monitor
    through entry into a synchronized method, the synchronized statement,
    or Object.wait(long). The status() method can be used to differentiate
    between the first two cases and the third.

ThreadReference.status() says:

    Returns the thread's status. If the thread is not suspended the thread's
    current status is returned. If the thread is suspended, the thread's
    status before the suspension is returned (or THREAD_STATUS_UNKNOWN if
    this information is not available. isSuspended() can be used to determine
    if the thread has been suspended.

ThreadReference.THREAD_STATUS_WAIT says:
    Thread is waiting - Thread.wait() or JVM_MonitorWait() was called

Looks like the JDI layer is expecting that a call into Object.wait() will
result in the thread showing a contended monitor.
Comments
  
  Include a link with my name & email   

Submitted On 15-OCT-2002
jph
Your interpretation looks right to me.  In my debugger, I
first call ThreadReference.currentContendedMonitor().  If it
returns a non-null result, I use ThreadReference.status() to
distinguish between the thread being blocking acquiring the
monitor (status == THREAD_STATUS_MONITOR) or block waiting
for a notify (status == THREAD_STATUS_WAIT).  This works
with the classic JVM.



PLEASE NOTE: JDK6 is formerly known as Project Mustang