8147447: serviceability/tmtools/jstack/WaitNotifyThreadTest.java test fails
Corrected verification of the jstack object references Reviewed-by: sla
This commit is contained in:
parent
ce491c9057
commit
17b9e0a7aa
hotspot/test/serviceability/tmtools/jstack
@ -88,6 +88,7 @@ public class WaitNotifyThreadTest {
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
|
||||
// Verify stack trace consistency when notifying the thread
|
||||
doTest(new ActionNotify());
|
||||
|
||||
@ -134,8 +135,7 @@ public class WaitNotifyThreadTest {
|
||||
if (mi.getName().startsWith(OBJECT_WAIT) && mi.getCompilationUnit() == null /*native method*/) {
|
||||
if (mi.getLocks().size() == 1) {
|
||||
MonitorInfo monInfo = mi.getLocks().getFirst();
|
||||
if (monInfo.getType().equals("waiting on")
|
||||
&& monInfo.getMonitorClass().equals(OBJECT)) {
|
||||
if (monInfo.getType().equals("waiting on") && compareMonitorClass(monInfo)) {
|
||||
monitorAddress = monInfo.getMonitorAddress();
|
||||
} else {
|
||||
System.err.println("Error: incorrect monitor info: " + monInfo.getType() + ", " + monInfo.getMonitorClass());
|
||||
@ -166,7 +166,7 @@ public class WaitNotifyThreadTest {
|
||||
|
||||
private void assertMonitorInfo(String expectedMessage, MonitorInfo monInfo, String monitorAddress) {
|
||||
if (monInfo.getType().equals(expectedMessage)
|
||||
&& monInfo.getMonitorClass().equals(OBJECT + "11")
|
||||
&& compareMonitorClass(monInfo)
|
||||
&& monInfo.getMonitorAddress().equals(
|
||||
monitorAddress)) {
|
||||
System.out.println("Correct monitor info found");
|
||||
@ -177,6 +177,13 @@ public class WaitNotifyThreadTest {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean compareMonitorClass(MonitorInfo monInfo) {
|
||||
// If monitor class info is present in the jstack output
|
||||
// then compare it with the class of the actual monitor object
|
||||
// If there is no monitor class info available then return true
|
||||
return OBJECT.equals(monInfo.getMonitorClass()) || (monInfo.getMonitorClass() == null);
|
||||
}
|
||||
|
||||
private void analyzeThreadStackNoWaiting(ThreadStack ti2) {
|
||||
Iterator<MethodInfo> it = ti2.getStack().iterator();
|
||||
|
||||
|
@ -70,10 +70,18 @@ public class DefaultFormat implements Format {
|
||||
return "^JNI\\sglobal\\sreferences:\\s((.+))$";
|
||||
}
|
||||
|
||||
// Sample string that matches the pattern:
|
||||
// waiting on <0x000000008f64e6d0> (a java.lang.Object)
|
||||
protected String monitorInfoPattern() {
|
||||
return "^\\s+\\-\\s(locked|waiting\\son|waiting\\sto\\slock)\\s\\<(.*)\\>\\s\\(((.*))\\)$";
|
||||
}
|
||||
|
||||
// Sample string that matches the pattern:
|
||||
// waiting on <no object reference available>
|
||||
protected String monitorInfoNoObjectRefPattern() {
|
||||
return "^\\s+\\-\\s(locked|waiting\\son|waiting\\sto\\slock)\\s\\<(.*)\\>$";
|
||||
}
|
||||
|
||||
protected String vmVersionInfoPattern() {
|
||||
return "Full\\sthread\\sdump\\s.*";
|
||||
}
|
||||
@ -100,7 +108,10 @@ public class DefaultFormat implements Format {
|
||||
currentMethodInfo = parseMethodInfo(line);
|
||||
currentThreadStack.addMethod(currentMethodInfo);
|
||||
} else if (line.matches(monitorInfoPattern())) {
|
||||
MonitorInfo mi = parseMonitorInfo(line);
|
||||
MonitorInfo mi = parseMonitorInfo(line, monitorInfoPattern());
|
||||
currentMethodInfo.getLocks().add(mi);
|
||||
} else if (line.matches(monitorInfoNoObjectRefPattern())) {
|
||||
MonitorInfo mi = parseMonitorInfo(line, monitorInfoNoObjectRefPattern());
|
||||
currentMethodInfo.getLocks().add(mi);
|
||||
} else if (line.matches(extendedStatusPattern())) {
|
||||
currentThreadStack.setExtendedStatus(parseExtendedStatus(line));
|
||||
@ -125,16 +136,17 @@ public class DefaultFormat implements Format {
|
||||
return result;
|
||||
}
|
||||
|
||||
private MonitorInfo parseMonitorInfo(String line) {
|
||||
private MonitorInfo parseMonitorInfo(String line, String pattern) {
|
||||
Scanner s = new Scanner(line);
|
||||
s.findInLine(monitorInfoPattern());
|
||||
s.findInLine(pattern);
|
||||
MonitorInfo mi = new MonitorInfo();
|
||||
MatchResult res = s.match();
|
||||
|
||||
mi.setType(res.group(1));
|
||||
mi.setMonitorAddress(res.group(2));
|
||||
mi.setMonitorClass(res.group(3));
|
||||
|
||||
if (res.groupCount() > 2) {
|
||||
mi.setMonitorClass(res.group(3));
|
||||
}
|
||||
return mi;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user