1 7 8 package java.lang.management; 9 10 import javax.management.openmbean.CompositeData ; 11 import sun.management.MonitorInfoCompositeData; 12 13 26 public class MonitorInfo extends LockInfo { 27 28 private int stackDepth; 29 private StackTraceElement stackFrame; 30 31 45 public MonitorInfo(String className, 46 int identityHashCode, 47 int stackDepth, 48 StackTraceElement stackFrame) { 49 super(className, identityHashCode); 50 if (stackDepth >= 0 && stackFrame == null) { 51 throw new IllegalArgumentException ("Parameter stackDepth is " + 52 stackDepth + " but stackFrame is null"); 53 } 54 if (stackDepth < 0 && stackFrame != null) { 55 throw new IllegalArgumentException ("Parameter stackDepth is " + 56 stackDepth + " but stackFrame is not null"); 57 } 58 this.stackDepth = stackDepth; 59 this.stackFrame = stackFrame; 60 } 61 62 70 public int getLockedStackDepth() { 71 return stackDepth; 72 } 73 74 80 public StackTraceElement getLockedStackFrame() { 81 return stackFrame; 82 } 83 84 122 public static MonitorInfo from(CompositeData cd) { 123 if (cd == null) { 124 return null; 125 } 126 127 if (cd instanceof MonitorInfoCompositeData) { 128 return ((MonitorInfoCompositeData) cd).getMonitorInfo(); 129 } else { 130 MonitorInfoCompositeData.validateCompositeData(cd); 131 String className = MonitorInfoCompositeData.getClassName(cd); 132 int identityHashCode = MonitorInfoCompositeData.getIdentityHashCode(cd); 133 int stackDepth = MonitorInfoCompositeData.getLockedStackDepth(cd); 134 StackTraceElement stackFrame = MonitorInfoCompositeData.getLockedStackFrame(cd); 135 return new MonitorInfo (className, 136 identityHashCode, 137 stackDepth, 138 stackFrame); 139 } 140 } 141 142 } 143 | Popular Tags |