From 14e41ab055955ffd7cf9e8129cc3269b4e3807b7 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Fri, 30 May 2025 20:14:14 +0000 Subject: [PATCH] 8357172: Extend try block in nsk/jdi tests to capture exceptions thrown by Debuggee.classByName() Reviewed-by: lmesnik, sspitsyn --- .../invokeMethod/invokemethod009.java | 20 +++---- .../invokeMethod/invokemethod010.java | 51 ++++++++---------- .../invokeMethod/invokemethod014.java | 26 ++++----- .../ClassType/newInstance/newinstance009.java | 53 ++++++++----------- .../invokeMethod/invokemethod002.java | 18 +++---- .../invokeMethod/invokemethod003.java | 30 +++++------ .../invokeMethod/invokemethod004.java | 37 ++++++------- .../invokeMethod/invokemethod005.java | 22 ++++---- .../invokeMethod/invokemethod006.java | 22 ++++---- .../invokeMethod/invokemethod007.java | 22 ++++---- .../invokeMethod/invokemethod008.java | 26 ++++----- .../invokeMethod/invokemethod009.java | 26 ++++----- .../invokeMethod/invokemethod014.java | 28 +++++----- .../ObjectReference/setValue/setvalue002.java | 36 ++++++------- .../ObjectReference/setValue/setvalue003.java | 37 ++++++------- .../ObjectReference/setValue/setvalue004.java | 37 ++++++------- .../ObjectReference/setValue/setvalue005.java | 39 ++++++-------- .../setValue/setvalue005/setvalue005.java | 24 ++++----- .../ownedMonitors/ownedmonitors002.java | 47 +++++++--------- .../popFrames/popframes006.java | 24 ++++----- .../popFrames/popframes007.java | 42 +++++++-------- .../nsk/jdi/ThreadReference/stop/stop002.java | 23 ++++---- 22 files changed, 318 insertions(+), 372 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009.java index c5e1be8f4a3..fe96c69ace6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009.java @@ -112,19 +112,19 @@ public class invokemethod009 { return quitDebuggee(); } - // debuggee main class - ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); + try { + // debuggee main class + ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); - thrRef = debuggee.threadByFieldName(rType, "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } + thrRef = debuggee.threadByFieldName(rType, "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } // Check the tested assersion - try { suspendAtBP(rType, DEBUGGEE_STOPATLINE); ClassType clsType = (ClassType) rType; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod010.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod010.java index 65621fb712c..f813a447192 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod010.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod010.java @@ -111,36 +111,29 @@ public class invokemethod010 { return quitDebuggee(); } - // debuggee main class - ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); - - thrRef = debuggee.threadByFieldName(rType, "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - thrRef.suspend(); - while(!thrRef.isSuspended()) { - num++; - if (num > ATTEMPTS) { - log.complain("TEST FAILED: unable to suspend debuggee thread"); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - log.display("Waiting for debuggee thread suspension ..."); - try { - Thread.currentThread().sleep(TIMEOUT_DELTA); - } catch(InterruptedException ie) { - ie.printStackTrace(); - log.complain("TEST FAILED: caught: " + ie); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - } - try { + // debuggee main class + ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); + + thrRef = debuggee.threadByFieldName(rType, "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + thrRef.suspend(); + while(!thrRef.isSuspended()) { + num++; + if (num > ATTEMPTS) { + log.complain("TEST FAILED: unable to suspend debuggee thread"); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + log.display("Waiting for debuggee thread suspension ..."); + Thread.currentThread().sleep(TIMEOUT_DELTA); + } + // debuggee main class ClassType clsType = (ClassType) rType; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod014.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod014.java index c1b5a2a64ab..900a453a2da 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod014.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod014.java @@ -113,20 +113,20 @@ public class invokemethod014 { return quitDebuggee(); } - // debuggee main class - ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); - ClassType clsType = (ClassType) rType; - - ThreadReference thrRef = - debuggee.threadByFieldName(rType, "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - try { + // debuggee main class + ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); + ClassType clsType = (ClassType) rType; + + ThreadReference thrRef = + debuggee.threadByFieldName(rType, "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + suspendAtBP(rType, DEBUGGEE_STOPATLINE); for (int i=0; i ATTEMPTS) { - log.complain("TEST FAILED: unable to suspend debuggee thread"); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - log.display("Waiting for debuggee thread suspension ..."); - try { - Thread.currentThread().sleep(DELAY); - } catch(InterruptedException ie) { - ie.printStackTrace(); - log.complain("TEST FAILED: caught: " + ie); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - } - try { + // debuggee main class + ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); + ClassType clsType = (ClassType) rType; + + ThreadReference thrRef = debuggee.threadByFieldName(rType, "thread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + thrRef.suspend(); + while(!thrRef.isSuspended()) { + num++; + if (num > ATTEMPTS) { + log.complain("TEST FAILED: unable to suspend debuggee thread"); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + log.display("Waiting for debuggee thread suspension ..."); + Thread.currentThread().sleep(DELAY); + } + List methList = rType.methodsByName(""); if (methList.isEmpty()) { log.complain("TEST FAILURE: the expected constructor " diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod002.java index 7c43d0b2fa5..44189cb3c3b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod002.java @@ -124,18 +124,18 @@ public class invokemethod002 { return quitDebuggee(); } - rType[0] = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class + try { + rType[0] = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class - thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } + thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } // Check the tested assersion - try { suspendAtBP(rType[0], DEBUGGEE_STOPATLINE); findObjRef(DEBUGGEE_LOCALVAR); rType[1] = objRef[1].referenceType(); // debuggee dummy class diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod003.java index a348f9ff78c..537be5cde65 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod003.java @@ -135,24 +135,24 @@ public class invokemethod003 { return quitDebuggee(); } - ReferenceType[] rType = new ReferenceType[3]; - // debuggee main class - rType[0] = debuggee.classByName(DEBUGGEE_CLASS); - // debuggee dummy interface - rType[1] = debuggee.classByName(DEBUGGEE_INTERFACE); - // debuggee dummy abstract class - rType[2] = debuggee.classByName(DEBUGGEE_ABSTRACTCLASS); + try { + ReferenceType[] rType = new ReferenceType[3]; + // debuggee main class + rType[0] = debuggee.classByName(DEBUGGEE_CLASS); + // debuggee dummy interface + rType[1] = debuggee.classByName(DEBUGGEE_INTERFACE); + // debuggee dummy abstract class + rType[2] = debuggee.classByName(DEBUGGEE_ABSTRACTCLASS); - thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } + thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } // Check the tested assersion - try { suspendAtBP(rType[0], DEBUGGEE_STOPATLINE); ObjectReference objRef = findObjRef(DEBUGGEE_LOCALVAR); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod004.java index 3b26eb2a010..61a78285a6b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod004.java @@ -111,36 +111,29 @@ public class invokemethod004 { return quitDebuggee(); } - ReferenceType debuggeeClass = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class + try { + ReferenceType debuggeeClass = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class - thrRef = debuggee.threadByFieldName(debuggeeClass, "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - thrRef.suspend(); - while(!thrRef.isSuspended()) { - num++; - if (num > ATTEMPTS) { - log.complain("TEST FAILED: unable to suspend debuggee thread"); + thrRef = debuggee.threadByFieldName(debuggeeClass, "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); tot_res = Consts.TEST_FAILED; return quitDebuggee(); } - log.display("Waiting for debuggee thread suspension ..."); - try { + thrRef.suspend(); + while(!thrRef.isSuspended()) { + num++; + if (num > ATTEMPTS) { + log.complain("TEST FAILED: unable to suspend debuggee thread"); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + log.display("Waiting for debuggee thread suspension ..."); Thread.currentThread().sleep(1000); - } catch(InterruptedException ie) { - ie.printStackTrace(); - log.complain("TEST FAILED: caught: " + ie); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); } - } // Check the tested assersion - try { ObjectReference objRef = findObjRef(DEBUGGEE_LOCALVAR); ReferenceType rType = objRef.referenceType(); // debuggee dummy class diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod005.java index fcc13dc3b10..a6f7806753d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod005.java @@ -113,20 +113,20 @@ public class invokemethod005 { return quitDebuggee(); } - ReferenceType[] rType = new ReferenceType[2]; - // debuggee main class - rType[0] = debuggee.classByName(DEBUGGEE_CLASS); + try { + ReferenceType[] rType = new ReferenceType[2]; + // debuggee main class + rType[0] = debuggee.classByName(DEBUGGEE_CLASS); - thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } + thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } // Check the tested assersion - try { suspendAtBP(rType[0], DEBUGGEE_STOPATLINE); ObjectReference objRef = findObjRef(DEBUGGEE_LOCALVAR); rType[1] = objRef.referenceType(); // debuggee dummy class diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod006.java index 0583cf62b53..d914b8bacfc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod006.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod006.java @@ -111,20 +111,20 @@ public class invokemethod006 { return quitDebuggee(); } - ReferenceType[] rType = new ReferenceType[2]; - // debuggee main class - rType[0] = debuggee.classByName(DEBUGGEE_CLASS); + try { + ReferenceType[] rType = new ReferenceType[2]; + // debuggee main class + rType[0] = debuggee.classByName(DEBUGGEE_CLASS); - thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } + thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } // Check the tested assersion - try { suspendAtBP(rType[0], DEBUGGEE_STOPATLINE); ObjectReference objRef = findObjRef(DEBUGGEE_LOCALVAR); rType[1] = objRef.referenceType(); // debuggee dummy class diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod007.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod007.java index fa5c9ec3e17..9dc343d69a9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod007.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod007.java @@ -127,20 +127,20 @@ public class invokemethod007 { return quitDebuggee(); } - ReferenceType[] rType = new ReferenceType[2]; - // debuggee main class - rType[0] = debuggee.classByName(DEBUGGEE_CLASS); + try { + ReferenceType[] rType = new ReferenceType[2]; + // debuggee main class + rType[0] = debuggee.classByName(DEBUGGEE_CLASS); - thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } + thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } // Check the tested assersion - try { suspendAtBP(rType[0], DEBUGGEE_STOPATLINE); ObjectReference objRef = findObjRef(DEBUGGEE_LOCALVAR); rType[1] = objRef.referenceType(); // debuggee dummy class diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod008.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod008.java index c0426229e5b..7572c5adefe 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod008.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod008.java @@ -120,22 +120,22 @@ public class invokemethod008 { return quitDebuggee(); } - ReferenceType[] rType = new ReferenceType[3]; - // reference types of debuggee main & dummy classes - rType[0] = debuggee.classByName(DEBUGGEE_CLASSES[0]); - rType[1] = debuggee.classByName(DEBUGGEE_CLASSES[1]); - rType[2] = debuggee.classByName(DEBUGGEE_CLASSES[2]); + try { + ReferenceType[] rType = new ReferenceType[3]; + // reference types of debuggee main & dummy classes + rType[0] = debuggee.classByName(DEBUGGEE_CLASSES[0]); + rType[1] = debuggee.classByName(DEBUGGEE_CLASSES[1]); + rType[2] = debuggee.classByName(DEBUGGEE_CLASSES[2]); - thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } + thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } // Check the tested assersion - try { suspendAtBP(rType[0], DEBUGGEE_STOPATLINE); ObjectReference objRef = findObjRef(DEBUGGEE_LOCALVAR); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod009.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod009.java index ce3545ac228..72ea170440e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod009.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod009.java @@ -120,22 +120,22 @@ public class invokemethod009 { return quitDebuggee(); } - ReferenceType[] rType = new ReferenceType[3]; - // reference types of debuggee main & dummy classes - rType[0] = debuggee.classByName(DEBUGGEE_CLASSES[0]); - rType[1] = debuggee.classByName(DEBUGGEE_CLASSES[1]); - rType[2] = debuggee.classByName(DEBUGGEE_CLASSES[2]); + try { + ReferenceType[] rType = new ReferenceType[3]; + // reference types of debuggee main & dummy classes + rType[0] = debuggee.classByName(DEBUGGEE_CLASSES[0]); + rType[1] = debuggee.classByName(DEBUGGEE_CLASSES[1]); + rType[2] = debuggee.classByName(DEBUGGEE_CLASSES[2]); - thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } + thrRef = debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } // Check the tested assersion - try { suspendAtBP(rType[0], DEBUGGEE_STOPATLINE); ObjectReference objRef = findObjRef(DEBUGGEE_LOCALVAR); LinkedList argList = new LinkedList(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod014.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod014.java index 3005ed87a64..0950b4064db 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod014.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod014.java @@ -143,23 +143,23 @@ public class invokemethod014 { return quitDebuggee(); } - ReferenceType[] rType = new ReferenceType[3]; - // debuggee main & dummy classes - rType[0] = debuggee.classByName(DEBUGGEE_CLASSES[0]); - rType[1] = debuggee.classByName(DEBUGGEE_CLASSES[1]); - rType[2] = debuggee.classByName(DEBUGGEE_CLASSES[2]); + try { + ReferenceType[] rType = new ReferenceType[3]; + // debuggee main & dummy classes + rType[0] = debuggee.classByName(DEBUGGEE_CLASSES[0]); + rType[1] = debuggee.classByName(DEBUGGEE_CLASSES[1]); + rType[2] = debuggee.classByName(DEBUGGEE_CLASSES[2]); - ThreadReference thrRef = - debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } + ThreadReference thrRef = + debuggee.threadByFieldName(rType[0], "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } // Check the tested assersion - try { suspendAtBP(rType[0], DEBUGGEE_STOPATLINE); objRef = findObjRef(thrRef, DEBUGGEE_LOCALVAR); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue002.java index 1c4803cffef..b9c5a99a4ea 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue002.java @@ -109,35 +109,29 @@ public class setvalue002 { return quitDebuggee(); } - ReferenceType debuggeeClass = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class + try { + ReferenceType debuggeeClass = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class - thrRef = debuggee.threadByFieldName(debuggeeClass, "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee's thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - thrRef.suspend(); - while(!thrRef.isSuspended()) { - num++; - if (num > ATTEMPTS) { - log.complain("TEST FAILED: Unable to suspend debuggee's thread"); + thrRef = debuggee.threadByFieldName(debuggeeClass, "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee's thread " + + DEBUGGEE_THRNAME); tot_res = Consts.TEST_FAILED; return quitDebuggee(); } - log.display("Waiting for debuggee's thread suspension ..."); - try { + thrRef.suspend(); + while (!thrRef.isSuspended()) { + num++; + if (num > ATTEMPTS) { + log.complain("TEST FAILED: Unable to suspend debuggee's thread"); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + log.display("Waiting for debuggee's thread suspension ..."); Thread.currentThread().sleep(1000); - } catch(InterruptedException ie) { - log.complain("TEST FAILED: caught: " + ie); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); } - } // Check the tested assersion - try { findObjRefs(DEBUGGEE_LOCALVAR); rType[0] = objRef[0].referenceType(); rType[1] = objRef[1].referenceType(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue003.java index 4fbe110ca96..8bb08f43c2e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue003.java @@ -142,36 +142,29 @@ public class setvalue003 { return quitDebuggee(); } - ReferenceType debuggeeClass = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class + try { + ReferenceType debuggeeClass = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class - thrRef = debuggee.threadByFieldName(debuggeeClass, "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee's thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - thrRef.suspend(); - while(!thrRef.isSuspended()) { - num++; - if (num > ATTEMPTS) { - log.complain("TEST FAILED: Unable to suspend debuggee's thread"); + thrRef = debuggee.threadByFieldName(debuggeeClass, "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee's thread " + + DEBUGGEE_THRNAME); tot_res = Consts.TEST_FAILED; return quitDebuggee(); } - log.display("Waiting for debuggee's thread suspension ..."); - try { + thrRef.suspend(); + while (!thrRef.isSuspended()) { + num++; + if (num > ATTEMPTS) { + log.complain("TEST FAILED: Unable to suspend debuggee's thread"); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + log.display("Waiting for debuggee's thread suspension ..."); Thread.sleep(1000); - } catch(InterruptedException ie) { - ie.printStackTrace(); - log.complain("TEST FAILED: caught: " + ie); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } } // Check the tested assertion - try { objRef = findObjRef(DEBUGGEE_LOCALVAR); rType = objRef.referenceType(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue004.java index 0eed84859eb..1928e965e32 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue004.java @@ -122,36 +122,29 @@ public class setvalue004 { return quitDebuggee(); } - ReferenceType debuggeeClass = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class + try { + ReferenceType debuggeeClass = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class - thrRef = debuggee.threadByFieldName(debuggeeClass, "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee's thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - thrRef.suspend(); - while(!thrRef.isSuspended()) { - num++; - if (num > ATTEMPTS) { - log.complain("TEST FAILED: Unable to suspend debuggee's thread"); + thrRef = debuggee.threadByFieldName(debuggeeClass, "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee's thread " + + DEBUGGEE_THRNAME); tot_res = Consts.TEST_FAILED; return quitDebuggee(); } - log.display("Waiting for debuggee's thread suspension ..."); - try { + thrRef.suspend(); + while(!thrRef.isSuspended()) { + num++; + if (num > ATTEMPTS) { + log.complain("TEST FAILED: Unable to suspend debuggee's thread"); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + log.display("Waiting for debuggee's thread suspension ..."); Thread.currentThread().sleep(1000); - } catch(InterruptedException ie) { - ie.printStackTrace(); - log.complain("TEST FAILED: caught: " + ie); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); } - } // Check the tested assersion - try { objRef = findObjRef(DEBUGGEE_LOCALVAR); rType = objRef.referenceType(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue005.java index b77ea99979d..25e1f0c37b6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/setValue/setvalue005.java @@ -109,37 +109,30 @@ public class setvalue005 { return quitDebuggee(); } - ReferenceType debuggeeClass = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class + try { + ReferenceType debuggeeClass = debuggee.classByName(DEBUGGEE_CLASS); // debuggee main class - thrRef = debuggee.threadByFieldName(debuggeeClass, "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - thrRef.suspend(); - while(!thrRef.isSuspended()) { - num++; - if (num > ATTEMPTS) { - log.complain("TEST FAILED: Unable to suspend debuggee thread after " - + ATTEMPTS + " attempts"); + thrRef = debuggee.threadByFieldName(debuggeeClass, "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: Method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); tot_res = Consts.TEST_FAILED; return quitDebuggee(); } - log.display("Waiting for debuggee thread suspension ..."); - try { + thrRef.suspend(); + while(!thrRef.isSuspended()) { + num++; + if (num > ATTEMPTS) { + log.complain("TEST FAILED: Unable to suspend debuggee thread after " + + ATTEMPTS + " attempts"); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + log.display("Waiting for debuggee thread suspension ..."); Thread.currentThread().sleep(1000); - } catch(InterruptedException ie) { - ie.printStackTrace(); - log.complain("TEST FAILED: caught: " + ie); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); } - } // Check the tested assersion - try { objRef = findObjRef(DEBUGGEE_LOCALVAR); rType = objRef.referenceType(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StackFrame/setValue/setvalue005/setvalue005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StackFrame/setValue/setvalue005/setvalue005.java index 3b8a49ac5d1..dd071f2e087 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StackFrame/setValue/setvalue005/setvalue005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StackFrame/setValue/setvalue005/setvalue005.java @@ -156,19 +156,19 @@ public class setvalue005 { return quitDebuggee(); } - // debuggee main class - ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); - - ThreadReference thrRef = - debuggee.threadByFieldName(rType, "mainThread", DEBUGGEE_THRDNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRDNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - try { + // debuggee main class + ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); + + ThreadReference thrRef = + debuggee.threadByFieldName(rType, "mainThread", DEBUGGEE_THRDNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRDNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + suspendAtBP(rType, DEBUGGEE_STOPATLINE); // find a stack frame which belongs to the "setvalue005tMainThr" thread diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/ownedMonitors/ownedmonitors002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/ownedMonitors/ownedmonitors002.java index 068670202c5..a77c153ab5d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/ownedMonitors/ownedmonitors002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/ownedMonitors/ownedmonitors002.java @@ -91,41 +91,34 @@ public class ownedmonitors002 { return quitDebuggee(); } - // debuggee main class - ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); + try { + // debuggee main class + ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); - ThreadReference thrRef = - debuggee.threadByFieldName(rType, "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - - int num = 0; - thrRef.suspend(); - while(!thrRef.isSuspended()) { - num++; - if (num > ATTEMPTS) { - log.complain("TEST FAILURE: Unable to suspend debuggee thread after " - + ATTEMPTS + " attempts"); + ThreadReference thrRef = + debuggee.threadByFieldName(rType, "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); tot_res = Consts.TEST_FAILED; return quitDebuggee(); } - log.display("Waiting for debuggee thread suspension ..."); - try { + + int num = 0; + thrRef.suspend(); + while(!thrRef.isSuspended()) { + num++; + if (num > ATTEMPTS) { + log.complain("TEST FAILURE: Unable to suspend debuggee thread after " + + ATTEMPTS + " attempts"); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + log.display("Waiting for debuggee thread suspension ..."); Thread.currentThread().sleep(DELAY); - } catch(InterruptedException ie) { - ie.printStackTrace(); - log.complain("TEST FAILURE: caught: " + ie); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); } - } // Check the tested assersion - try { List mons = thrRef.ownedMonitors(); if (vm.canGetOwnedMonitorInfo()) { log.display("CHECK PASSED: got a List of monitors owned by the thread," diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes006.java index ed60d3abe53..fe0543fe11f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes006.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes006.java @@ -106,20 +106,20 @@ public class popframes006 { return quitDebuggee(); } - // debuggee main class - ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); - - ThreadReference thrRef = - debuggee.threadByFieldName(rType, "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - Field doExit = null; try { + // debuggee main class + ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); + + ThreadReference thrRef = + debuggee.threadByFieldName(rType, "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + suspendAtBP(rType, DEBUGGEE_STOPATLINE); // debuggee field used to indicate that popping has been done diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes007.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes007.java index 350b89ef4b6..df086449bef 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes007.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes007.java @@ -106,29 +106,29 @@ public class popframes007 { return quitDebuggee(); } - // debuggee main class - ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); - - ThreadReference mainThread = - debuggee.threadByFieldName(rType, "mainThread", DEBUGGEE_MAIN_THREAD_NAME); - if (mainThread == null) { - log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_MAIN_THREAD_NAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - - ThreadReference auxThread = - debuggee.threadByFieldName(rType, "auxThr", DEBUGGEE_AUX_THREAD_NAME); - if (auxThread == null) { - log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_AUX_THREAD_NAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - Field doExit = null; try { + // debuggee main class + ReferenceType rType = debuggee.classByName(DEBUGGEE_CLASS); + + ThreadReference mainThread = + debuggee.threadByFieldName(rType, "mainThread", DEBUGGEE_MAIN_THREAD_NAME); + if (mainThread == null) { + log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_MAIN_THREAD_NAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + + ThreadReference auxThread = + debuggee.threadByFieldName(rType, "auxThr", DEBUGGEE_AUX_THREAD_NAME); + if (auxThread == null) { + log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_AUX_THREAD_NAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + suspendAtBP(rType, DEBUGGEE_STOPATLINE); // debuggee field used to indicate that popping has been done diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002.java index fcf38c5c5ab..02a87d9c42b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002.java @@ -115,22 +115,23 @@ public class stop002 { return quitDebuggee(); } - // debuggee main class - mainClass = debuggee.classByName(DEBUGGEE_CLASS); - - ThreadReference thrRef = debuggee.threadByFieldName(mainClass, "testThread", DEBUGGEE_THRNAME); - if (thrRef == null) { - log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " - + DEBUGGEE_THRNAME); - tot_res = Consts.TEST_FAILED; - return quitDebuggee(); - } - Field stopLoop1 = null; Field stopLoop2 = null; ObjectReference objRef = null; ObjectReference throwableRef = null; + try { + // debuggee main class + mainClass = debuggee.classByName(DEBUGGEE_CLASS); + + ThreadReference thrRef = debuggee.threadByFieldName(mainClass, "testThread", DEBUGGEE_THRNAME); + if (thrRef == null) { + log.complain("TEST FAILURE: method Debugee.threadByFieldName() returned null for debuggee thread " + + DEBUGGEE_THRNAME); + tot_res = Consts.TEST_FAILED; + return quitDebuggee(); + } + suspendAtBP(mainClass, DEBUGGEE_STOPATLINE); objRef = findObjRef(thrRef, DEBUGGEE_NON_THROWABLE_VAR); throwableRef = findObjRef(thrRef, DEBUGGEE_THROWABLE_VAR);