< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/ThreadMonitoringScenarioBase.java

Print this page

 77         }
 78 
 79         /**
 80          * Verifies that given stack trace element from stack trace is expected
 81          * in pre-defined state. This method will be called by checkStackTrace
 82          * for each element.
 83          *
 84          * @param element stack trace element
 85          * @return true if element is expected, false otherwise
 86          */
 87         protected boolean isStackTraceElementExpected(StackTraceElement element) {
 88                 return false;
 89         }
 90 
 91         /**
 92          * Check that stack trace element is expected.
 93          */
 94         protected boolean checkStackTraceElement(StackTraceElement element, String[] expectedMethods) {
 95                 String name = element.getClassName() + "." + element.getMethodName();
 96                 for (String method : expectedMethods)
 97                         if (method.equals(name))
 98                                 return true;
 99                 return false;
100         }
101 
102         /**
103          * Check that lock info matches given lock object.
104          *
105          * @param lockInfo lock info
106          * @param lock lock object
107          */
108         protected void checkLockInfo(LockInfo lockInfo, Object lock) {
109                 if (lock != null) {
110                         verify(lockInfo.getClassName().equals(lock.getClass().getName()), "LockInfo.getClassName() = " + lockInfo.getClassName() + " differs from lock.getClass().getName() = " + lock.getClass().getName());
111                         verify(lockInfo.getIdentityHashCode() == System.identityHashCode(lock), "LockInfo.getIdentityHashCode() = " + lockInfo.getIdentityHashCode() + " differs from System.identityHashCode(lock) = " + System.identityHashCode(lock));
112                         String expectedToString = lock.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(lock));
113                         verify(lockInfo.toString().equals(expectedToString), "LockInfo.toString() = " + lockInfo.toString() + " differs from expected toString() = " + expectedToString);
114                 } else
115                         verify(lockInfo == null, "Unexpected ThreadInfo.getLockInfo(): " + ThreadUtils.strLockInfo(lockInfo));
116         }
117 

 77         }
 78 
 79         /**
 80          * Verifies that given stack trace element from stack trace is expected
 81          * in pre-defined state. This method will be called by checkStackTrace
 82          * for each element.
 83          *
 84          * @param element stack trace element
 85          * @return true if element is expected, false otherwise
 86          */
 87         protected boolean isStackTraceElementExpected(StackTraceElement element) {
 88                 return false;
 89         }
 90 
 91         /**
 92          * Check that stack trace element is expected.
 93          */
 94         protected boolean checkStackTraceElement(StackTraceElement element, String[] expectedMethods) {
 95                 String name = element.getClassName() + "." + element.getMethodName();
 96                 for (String method : expectedMethods)
 97                         if (name.startsWith(method))
 98                                 return true;
 99                 return false;
100         }
101 
102         /**
103          * Check that lock info matches given lock object.
104          *
105          * @param lockInfo lock info
106          * @param lock lock object
107          */
108         protected void checkLockInfo(LockInfo lockInfo, Object lock) {
109                 if (lock != null) {
110                         verify(lockInfo.getClassName().equals(lock.getClass().getName()), "LockInfo.getClassName() = " + lockInfo.getClassName() + " differs from lock.getClass().getName() = " + lock.getClass().getName());
111                         verify(lockInfo.getIdentityHashCode() == System.identityHashCode(lock), "LockInfo.getIdentityHashCode() = " + lockInfo.getIdentityHashCode() + " differs from System.identityHashCode(lock) = " + System.identityHashCode(lock));
112                         String expectedToString = lock.getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(lock));
113                         verify(lockInfo.toString().equals(expectedToString), "LockInfo.toString() = " + lockInfo.toString() + " differs from expected toString() = " + expectedToString);
114                 } else
115                         verify(lockInfo == null, "Unexpected ThreadInfo.getLockInfo(): " + ThreadUtils.strLockInfo(lockInfo));
116         }
117 
< prev index next >