8270434: JDI+UT: Unexpected event in JDI tests

Reviewed-by: sspitsyn, kevinw
This commit is contained in:
Alex Menkov 2021-09-16 23:45:08 +00:00
parent b98290444a
commit 8c022e2c17
3 changed files with 28 additions and 5 deletions
test/hotspot/jtreg/vmTestbase/nsk
jdi
EventIterator/nextEvent
EventRequestManager/methodEntryRequests
share/jdi

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -320,6 +320,8 @@ public class nextevent001 extends JDIBase {
log1(" TESTING BEGINS");
{
final String testThreadName = "thread2";
log2("......setting up ThreadStartRequest");
ThreadStartRequest tsr = eventRManager.createThreadStartRequest();
tsr.addCountFilter(1);
@ -342,7 +344,7 @@ public class nextevent001 extends JDIBase {
vm.resume();
log2("......waiting for ThreadStartEvent");
getEventSet();
getEventSetForThreadStartDeath(testThreadName);
eventSets[10] = eventSet;
Event receivedEvent = eventIterator.nextEvent();
@ -357,7 +359,7 @@ public class nextevent001 extends JDIBase {
vm.resume();
log2("......waiting for ThreadDeathEvent");
getEventSet();
getEventSetForThreadStartDeath(testThreadName);
eventSets[9] = eventSet;
receivedEvent = eventIterator.nextEvent();
if ( !(receivedEvent instanceof ThreadDeathEvent) ) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -266,7 +266,7 @@ public class methentreq002 extends JDIBase {
for (int i = 0; ; i++) {
vm.resume();
breakpointForCommunication();
breakpointForCommunication(debuggeeName);
int instruction = ((IntegerValue)
(debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value();

@ -197,4 +197,25 @@ public class JDIBase {
throw new JDITestRuntimeException("** event '" + event + "' IS NOT a breakpoint **");
}
// Similar to breakpointForCommunication, but skips Locatable events from unexpected locations.
// It's useful for cases when enabled event requests can cause notifications from system threads
// (like MethodEntryRequest, MethodExitRequest).
protected void breakpointForCommunication(String debuggeeName) throws JDITestRuntimeException {
log2("breakpointForCommunication");
while (true) {
getEventSet();
Event event = eventIterator.nextEvent();
if (event instanceof BreakpointEvent) {
return;
}
if (EventFilters.filtered(event, debuggeeName)) {
log2(" got unexpected event: " + event + ", skipping");
eventSet.resume();
} else {
throw new JDITestRuntimeException("** event '" + event + "' IS NOT a breakpoint **");
}
}
}
}