Skip to content
Permalink
Browse files
8270434: JDI+UT: Unexpected event in JDI tests
Reviewed-by: sspitsyn, kevinw
  • Loading branch information
Alex Menkov committed Sep 16, 2021
1 parent b982904 commit 8c022e2c174cca2b03e8fdf4fadad42bc11c65f1
Showing 3 changed files with 28 additions and 5 deletions.
@@ -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 @@ private void testRun()
log1(" TESTING BEGINS");

{
final String testThreadName = "thread2";

log2("......setting up ThreadStartRequest");
ThreadStartRequest tsr = eventRManager.createThreadStartRequest();
tsr.addCountFilter(1);
@@ -342,7 +344,7 @@ private void testRun()
vm.resume();

log2("......waiting for ThreadStartEvent");
getEventSet();
getEventSetForThreadStartDeath(testThreadName);
eventSets[10] = eventSet;

Event receivedEvent = eventIterator.nextEvent();
@@ -357,7 +359,7 @@ private void testRun()
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 @@ private void testRun()
for (int i = 0; ; i++) {

vm.resume();
breakpointForCommunication();
breakpointForCommunication(debuggeeName);

int instruction = ((IntegerValue)
(debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value();
@@ -197,4 +197,25 @@ protected void breakpointForCommunication() throws JDITestRuntimeException {
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 **");
}
}
}

}

1 comment on commit 8c022e2

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 8c022e2 Sep 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.