8206086: [Graal] JDI tests fail with com.sun.jdi.ObjectCollectedException
authordtitov
Fri, 29 Jun 2018 12:34:03 -0700
changeset 50900 f651ae122ff7
parent 50899 4fa199e67e41
child 50901 9f62267e79df
8206086: [Graal] JDI tests fail with com.sun.jdi.ObjectCollectedException Reviewed-by: sspitsyn, cjplummer, amenkov
test/hotspot/jtreg/ProblemList-graal.txt
test/hotspot/jtreg/vmTestbase/nsk/share/jdi/EventTestTemplates.java
--- a/test/hotspot/jtreg/ProblemList-graal.txt	Fri Jun 29 10:13:24 2018 -0700
+++ b/test/hotspot/jtreg/ProblemList-graal.txt	Fri Jun 29 12:34:03 2018 -0700
@@ -121,10 +121,6 @@
 vmTestbase/nsk/jdi/ArrayType/newInstance/newinstance001/TestDescription.java                              8203174   generic-all
 vmTestbase/nsk/jdi/ArrayType/newInstance/newinstance002/TestDescription.java                              8203174   generic-all
 vmTestbase/nsk/jdi/ArrayType/newInstance/newinstance003/TestDescription.java                              8203174   generic-all
-vmTestbase/nsk/jdi/EventRequestManager/methodExitRequests/methexitreq002/TestDescription.java             8203174   generic-all
-vmTestbase/nsk/jdi/MonitorContendedEnteredRequest/MonitorContendedEnteredRequest001/TestDescription.java  8203174   generic-all
-vmTestbase/nsk/jdi/MonitorContendedEnteredRequest/MonitorContendedEnteredRequest002/TestDescription.java  8203174   generic-all
-vmTestbase/nsk/jdi/MonitorWaitedRequest/addClassExclusionFilter/TestDescription.java                      8203174   generic-all
 vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects001/referringObjects001.java          8203174   generic-all
 vmTestbase/nsk/jdi/ReferenceType/instances/instances002/instances002.java                                 8203174   generic-all
 vmTestbase/nsk/jdi/ReferenceType/instances/instances003/instances003.java                                 8203174   generic-all
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/EventTestTemplates.java	Fri Jun 29 10:13:24 2018 -0700
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/EventTestTemplates.java	Fri Jun 29 12:34:03 2018 -0700
@@ -139,7 +139,7 @@
 
         // can't control events from system libraries, so save events only from nsk packages
         protected boolean shouldSaveEvent(Event event) {
-            return isEventFromNSK(event);
+            return isEventFromNSK(event, debuggee);
         }
 
         protected String debuggeeClassName() {
@@ -415,7 +415,7 @@
 
         // can't control events from system libraries, so save events only from nsk packages
         protected boolean shouldSaveEvent(Event event) {
-            return isEventFromNSK(event);
+            return isEventFromNSK(event, debuggee);
         }
 
         protected String debuggeeClassName() {
@@ -436,20 +436,25 @@
         }
     }
 
-    static public boolean isEventFromNSK(Event event) {
-        if (event instanceof MonitorContendedEnterEvent) {
-            return ((MonitorContendedEnterEvent) event).location() != null && ((MonitorContendedEnterEvent) event).monitor().type().name().startsWith("nsk.");
-        }
-        if (event instanceof MonitorContendedEnteredEvent) {
-            return ((MonitorContendedEnteredEvent) event).location() != null  && ((MonitorContendedEnteredEvent) event).monitor().type().name().startsWith("nsk.");
+    static public boolean isEventFromNSK(Event event, Debugee debuggee) {
+        try {
+            if (event instanceof MonitorContendedEnterEvent) {
+                return ((MonitorContendedEnterEvent) event).location() != null && ((MonitorContendedEnterEvent) event).monitor().type().name().startsWith("nsk.");
+            }
+            if (event instanceof MonitorContendedEnteredEvent) {
+                return ((MonitorContendedEnteredEvent) event).location() != null && ((MonitorContendedEnteredEvent) event).monitor().type().name().startsWith("nsk.");
+            }
+            if (event instanceof MonitorWaitEvent) {
+                return ((MonitorWaitEvent) event).monitor().type().name().startsWith("nsk.");
+            }
+            if (event instanceof MonitorWaitedEvent) {
+                return ((MonitorWaitedEvent) event).monitor().type().name().startsWith("nsk.");
+            }
+        } catch (ObjectCollectedException ex) {
+            // The monitor object the event refers to might be already collected. Ignore this exception.
+            debuggee.getLog().display("Exception caught:" + ex);
+            return false;
         }
-        if (event instanceof MonitorWaitEvent) {
-            return ((MonitorWaitEvent) event).monitor().type().name().startsWith("nsk.");
-        }
-        if (event instanceof MonitorWaitedEvent) {
-            return ((MonitorWaitedEvent) event).monitor().type().name().startsWith("nsk.");
-        }
-
         // don't filter other events
         return true;
     }