Skip to content

Commit 9273094

Browse files
committed
8356023: Some nsk/jdi tests can fetch ThreadReference from static field in the debuggee: part 2
Reviewed-by: amenkov, sspitsyn, lmesnik
1 parent 24d84cf commit 9273094

File tree

92 files changed

+400
-828
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+400
-828
lines changed

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod001.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -173,6 +173,7 @@ private int runThis (String argv[], PrintStream out) {
173173
}
174174

175175
VirtualMachine vm = debuggee.VM();
176+
ReferenceType debuggeeClass = debuggee.classByName(debuggeeName);
176177

177178
//------------------------------------------------------ testing section
178179
log1(" TESTING BEGINS");
@@ -209,9 +210,6 @@ private int runThis (String argv[], PrintStream out) {
209210
//String bpLine2 = "breakpointLineNumber2";
210211
//String bpLine3 = "breakpointLineNumber3";
211212

212-
213-
List allThreads = null;
214-
ListIterator listIterator = null;
215213
List classes = null;
216214

217215
BreakpointRequest breakpRequest1 = null;
@@ -231,7 +229,6 @@ private int runThis (String argv[], PrintStream out) {
231229

232230
log2("getting ThreadReference object");
233231
try {
234-
allThreads = vm.allThreads();
235232
classes = vm.classesByName(testedClassName);
236233
testedclass = (ReferenceType) classes.get(0);
237234
classType = (ClassType) testedclass;
@@ -241,7 +238,7 @@ private int runThis (String argv[], PrintStream out) {
241238
break label0;
242239
}
243240

244-
thread2 = debuggee.threadByName(threadName);
241+
thread2 = debuggee.threadByFieldNameOrThrow(debuggeeClass, "test_thread", threadName);
245242

246243
log2("setting up a breakpoint");
247244

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod001a.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -59,6 +59,8 @@ private static void logErr(String message) {
5959

6060
//====================================================== test program
6161

62+
static Thread test_thread = null;
63+
6264
// String mName = //!!!!!!!!!!!!!!!!!!!!!!
6365
// "nsk.jdi.ClassType.invokeMethod";
6466

@@ -98,8 +100,8 @@ public static void main (String argv[]) {
98100
//------------------------------------------------------ section tested
99101

100102
case 0:
101-
Thread test_thread =
102-
JDIThreadFactory.newThread(new Threadinvokemethod001a("testedThread"));
103+
test_thread =
104+
JDIThreadFactory.newThread(new Threadinvokemethod001a("testedThread"));
103105
log1(" thread2 is created");
104106

105107
label:

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance001.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -184,6 +184,7 @@ private int runThis (String argv[], PrintStream out) {
184184
}
185185

186186
vm = debuggee.VM();
187+
ReferenceType debuggeeClass = debuggee.classByName(debuggeeName);
187188

188189
//------------------------------------------------------ testing section
189190
log1(" TESTING BEGINS");
@@ -216,8 +217,6 @@ private int runThis (String argv[], PrintStream out) {
216217

217218
String bpLine1 = "breakpointLineNumber1";
218219

219-
List allThreads = null;
220-
ListIterator listIterator = null;
221220
List classes = null;
222221

223222
BreakpointRequest breakpRequest1 = null;
@@ -228,7 +227,6 @@ private int runThis (String argv[], PrintStream out) {
228227

229228
log2("getting ThreadReference object");
230229
try {
231-
allThreads = vm.allThreads();
232230
classes = vm.classesByName(threadClassName);
233231
threadClass = (ReferenceType) classes.get(0);
234232
} catch ( Exception e) {
@@ -237,21 +235,7 @@ private int runThis (String argv[], PrintStream out) {
237235
break label0;
238236
}
239237

240-
241-
log2("......getting Thread thread2 - 1-st argument");
242-
listIterator = allThreads.listIterator();
243-
for (;;) {
244-
try {
245-
thread2 = (ThreadReference) listIterator.next();
246-
if (thread2.name().equals(threadName))
247-
break ;
248-
} catch ( NoSuchElementException e ) {
249-
log3("ERROR: NoSuchElementException for listIterator.next()");
250-
log3("ERROR: NO THREAD2 ?????????!!!!!!!");
251-
expresult = returnCode1;
252-
break label0;
253-
}
254-
}
238+
thread2 = debuggee.threadByFieldNameOrThrow(debuggeeClass, "test_thread", threadName);
255239

256240
log2("setting up a breakpoint");
257241

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance001a.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -59,6 +59,7 @@ private static void logErr(String message) {
5959

6060
//====================================================== test program
6161

62+
static Thread test_thread = null;
6263
static TestClass obj = new TestClass();
6364

6465
//---------------------------------------------------- main method
@@ -96,8 +97,8 @@ public static void main (String argv[]) {
9697
//------------------------------------------------------ section tested
9798

9899
case 0:
99-
Thread test_thread =
100-
JDIThreadFactory.newThread(new Threadnewinstance001a("testedThread"));
100+
test_thread =
101+
JDIThreadFactory.newThread(new Threadnewinstance001a("testedThread"));
101102
log1(" thread2 is created");
102103

103104
label:

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance002.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -181,6 +181,7 @@ private int runThis (String argv[], PrintStream out) {
181181
}
182182

183183
vm = debuggee.VM();
184+
ReferenceType debuggeeClass = debuggee.classByName(debuggeeName);
184185

185186
//------------------------------------------------------ testing section
186187
log1(" TESTING BEGINS");
@@ -213,8 +214,6 @@ private int runThis (String argv[], PrintStream out) {
213214

214215
String bpLine1 = "breakpointLineNumber1";
215216

216-
List allThreads = null;
217-
ListIterator listIterator = null;
218217
List classes = null;
219218

220219
BreakpointRequest breakpRequest1 = null;
@@ -225,7 +224,6 @@ private int runThis (String argv[], PrintStream out) {
225224

226225
log2("getting ThreadReference object");
227226
try {
228-
allThreads = vm.allThreads();
229227
classes = vm.classesByName(threadClassName);
230228
threadClass = (ReferenceType) classes.get(0);
231229
} catch ( Exception e) {
@@ -234,20 +232,7 @@ private int runThis (String argv[], PrintStream out) {
234232
break label0;
235233
}
236234

237-
238-
listIterator = allThreads.listIterator();
239-
for (;;) {
240-
try {
241-
thread2 = (ThreadReference) listIterator.next();
242-
if (thread2.name().equals(threadName))
243-
break ;
244-
} catch ( NoSuchElementException e ) {
245-
log3("ERROR: NoSuchElementException for listIterator.next()");
246-
log3("ERROR: NO THREAD2 ?????????!!!!!!!");
247-
expresult = returnCode1;
248-
break label0;
249-
}
250-
}
235+
thread2 = debuggee.threadByFieldNameOrThrow(debuggeeClass, "test_thread", threadName);
251236

252237
log2("setting up a breakpoint");
253238

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance002a.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -60,6 +60,7 @@ private static void logErr(String message) {
6060

6161
//====================================================== test program
6262

63+
static Threadnewinstance002a test_thread = null;
6364
// static TestClass obj = new TestClass();
6465

6566
//---------------------------------------------------- main method
@@ -97,7 +98,7 @@ public static void main (String argv[]) {
9798
//------------------------------------------------------ section tested
9899

99100
case 0:
100-
Threadnewinstance002a test_thread =
101+
test_thread =
101102
new Threadnewinstance002a("testedThread");
102103
log1(" thread2 is created");
103104

test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/getValue/getvalue001.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -168,6 +168,7 @@ private int runThis (String argv[], PrintStream out) {
168168
}
169169

170170
vm = debuggee.VM();
171+
ReferenceType debuggeeClass = debuggee.classByName(debuggeeName);
171172

172173
//------------------------------------------------------ testing section
173174
log1(" TESTING BEGINS");
@@ -199,8 +200,6 @@ private int runThis (String argv[], PrintStream out) {
199200
String breakpointMethod1 = "runt1";
200201
String bpLine1 = "breakpointLineNumber1";
201202

202-
List allThreads = null;
203-
ListIterator listIterator = null;
204203
List classes = null;
205204

206205
BreakpointRequest breakpRequest1 = null;
@@ -211,7 +210,6 @@ private int runThis (String argv[], PrintStream out) {
211210

212211
log2("getting ThreadReference object");
213212
try {
214-
allThreads = vm.allThreads();
215213
classes = vm.classesByName(testedClassName);
216214
testedClass = (ReferenceType) classes.get(0);
217215
} catch ( Exception e) {
@@ -220,19 +218,7 @@ private int runThis (String argv[], PrintStream out) {
220218
break label0;
221219
}
222220

223-
listIterator = allThreads.listIterator();
224-
for (;;) {
225-
try {
226-
thread2 = (ThreadReference) listIterator.next();
227-
if (thread2.name().equals(threadName))
228-
break ;
229-
} catch ( NoSuchElementException e ) {
230-
log3("ERROR: NoSuchElementException for listIterator.next()");
231-
log3("ERROR: NO THREAD2 ?????????!!!!!!!");
232-
expresult = returnCode1;
233-
break label0;
234-
}
235-
}
221+
thread2 = debuggee.threadByFieldNameOrThrow(debuggeeClass, "test_thread", threadName);
236222

237223
log2("setting up a breakpoint");
238224

test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/getValue/getvalue001a.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -58,6 +58,9 @@ private static void logErr(String message) {
5858
}
5959

6060
//====================================================== test program
61+
62+
static Thread test_thread = null;
63+
6164
//---------------------------------------------------- main method
6265

6366
public static void main (String argv[]) {
@@ -93,8 +96,8 @@ public static void main (String argv[]) {
9396
//------------------------------------------------------ section tested
9497

9598
case 0:
96-
Thread test_thread =
97-
JDIThreadFactory.newThread(new Threadgetvalue001a("testedThread"));
99+
test_thread =
100+
JDIThreadFactory.newThread(new Threadgetvalue001a("testedThread"));
98101
log1(" thread2 is created");
99102

100103
label:

test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/getValue/getvalue002.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -172,6 +172,7 @@ private int runThis (String argv[], PrintStream out) {
172172
}
173173

174174
vm = debuggee.VM();
175+
ReferenceType debuggeeClass = debuggee.classByName(debuggeeName);
175176

176177
//------------------------------------------------------ testing section
177178
log1(" TESTING BEGINS");
@@ -204,8 +205,6 @@ private int runThis (String argv[], PrintStream out) {
204205

205206
String bpLine1 = "breakpointLineNumber1";
206207

207-
List allThreads = null;
208-
ListIterator listIterator = null;
209208
List classes = null;
210209

211210
BreakpointRequest breakpRequest1 = null;
@@ -216,7 +215,6 @@ private int runThis (String argv[], PrintStream out) {
216215

217216
log2("getting ThreadReference object");
218217
try {
219-
allThreads = vm.allThreads();
220218
classes = vm.classesByName(threadClassName);
221219
threadClass = (ReferenceType) classes.get(0);
222220
} catch ( Exception e) {
@@ -225,21 +223,7 @@ private int runThis (String argv[], PrintStream out) {
225223
break label0;
226224
}
227225

228-
229-
log2("......getting Thread thread2 - 1-st argument");
230-
listIterator = allThreads.listIterator();
231-
for (;;) {
232-
try {
233-
thread2 = (ThreadReference) listIterator.next();
234-
if (thread2.name().equals(threadName))
235-
break ;
236-
} catch ( NoSuchElementException e ) {
237-
log3("ERROR: NoSuchElementException for listIterator.next()");
238-
log3("ERROR: NO THREAD2 ?????????!!!!!!!");
239-
expresult = returnCode1;
240-
break label0;
241-
}
242-
}
226+
thread2 = debuggee.threadByFieldNameOrThrow(debuggeeClass, "test_thread", threadName);
243227

244228
log2("setting up a breakpoint");
245229

test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/getValue/getvalue002a.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -60,6 +60,7 @@ private static void logErr(String message) {
6060

6161
//====================================================== test program
6262

63+
static getvalue002aThread test_thread = null;
6364
static getvalue002aTestClass obj = new getvalue002aTestClass();
6465

6566
//---------------------------------------------------- main method
@@ -97,8 +98,7 @@ public static void main (String argv[]) {
9798
//------------------------------------------------------ section tested
9899

99100
case 0:
100-
getvalue002aThread test_thread =
101-
new getvalue002aThread("testedThread");
101+
test_thread = new getvalue002aThread("testedThread");
102102
log1(" thread2 is created");
103103

104104
label:

0 commit comments

Comments
 (0)