diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java index f4e41409cae58..1ba99246f602a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java @@ -291,7 +291,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable001.java index 75e9f40790c6b..0e784c8973809 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable001.java @@ -289,7 +289,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java index b46bf2ee1a2fa..0a698997d0ed7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java @@ -283,8 +283,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); - + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest (thread1, StepRequest.STEP_MIN, StepRequest.STEP_INTO); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java index 615cf46c7461d..3a72bb8ff7cc7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java @@ -283,7 +283,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java index 767f069438fe1..8cf7d15e7808d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java @@ -285,7 +285,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java index b4b9f0edcbcdc..070286903f45e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java @@ -289,7 +289,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java index d91db9a5a6ac1..ccc8f47299fa6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java @@ -284,7 +284,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java index 479c40904e732..9e9112faf37e8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java @@ -289,7 +289,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java index 57ed8454edadd..6c175ec5ee3ff 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java @@ -282,7 +282,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java index 25b665dbed922..a36154cd58092 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java @@ -286,7 +286,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java index 04995ea0b13a3..b35e6f39898a9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java @@ -291,7 +291,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java index b11a291b2f588..8372daab067c9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java @@ -287,7 +287,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest"); eventRequest1 = eventRManager.createStepRequest diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java index a5dd9023dfd6d..7eaa31598aa3b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java @@ -275,7 +275,7 @@ private void testRun() //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part - thread = debuggee.threadByNameOrThrow(threadName); + thread = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName); if (StepRequest.STEP_MIN > StepRequest.STEP_LINE) { maxSize = StepRequest.STEP_MIN; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003.java index d712fb34c42a4..1de51ac83663a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003.java @@ -77,8 +77,8 @@ public static void main (String argv[]) { //------------------------------------------------------ test specific fields - static final int lineForBreakInThread = 137; - static final int[] checkedLines = { 138, 138, 178 }; + static final int lineForBreakInThread = 141; + static final int[] checkedLines = { 142, 142, 182 }; //------------------------------------------------------ mutable common methods @@ -247,7 +247,7 @@ private void setAndCheckStepEvent ( BreakpointRequest bpRequest, exitCode = FAILED; } - ThreadReference thread = debuggee.threadByNameOrThrow(threadName); + ThreadReference thread = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName); StepRequest stepRequest = setStepRequest( thread, StepRequest.STEP_LINE, stepDepth, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003a.java index 460dc8e92f1ee..d1a5362251c80 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2025, 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 @@ -55,6 +55,10 @@ public class crstepreq003a { static Object waitnotifyObj = new Object(); + static Thread thread0; + static Thread thread1; + static Thread thread2; + //------------------------------------------------------ mutable common method public static void main (String argv[]) { @@ -72,21 +76,21 @@ public static void main (String argv[]) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test case section case 0: - Thread thread0 = JDIThreadFactory.newThread(new Thread0crstepreq003a("thread0")); + thread0 = JDIThreadFactory.newThread(new Thread0crstepreq003a("thread0")); threadStart(thread0); threadJoin (thread0, "0"); break; case 1: - Thread thread1 = JDIThreadFactory.newThread(new Thread0crstepreq003a("thread1")); + thread1 = JDIThreadFactory.newThread(new Thread0crstepreq003a("thread1")); threadStart(thread1); threadJoin (thread1, "1"); break; case 2: - Thread thread2 = JDIThreadFactory.newThread(new Thread0crstepreq003a("thread2")); + thread2 = JDIThreadFactory.newThread(new Thread0crstepreq003a("thread2")); threadStart(thread2); threadJoin (thread2, "2"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004.java index 1ab0ce68af8ad..16c6f79ffc309 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004.java @@ -77,9 +77,9 @@ public static void main (String argv[]) { //------------------------------------------------------ test specific fields - static final int lineForBreakInThread = 146; - static final int[] checkedLines = { 160, 160, 193 }; - static final int[] checkedLinesAlt = { 161, 161, 193 }; + static final int lineForBreakInThread = 149; + static final int[] checkedLines = { 163, 163, 196 }; + static final int[] checkedLinesAlt = { 164, 164, 196 }; //------------------------------------------------------ mutable common methods @@ -248,7 +248,7 @@ private void setAndCheckStepEvent ( BreakpointRequest bpRequest, exitCode = FAILED; } - ThreadReference thread = debuggee.threadByNameOrThrow(threadName); + ThreadReference thread = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName); StepRequest stepRequest = setStepRequest( thread, StepRequest.STEP_LINE, stepDepth, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004a.java index 881d211aa0e96..d6e28602ed74b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2025, 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 @@ -58,6 +58,9 @@ public class crstepreq004a { private static volatile boolean isFirstThreadReady = false; private static volatile boolean isSecondThreadReady = false; + static Thread thread1; + static Thread thread2; + //------------------------------------------------------ mutable common method public static void main (String argv[]) { @@ -95,8 +98,8 @@ public static void main (String argv[]) { private static void runTestCase(int testCaseId) { isFirstThreadReady = false; isSecondThreadReady = false; - Thread thread1 = JDIThreadFactory.newThread(new Thread1crstepreq004a("thread1")); - Thread thread2 = JDIThreadFactory.newThread(new Thread2crstepreq004a("thread2")); + thread1 = JDIThreadFactory.newThread(new Thread1crstepreq004a("thread1")); + thread2 = JDIThreadFactory.newThread(new Thread2crstepreq004a("thread2")); synchronized (lockObj) { thread1.start(); while (!isFirstThreadReady) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java index 23be3eab4c95a..363661d684798 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java @@ -290,7 +290,7 @@ private void testRun() testClassReference = (ReferenceType) vm.classesByName(testedClassName).get(0); - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); eventRequest1 = setting21StepRequest(thread1, testClassReference, EventRequest.SUSPEND_NONE, property1); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java index d4ff86268dafe..9498fdb53e600 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java @@ -282,7 +282,7 @@ private void testRun() switch (i) { case 0: - ThreadReference thread1 = debuggee.threadByNameOrThrow("thread1"); + ThreadReference thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, "thread1"); eventRequest1 = setting23StepRequest(thread1, testedClassName1, EventRequest.SUSPEND_NONE, property1); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java index de63a0af86bf9..d908cb4251f38 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java @@ -281,7 +281,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest with depth StepRequest.STEP_INTO"); eventRequest1 = setting24StepRequest(thread1, StepRequest.STEP_LINE, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java index 5cd109f6fa3fe..acb9792d884bd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java @@ -281,7 +281,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest with depth StepRequest.STEP_OVER"); eventRequest1 = setting24StepRequest(thread1, StepRequest.STEP_LINE, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java index 03b8f415b5620..8e828925f83bd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java @@ -281,7 +281,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest with depth StepRequest.STEP_OUT"); eventRequest1 = setting24StepRequest(thread1, StepRequest.STEP_LINE, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java index db59bf6e4982a..3ae173708bff5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java @@ -281,7 +281,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest with size StepRequest.STEP_MIN"); eventRequest1 = setting24StepRequest(thread1, StepRequest.STEP_MIN, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java index 09b0c53ea8cb1..836d8803c84f3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java @@ -281,7 +281,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest with size StepRequest.STEP_LINE"); eventRequest1 = setting24StepRequest(thread1, StepRequest.STEP_LINE, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java index a8d3769c6c2fb..c00193a8958b2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java @@ -283,7 +283,7 @@ private void testRun() switch (i) { case 0: - thread1 = debuggee.threadByNameOrThrow(threadName1); + thread1 = debuggee.threadByFieldNameOrThrow(debuggeeClass, threadName1); log2("......setting up StepRequest with size StepRequest.STEP_MIN"); eventRequest1 = setting24StepRequest(thread1, StepRequest.STEP_MIN, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java index 3091f51097703..198e20fc626f5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java @@ -302,7 +302,7 @@ private void testRun() } String thread2Name = "thread2"; - ThreadReference thread2Ref = debuggee.threadByNameOrThrow(thread2Name); + ThreadReference thread2Ref = debuggee.threadByFieldNameOrThrow(debuggeeClass, thread2Name); String poppedMethod = "poppedMethod"; @@ -311,7 +311,7 @@ private void testRun() log2("......setting breakpoint in poppedMethod"); try { - breakpointRequest = settingBreakpoint(debuggee.threadByNameOrThrow(thread2Name), + breakpointRequest = settingBreakpoint(thread2Ref, debuggeeClass, poppedMethod, breakpointLine, "one"); } catch ( Exception e ) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java index c47358e96f82f..05d8c1c39f6a4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java @@ -270,10 +270,10 @@ private void testRun() breakpointForCommunication(); String thread2Name = "thread2"; - ThreadReference thread2Ref = debuggee.threadByNameOrThrow(thread2Name); + ThreadReference thread2Ref = debuggee.threadByFieldNameOrThrow(debuggeeClass, thread2Name); String thread3Name = "thread3"; - ThreadReference thread3Ref = debuggee.threadByNameOrThrow(thread3Name); + ThreadReference thread3Ref = debuggee.threadByFieldNameOrThrow(debuggeeClass, thread3Name); String poppedMethod = "poppedMethod"; String breakpointLine = "breakpointLine"; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java index 84ee5996a778a..117a626752c80 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java @@ -283,10 +283,10 @@ private void testRun() String thread2Name = "thread2"; - ThreadReference thread2Ref = debuggee.threadByNameOrThrow(thread2Name); + ThreadReference thread2Ref = debuggee.threadByFieldNameOrThrow(debuggeeClass, thread2Name); String thread3Name = "thread3"; - ThreadReference thread3Ref = debuggee.threadByNameOrThrow(thread3Name); + ThreadReference thread3Ref = debuggee.threadByFieldNameOrThrow(debuggeeClass, thread3Name); String poppedMethod = "poppedMethod"; String breakpointLine = "breakpointLine"; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java index eb46fac37dac2..d4acdde1c9b1b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java @@ -270,7 +270,7 @@ private void testRun() breakpointForCommunication(); String thread2Name = "thread2"; - ThreadReference thread2Ref = debuggee.threadByNameOrThrow(thread2Name); + ThreadReference thread2Ref = debuggee.threadByFieldNameOrThrow(debuggeeClass, thread2Name); StackFrame stackFrame = null; int var; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java index ec499eba24d6c..170f2973a3578 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java @@ -274,7 +274,7 @@ private void testRun() breakpointForCommunication(); String thread2Name = "thread2"; - ThreadReference thread2Ref = debuggee.threadByNameOrThrow(thread2Name); + ThreadReference thread2Ref = debuggee.threadByFieldNameOrThrow(debuggeeClass, thread2Name); StackFrame stackFrame0 = null; StackFrame stackFrame1 = null; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java index 732a7a6696b27..b596e4366e687 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2025, 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 @@ -264,6 +264,33 @@ public ThreadReference threadByNameOrThrow(String name) throws JDITestRuntimeExc throw new JDITestRuntimeException("** Thread IS NOT found ** : " + name); } + /** + * Return a debuggee thread by fetching it from a static field in the debuggee. + */ + public ThreadReference threadByFieldNameOrThrow(ReferenceType debuggeeClass, + String threadFieldName) + throws JDITestRuntimeException { + + Field field = debuggeeClass.fieldByName(threadFieldName); + if (field == null) { + throw new JDITestRuntimeException("** Thread field not found ** : " + + threadFieldName); + } + + ThreadReference thread = (ThreadReference)debuggeeClass.getValue(field); + if (thread == null) { + throw new JDITestRuntimeException("** Thread field is null ** : " + + threadFieldName); + } + + if (!thread.name().equals(threadFieldName)) { + throw new JDITestRuntimeException("** Thread names do not match ** : " + + threadFieldName + " vs. " + thread.name()); + } + + return thread; + } + // --------------------------------------------------- // /**