Class MonitorInfo

java.lang.Object
java.lang.management.LockInfo
java.lang.management.MonitorInfo

public class MonitorInfo extends LockInfo
This class represents information about objects locked via a synchronized method or block.
Since:
1.6
  • Constructor Summary

    Constructors
    Constructor
    Description
    MonitorInfo(String className, int identityHashCode, int stackDepth, StackTraceElement stackFrame)
    Creates a new MonitorInfo instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    Receives a CompositeData representing a MonitorInfo object and attempts to return the root MonitorInfo instance.
    int
    Returns an integer which is the number of frames deep into the stack where the monitor locking took place.
    The complete StackTraceElement in which the monitor was locked.

    Methods declared in class LockInfo

    getClassName, getIdentityHashCode, toString
    Modifier and Type
    Method
    Description
    Returns the name of the lock object's class in fully qualified form (i.e. including the package prefix).
    int
    Returns the value of the associated lock object's identity hash code
    Provides callers with a string value that represents the associated lock.

    Methods declared in class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
    Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.
    boolean
    Compares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    May cause performance issues, deadlocks and hangs.
    final Class<? extends Object>
    Answers the unique instance of java.lang.Class which represents the class of the receiver.
    int
    Answers an integer hash code for the receiver.
    final void
    Causes one thread which is waiting on the receiver to be made ready to run.
    final void
    Causes all threads which are waiting on the receiver to be made ready to run.
    final void
    Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated by notify or notifyAll).
    final void
    wait(long time)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
    final void
    wait(long time, int frac)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
  • Constructor Details

    • MonitorInfo

      public MonitorInfo(String className, int identityHashCode, int stackDepth, StackTraceElement stackFrame)
      Creates a new MonitorInfo instance.
      Parameters:
      className - the name (including the package prefix) of the associated monitor lock object's class
      identityHashCode - the value of the associated monitor lock object's identity hash code. This amounts to the result of calling System.identityHashCode(Object) with the monitor lock object as the sole argument.
      stackDepth - the number of frames deep in the stack where the locking of the monitor took place
      stackFrame - the complete stack frame at which the locking of the monitor occurred
      Throws:
      IllegalArgumentException - if either of the following two conditions apply:
      • the supplied stackFrame is non-null yet the value of stackDepth is less than zero
      • the supplied stackFrame is null yet the value of stackDepth is zero or greater
  • Method Details

    • getLockedStackDepth

      public int getLockedStackDepth()
      Returns an integer which is the number of frames deep into the stack where the monitor locking took place.
      Returns:
      the number of frames into the stack trace at which point the monitor object locking too place
    • getLockedStackFrame

      public StackTraceElement getLockedStackFrame()
      The complete StackTraceElement in which the monitor was locked.
      Returns:
      the StackTraceElement in which the associated monitor was locked
    • from

      public static MonitorInfo from(CompositeData cd)
      Receives a CompositeData representing a MonitorInfo object and attempts to return the root MonitorInfo instance.
      Parameters:
      cd - a CompositeData that represents a MonitorInfo.
      Returns:
      if cd is non- null, returns a new instance of MonitorInfo. If cd is null, returns null.
      Throws:
      IllegalArgumentException - if argument cd does not correspond to a MonitorInfo with the expected attributes of a LockInfo - className(java.lang.String) and identityHashCode(java.lang.Integer) -  plus the following:
      • lockedStackFrame(javax.management.openmbean.CompositeData)
      • lockedStackDepth( java.lang.Integer)
      The lockedStackFrame attribute must correspond to a java.lang.StackTraceElement which has the following attributes:
      • moduleName(java.lang.String)
      • moduleVersion(java.lang.String)
      • className (java.lang.String)
      • methodName (java.lang.String)
      • fileName (java.lang.String)
      • lineNumber (java.lang.Integer)
      • nativeMethod (java.lang.Boolean)