8381658: Update nsk/jvmti/scenarios/sampling to better test virtual threads

Reviewed-by: cjplummer, sspitsyn
This commit is contained in:
Leonid Mesnik 2026-04-10 18:21:44 +00:00
parent f7c06959a1
commit 2b716d7b32
61 changed files with 489 additions and 149 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -26,6 +26,7 @@ package nsk.jvmti.scenarios.allocation.AP04;
import java.io.*;
import java.lang.reflect.*;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -114,7 +115,7 @@ public class ap04t001 extends DebugeeClass {
log.display("All objects collected");
log.display("Wait for thread to finish");
joinThread(thread);
joinThread(thread.getThread());
log.display("CASE #" + caseName + " finished.\n");
}
@ -172,7 +173,7 @@ class ap04t001SomeReachachableObjectsIterator implements ap04t001Iterator {
}
/**************************************************************************/
class ap04t001Thread extends Thread {
class ap04t001Thread extends ThreadWrapper {
String name;
ap04t001Iterator iterator;
Wicket startLock;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -26,6 +26,7 @@ package nsk.jvmti.scenarios.allocation.AP04;
import java.io.*;
import java.lang.reflect.*;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -100,7 +101,7 @@ public class ap04t002 extends DebugeeClass {
modified++;
log.display("Wait for completion thread to finish");
joinThread(thread);
joinThread(thread.getThread());
log.display("Cleaning tags and references to objects...");
for (int i = 0; i < OBJ_MAX_COUNT; i++) {
if (root[i] != null) {
@ -166,7 +167,7 @@ class ap04t002SomeReachachableObjectsIterator implements ap04t002Iterator {
}
/**************************************************************************/
class ap04t002Thread extends Thread {
class ap04t002Thread extends ThreadWrapper {
String name;
ap04t002Iterator iterator;
Wicket startLock;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -26,6 +26,7 @@ package nsk.jvmti.scenarios.allocation.AP04;
import java.io.*;
import java.lang.reflect.*;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -98,7 +99,7 @@ public class ap04t003 extends DebugeeClass {
ap04t003Thread thread = startThread( threadName, iterator);
log.display("Wait for thread to finish");
joinThread(thread);
joinThread(thread.getThread());
log.display("Cleaning tags and references to objects...");
for (int i = 0; i < OBJ_MAX_COUNT; i++) {
if (root[i] != null) {
@ -164,7 +165,7 @@ class ap04t003SomeReachachableObjectsIterator implements ap04t003Iterator {
}
/**************************************************************************/
class ap04t003Thread extends Thread {
class ap04t003Thread extends ThreadWrapper {
String name;
ap04t003Iterator iterator;
Wicket startLock;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -30,6 +30,7 @@ import nsk.share.Consts;
import nsk.share.jvmti.ArgumentHandler;
import nsk.share.jvmti.DebugeeClass;
import jdk.test.lib.thread.ThreadWrapper;
public class bi04t002 extends DebugeeClass {
@ -118,7 +119,7 @@ public class bi04t002 extends DebugeeClass {
}
}
class bi04t002b extends Thread {
class bi04t002b extends ThreadWrapper {
Object obj = new Object();
static Object started = new Object();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -28,6 +28,7 @@ import java.util.concurrent.*;
import nsk.share.*;
import nsk.share.jvmti.*;
import jdk.test.lib.thread.ThreadWrapper;
public class tc04t001 extends DebugeeClass {
@ -92,7 +93,7 @@ public class tc04t001 extends DebugeeClass {
/* =================================================================== */
class tc04t001Thread extends Thread {
class tc04t001Thread extends ThreadWrapper {
final static int INCREMENT_LIMIT = 100;
final static int DELAY = 1000;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -27,6 +27,7 @@ import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
import jdk.test.lib.thread.ThreadWrapper;
public class em02t001 extends DebugeeClass {
@ -65,7 +66,7 @@ public class em02t001 extends DebugeeClass {
logger.display("Timeout = " + timeout + " msc.");
for (int i = 0; i < 3; i++) {
debuggeeThread = new em02t001Thread("Debuggee Thread");
debuggeeThread = new em02t001Thread("Debuggee Thread").getThread();
generateEvents();
@ -113,7 +114,7 @@ public class em02t001 extends DebugeeClass {
}
// tested threads
class em02t001Thread extends Thread {
class em02t001Thread extends ThreadWrapper {
public em02t001Thread(String name) {
super(name);

View File

@ -33,6 +33,8 @@ import nsk.share.jvmti.*;
import java.util.*;
import java.math.*;
import jdk.test.lib.thread.ThreadWrapper;
public class em02t003 extends DebugeeClass {
// run test from command line
@ -74,7 +76,7 @@ public class em02t003 extends DebugeeClass {
}
Class<?> loadedClass;
Thread thrd;
ThreadWrapper thrd;
ClassUnloader unloader = new ClassUnloader();
for (int i = 0; i < 3; i++) {
@ -90,7 +92,7 @@ public class em02t003 extends DebugeeClass {
loadedClass = unloader.getLoadedClass();
try {
thrd = (Thread )loadedClass.newInstance();
thrd = ((ThreadWrapper)loadedClass.newInstance());
} catch (Exception e) {
logger.complain("Unexpected exception " + e);
e.printStackTrace();
@ -139,7 +141,7 @@ public class em02t003 extends DebugeeClass {
return status;
}
boolean invokeMethod(Class<?> cls, Thread thrd, String methodName) {
boolean invokeMethod(Class<?> cls, ThreadWrapper thrd, String methodName) {
Method method;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -22,8 +22,9 @@
*/
package nsk.jvmti.scenarios.events.EM02;
import jdk.test.lib.thread.ThreadWrapper;
public class em02t003a extends Thread {
public class em02t003a extends ThreadWrapper {
public void run() {
// invoke methods in a loop to provoke compilation

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -22,8 +22,9 @@
*/
package nsk.jvmti.scenarios.events.EM02;
import jdk.test.lib.thread.ThreadWrapper;
public class em02t005a extends Thread {
public class em02t005a extends ThreadWrapper {
public void em02t005a() {
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -27,6 +27,7 @@ import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
import jdk.test.lib.thread.ThreadWrapper;
public class em02t008 extends DebugeeClass {
@ -55,7 +56,7 @@ public class em02t008 extends DebugeeClass {
int status = Consts.TEST_PASSED;
long timeout = argHandler.getWaitTime() * 60000; // milliseconds
Thread thrd1, thrd2;
ThreadWrapper thrd1, thrd2;
for (int i = 0; i < STEP_NUMBER; i++) {
thrd1 = new em02t008a();
@ -79,7 +80,7 @@ public class em02t008 extends DebugeeClass {
return status;
}
class em02t008a extends Thread{
class em02t008a extends ThreadWrapper {
em02t008a() {
setName("em02t008a");
@ -90,7 +91,7 @@ public class em02t008 extends DebugeeClass {
}
}
class em02t008b extends Thread{
class em02t008b extends ThreadWrapper {
em02t008b() {
setName("em02t008b");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2026, 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
@ -27,6 +27,7 @@ import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
import jdk.test.lib.thread.ThreadWrapper;
public class em05t001 extends DebugeeClass {
@ -95,7 +96,7 @@ public class em05t001 extends DebugeeClass {
/* =================================================================== */
// tested threads
class em05t001Thread extends Thread {
class em05t001Thread extends ThreadWrapper {
public void run() {
// invoke methods in a loop to provoke compilation
for (int i = 0; i < 100; i++) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2026, 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
@ -27,6 +27,7 @@ import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
import jdk.test.lib.thread.ThreadWrapper;
public class em05t002 extends DebugeeClass {
@ -98,7 +99,7 @@ public class em05t002 extends DebugeeClass {
/* =================================================================== */
// tested threads
class em05t002Thread extends Thread {
class em05t002Thread extends ThreadWrapper {
public void run() {
// invoke methods in a loop to provoke compilation
for (int i = 0; i < 100; i++) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -31,6 +31,8 @@ import java.io.File;
import nsk.share.*;
import nsk.share.jvmti.*;
import jdk.test.lib.thread.ThreadWrapper;
/**
* Test executes the following scenario to check events <code>COMPILED_METHOD_LOAD</code>,
* <code>COMPILED_METHOD_UNLOAD</code>:
@ -118,7 +120,7 @@ public class em07t002 extends DebugeeClass {
String path = args[0];
Class<?> loadedClass;
Thread thrd;
ThreadWrapper thrd;
ClassUnloader unloader = new ClassUnloader();
for (int i = 0; i < attempts; i++) {
logger.display("======================================");
@ -136,7 +138,7 @@ public class em07t002 extends DebugeeClass {
loadedClass = unloader.getLoadedClass();
try {
thrd = (Thread )loadedClass.newInstance();
thrd = (ThreadWrapper)loadedClass.newInstance();
} catch (Exception e) {
logger.complain("Unexpected exception " + e);
e.printStackTrace();
@ -170,7 +172,7 @@ public class em07t002 extends DebugeeClass {
return status;
}
boolean invokeMethod(Class<?> cls, Thread thrd, String methodName) {
boolean invokeMethod(Class<?> cls, ThreadWrapper thrd, String methodName) {
Method method;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -22,8 +22,9 @@
*/
package nsk.jvmti.scenarios.events.EM07;
import jdk.test.lib.thread.ThreadWrapper;
public class em07t002a extends Thread {
public class em07t002a extends ThreadWrapper {
public void run() {
// invoke methods in a loop to provoke compilation

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -25,6 +25,7 @@ package nsk.jvmti.scenarios.hotswap.HS101;
import java.io.PrintStream;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -115,7 +116,7 @@ public class hs101t001 extends DebugeeClass {
/* =================================================================== */
class hs101t001Thread extends Thread {
class hs101t001Thread extends ThreadWrapper {
public Wicket startingBarrier = new Wicket();
private volatile boolean flag = true;
public int i;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -25,6 +25,7 @@ package nsk.jvmti.scenarios.hotswap.HS101;
import java.io.PrintStream;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -115,7 +116,7 @@ public class hs101t002 extends DebugeeClass {
/* =================================================================== */
class hs101t002Thread extends Thread {
class hs101t002Thread extends ThreadWrapper {
public Wicket startingBarrier = new Wicket();
private volatile boolean flag = true;
public int i;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -25,6 +25,7 @@ package nsk.jvmti.scenarios.hotswap.HS101;
import java.io.PrintStream;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -115,7 +116,7 @@ public class hs101t003 extends DebugeeClass {
/* =================================================================== */
class hs101t003Thread extends Thread {
class hs101t003Thread extends ThreadWrapper {
public Wicket startingBarrier = new Wicket();
private volatile boolean flag = true;
public int i;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -25,6 +25,7 @@ package nsk.jvmti.scenarios.hotswap.HS101;
import java.io.PrintStream;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -98,7 +99,7 @@ public class hs101t004 extends DebugeeClass {
/* =================================================================== */
class hs101t004Thread extends Thread {
class hs101t004Thread extends ThreadWrapper {
public Wicket startingBarrier = new Wicket();
private volatile boolean flag = true;
public int i;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -25,6 +25,7 @@ package nsk.jvmti.scenarios.hotswap.HS101;
import java.io.PrintStream;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -98,7 +99,7 @@ public class hs101t005 extends DebugeeClass {
/* =================================================================== */
class hs101t005Thread extends Thread {
class hs101t005Thread extends ThreadWrapper {
public Wicket startingBarrier = new Wicket();
private volatile boolean flag = true;
public int i;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -25,6 +25,7 @@ package nsk.jvmti.scenarios.hotswap.HS101;
import java.io.PrintStream;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -98,7 +99,7 @@ public class hs101t006 extends DebugeeClass {
/* =================================================================== */
class hs101t006Thread extends Thread {
class hs101t006Thread extends ThreadWrapper {
public Wicket startingBarrier = new Wicket();
private volatile boolean flag = true;
public int i;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -25,6 +25,7 @@ package nsk.jvmti.scenarios.hotswap.HS101;
import java.io.PrintStream;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -95,7 +96,7 @@ public class hs101t007 extends DebugeeClass {
/* =================================================================== */
class hs101t007Thread extends Thread {
class hs101t007Thread extends ThreadWrapper {
public Wicket startingBarrier = new Wicket();
private volatile boolean flag = true;
public int i;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -25,6 +25,7 @@ package nsk.jvmti.scenarios.hotswap.HS101;
import java.io.PrintStream;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -95,7 +96,7 @@ public class hs101t008 extends DebugeeClass {
/* =================================================================== */
class hs101t008Thread extends Thread {
class hs101t008Thread extends ThreadWrapper {
public Wicket startingBarrier = new Wicket();
private volatile boolean flag = true;
public int i;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -25,6 +25,7 @@ package nsk.jvmti.scenarios.hotswap.HS102;
import java.io.PrintStream;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -150,7 +151,7 @@ public class hs102t001 extends DebugeeClass {
/* =================================================================== */
class hs102t001Thread extends Thread {
class hs102t001Thread extends ThreadWrapper {
public Wicket startingBarrier = new Wicket();
private volatile boolean flag = true;
public int i;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -25,6 +25,7 @@ package nsk.jvmti.scenarios.hotswap.HS102;
import java.io.PrintStream;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -150,7 +151,7 @@ public class hs102t002 extends DebugeeClass {
/* =================================================================== */
class hs102t002Thread extends Thread {
class hs102t002Thread extends ThreadWrapper {
public Wicket startingBarrier = new Wicket();
private volatile boolean flag = true;
public int i;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -22,9 +22,11 @@
*/
package nsk.jvmti.scenarios.hotswap.HS103.hs103t002;
import jdk.test.lib.thread.ThreadWrapper;
import java.util.concurrent.atomic.AtomicInteger;
public class MyThread extends Thread {
public class MyThread extends ThreadWrapper {
public static AtomicInteger ai = new AtomicInteger(0);
public static final int size = 10;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -22,9 +22,11 @@
*/
package nsk.jvmti.scenarios.hotswap.HS103.hs103t002;
import jdk.test.lib.thread.ThreadWrapper;
import java.util.concurrent.atomic.AtomicInteger;
public class MyThread extends Thread {
public class MyThread extends ThreadWrapper {
public static AtomicInteger ai = new AtomicInteger(0);
public static final int size = 10;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -22,9 +22,10 @@
*/
package nsk.jvmti.scenarios.hotswap.HS104.hs104t002;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.Wicket;
public class MyThread extends Thread {
public class MyThread extends ThreadWrapper {
int threadState;
private Wicket wicket;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -22,9 +22,10 @@
*/
package nsk.jvmti.scenarios.hotswap.HS104.hs104t002;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.Wicket;
public class MyThread extends Thread {
public class MyThread extends ThreadWrapper {
int threadState;
private Wicket wicket;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -27,6 +27,7 @@ import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
import jdk.test.lib.thread.ThreadWrapper;
public class hs201t001 extends DebugeeClass {
@ -74,7 +75,7 @@ public class hs201t001 extends DebugeeClass {
timeout = argHandler.getWaitTime() * 60 * 1000; // milliseconds
log.display(">>> starting tested thread");
Thread thread = new hs201t001Thread();
Thread thread = new hs201t001Thread().getThread();
// testing sync
status = checkStatus(status);
@ -130,7 +131,7 @@ public class hs201t001 extends DebugeeClass {
return status;
}
class hs201t001Thread extends Thread {
class hs201t001Thread extends ThreadWrapper {
hs201t001Thread() {
setName("hs201t001Thread");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -28,6 +28,7 @@ import java.util.concurrent.CountDownLatch;
import nsk.share.*;
import nsk.share.jvmti.*;
import jdk.test.lib.thread.ThreadWrapper;
public class hs201t002 extends DebugeeClass {
@ -74,7 +75,8 @@ public class hs201t002 extends DebugeeClass {
timeout = argHandler.getWaitTime() * 60 * 1000; // milliseconds
log.display(">>> starting tested thread");
hs201t002Thread thread = new hs201t002Thread();
hs201t002Thread wrappedThread = new hs201t002Thread();
Thread thread = wrappedThread.getThread();
// testing sync
status = checkStatus(status);
@ -84,12 +86,12 @@ public class hs201t002 extends DebugeeClass {
// setThread(thread) enables JVMTI events, and that can only be done on a live thread,
// so wait until the thread has started.
try {
thread.ready.await();
wrappedThread.ready.await();
} catch (InterruptedException e) {
}
setThread(thread);
thread.go.countDown();
wrappedThread.go.countDown();
while (currentStep != 4) {
try {
@ -148,7 +150,7 @@ public class hs201t002 extends DebugeeClass {
return status;
}
class hs201t002Thread extends Thread {
class hs201t002Thread extends ThreadWrapper {
CountDownLatch ready = new CountDownLatch(1);
CountDownLatch go = new CountDownLatch(1);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -25,6 +25,8 @@ package nsk.jvmti.scenarios.hotswap.HS201;
import java.io.*;
import java.util.*;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.*;
import nsk.share.jvmti.*;
@ -187,7 +189,7 @@ public class hs201t003 extends DebugeeClass {
/**
* Class executing a class to be redefined.
*/
class RedefClassWrapper extends Thread {
class RedefClassWrapper extends ThreadWrapper {
boolean stopMe = false;
RedefClassWrapper() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -21,7 +21,10 @@
* questions.
*/
package nsk.jvmti.scenarios.hotswap.HS202.hs202t001;
public class MyThread extends Thread {
import jdk.test.lib.thread.ThreadWrapper;
public class MyThread extends ThreadWrapper {
MyObject myObject;
public MyThread(MyObject obj) {
this.myObject = obj;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -80,8 +80,8 @@ public class hs202t001 extends RedefineAgent {
add(myObject, 1);
}
myObject.stop(true);
if( popThreadFrame(mt)) {;
resumeThread(mt);
if( popThreadFrame(mt.getThread())) {;
resumeThread(mt.getThread());
} // Popoing will not be possible on ..
mt.join();
state = myObject.getAge();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -21,7 +21,10 @@
* questions.
*/
package nsk.jvmti.scenarios.hotswap.HS202.hs202t001;
public class MyThread extends Thread {
import jdk.test.lib.thread.ThreadWrapper;
public class MyThread extends ThreadWrapper {
MyObject myObject;
public MyThread(MyObject obj) {
this.myObject = obj;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -21,7 +21,10 @@
* questions.
*/
package nsk.jvmti.scenarios.hotswap.HS202.hs202t002;
public class MyThread extends Thread {
import jdk.test.lib.thread.ThreadWrapper;
public class MyThread extends ThreadWrapper {
private int val = 100;
public void run() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -70,15 +70,15 @@ public class hs202t002 extends RedefineAgent {
try {
mt.start();
while (!isThreadSuspended(mt)) {
while (!isThreadSuspended(mt.getThread())) {
Thread.yield();
}
if (!popThreadFrame(mt)) {
if (!popThreadFrame(mt.getThread())) {
throw new RuntimeException("error in popframe operation!");
}
if (!resumeThread(mt)) {
if (!resumeThread(mt.getThread())) {
throw new RuntimeException("error in resuming thread!");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -21,7 +21,10 @@
* questions.
*/
package nsk.jvmti.scenarios.hotswap.HS202.hs202t002;
public class MyThread extends Thread {
import jdk.test.lib.thread.ThreadWrapper;
public class MyThread extends ThreadWrapper {
private int val = 100;
public void run() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -21,8 +21,10 @@
* questions.
*/
package nsk.jvmti.scenarios.hotswap.HS203.hs203t001;
import jdk.test.lib.thread.ThreadWrapper;
import java.util.concurrent.atomic.AtomicBoolean;
public class MyThread extends Thread {
public class MyThread extends ThreadWrapper {
public static AtomicBoolean resume = new AtomicBoolean(false);
public int threadState=100;
public MyThread() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -76,8 +76,8 @@ public class hs203t001 extends RedefineAgent {
mt.start();
while(!MyThread.resume.get());
Thread.sleep(10000);
popThreadFrame(mt);
resumeThread(mt);
popThreadFrame(mt.getThread());
resumeThread(mt.getThread());
mt.join();
log.println(" ..."+mt.threadState);
} catch(Exception ie) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -21,8 +21,10 @@
* questions.
*/
package nsk.jvmti.scenarios.hotswap.HS203.hs203t001;
import jdk.test.lib.thread.ThreadWrapper;
import java.util.concurrent.atomic.AtomicBoolean;
public class MyThread extends Thread {
public class MyThread extends ThreadWrapper {
public static AtomicBoolean resume = new AtomicBoolean(false);
public int threadState=10;
public MyThread() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -21,8 +21,10 @@
* questions.
*/
package nsk.jvmti.scenarios.hotswap.HS203.hs203t002;
import jdk.test.lib.thread.ThreadWrapper;
import java.util.concurrent.atomic.AtomicBoolean;
public class MyThread extends Thread {
public class MyThread extends ThreadWrapper {
public static AtomicBoolean resume = new AtomicBoolean(false);
public static AtomicBoolean resume2 = new AtomicBoolean(false);
public int threadState=100;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -77,14 +77,14 @@ public class hs203t002 extends RedefineAgent {
while(!MyThread.resume.get());
MyThread.resume.set(false);
Thread.sleep(10000);
popThreadFrame(mt);
resumeThread(mt);
popThreadFrame(mt.getThread());
resumeThread(mt.getThread());
while(!MyThread.resume2.get());
Thread.sleep(10000);
suspendThread(mt);
suspendThread(mt.getThread());
//mt.suspend();
popThreadFrame(mt);
resumeThread(mt);
popThreadFrame(mt.getThread());
resumeThread(mt.getThread());
MyThread.resume.set(true);
mt.join();
log.println(" ..."+mt.threadState);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -21,8 +21,10 @@
* questions.
*/
package nsk.jvmti.scenarios.hotswap.HS203.hs203t002;
import jdk.test.lib.thread.ThreadWrapper;
import java.util.concurrent.atomic.AtomicBoolean;
public class MyThread extends Thread {
public class MyThread extends ThreadWrapper {
public static AtomicBoolean resume = new AtomicBoolean(false);
public static AtomicBoolean resume2 = new AtomicBoolean(false);
public int threadState=100;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -22,9 +22,11 @@
*/
package nsk.jvmti.scenarios.hotswap.HS203.hs203t003;
import jdk.test.lib.thread.ThreadWrapper;
import java.util.concurrent.atomic.AtomicBoolean;
public class MyThread extends Thread {
public class MyThread extends ThreadWrapper {
public static AtomicBoolean resume = new AtomicBoolean(false);
public int threadState=0;
// field watch is added on.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -93,7 +93,7 @@ public class hs203t003 extends RedefineAgent {
Thread.sleep(100);
}
// Wait for the thread to be suspended.
while (!isSuspended(mt)) {
while (!isSuspended(mt.getThread())) {
if (!agentStatus()) {
System.out.println("Failed to suspend thread");
return passed;
@ -101,12 +101,12 @@ public class hs203t003 extends RedefineAgent {
Thread.sleep(100);
}
// Pop the frame.
if (!popThreadFrame(mt)) {
if (!popThreadFrame(mt.getThread())) {
System.out.println("Failed to pop a frame = "
+ mt.threadState);
}
// Resume the thread.
if(!resumeThread(mt)) {
if(!resumeThread(mt.getThread())) {
System.out.println("Failed to resume the thread = "
+ mt.threadState);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -22,8 +22,10 @@
*/
package nsk.jvmti.scenarios.hotswap.HS203.hs203t003;
import jdk.test.lib.thread.ThreadWrapper;
import java.util.concurrent.atomic.AtomicBoolean;
public class MyThread extends Thread {
public class MyThread extends ThreadWrapper {
public static AtomicBoolean resume = new AtomicBoolean(false);
public int threadState=100;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -22,7 +22,9 @@
*/
package nsk.jvmti.scenarios.hotswap.HS203.hs203t004;
public class MyThread extends Thread {
import jdk.test.lib.thread.ThreadWrapper;
public class MyThread extends ThreadWrapper {
public static volatile boolean stop = true;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -82,11 +82,11 @@ public class hs203t004 extends RedefineAgent {
Thread.yield();
}
suspendThread(myThread);
suspendThread(myThread.getThread());
popThreadFrame(myThread);
popThreadFrame(myThread.getThread());
resumeThread(myThread);
resumeThread(myThread.getThread());
MyThread.stop = false;
myThread.join();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -23,7 +23,9 @@
package nsk.jvmti.scenarios.hotswap.HS203.hs203t004;
public class MyThread extends Thread {
import jdk.test.lib.thread.ThreadWrapper;
public class MyThread extends ThreadWrapper {
public static volatile boolean stop = true;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -21,7 +21,10 @@
* questions.
*/
package nsk.jvmti.scenarios.hotswap.HS204.hs204t002;
public class MyThread extends Thread{
import jdk.test.lib.thread.ThreadWrapper;
public class MyThread extends ThreadWrapper {
public static int value=100;
static {
System.out.println(" ... Break Point here..");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -21,7 +21,10 @@
* questions.
*/
package nsk.jvmti.scenarios.hotswap.HS204.hs204t002;
public class MyThread extends Thread{
import jdk.test.lib.thread.ThreadWrapper;
public class MyThread extends ThreadWrapper {
public static int value=200;
static {
System.out.println(" ... Break Point here..");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -22,7 +22,9 @@
*/
package nsk.jvmti.scenarios.hotswap.HS204.hs204t003;
public class MyThread extends Thread {
import jdk.test.lib.thread.ThreadWrapper;
public class MyThread extends ThreadWrapper {
private static volatile int intState=100;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -61,6 +61,7 @@
package nsk.jvmti.scenarios.hotswap.HS204.hs204t003;
import nsk.share.jvmti.RedefineAgent;
import jdk.test.lib.thread.ThreadWrapper;
public class hs204t003 extends RedefineAgent {
public native boolean popFrame(Thread thread) ;
@ -82,7 +83,7 @@ public class hs204t003 extends RedefineAgent {
TempThread temp = new TempThread();
temp.start();
Thread.sleep(10000);
popFrame(temp);
popFrame(temp.getThread());
temp.join();
mthread = temp.mthread;
mthread.start();
@ -104,7 +105,7 @@ public class hs204t003 extends RedefineAgent {
return passed;
}
}
class TempThread extends Thread {
class TempThread extends ThreadWrapper {
public MyThread mthread;
public TempThread() {
super("TempThread.");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -21,7 +21,10 @@
* questions.
*/
package nsk.jvmti.scenarios.hotswap.HS204.hs204t003;
public class MyThread extends Thread {
import jdk.test.lib.thread.ThreadWrapper;
public class MyThread extends ThreadWrapper {
private static volatile int intState=0;
public static int count=100;
static {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2026, 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
@ -51,6 +51,8 @@
package nsk.jvmti.scenarios.hotswap.HS204.hs204t004;
import java.util.concurrent.atomic.AtomicBoolean;
import jdk.test.lib.thread.ThreadWrapper;
import nsk.share.jvmti.RedefineAgent;
public class hs204t004 extends RedefineAgent {
@ -71,7 +73,7 @@ public class hs204t004 extends RedefineAgent {
mt.start();
while(!MyThread.resume.get()) ;
Thread.sleep(10000);
popFrame(mt);
popFrame(mt.getThread());
mt.join();
} catch(Exception exp) {
exp.printStackTrace();
@ -88,7 +90,7 @@ public class hs204t004 extends RedefineAgent {
public static native boolean popFrame(Thread thread);
}
class MyThread extends Thread {
class MyThread extends ThreadWrapper {
public static AtomicBoolean resume = new AtomicBoolean(false);
public String name="MyThread";

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2026, 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
@ -27,6 +27,7 @@ import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
import jdk.test.lib.thread.ThreadWrapper;
public class ma03t001 extends DebugeeClass {
@ -79,7 +80,7 @@ public class ma03t001 extends DebugeeClass {
/* =================================================================== */
class ma03t001Thread extends Thread {
class ma03t001Thread extends ThreadWrapper {
public Wicket startingBarrier = new Wicket();
public Wicket endingBarrier = new Wicket();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2026, 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
@ -28,6 +28,8 @@ import java.io.PrintStream;
import nsk.share.*;
import nsk.share.jvmti.*;
import jdk.test.lib.thread.ThreadWrapper;
public class sp01t001 extends DebugeeClass {
// run test from command line
@ -51,7 +53,8 @@ public class sp01t001 extends DebugeeClass {
int status = Consts.TEST_PASSED;
// tested threads list
static sp01t001Thread threads[] = null;
static sp01t001Thread threadWrappers[] = null;
static Thread threads[] = null;
static int indexStartedThread = 0;
// run debuggee class
@ -60,21 +63,25 @@ public class sp01t001 extends DebugeeClass {
log = new Log(out, argHandler);
// create threads list
threads = new sp01t001Thread[] {
threadWrappers = new sp01t001Thread[] {
// not started thread
new sp01t001ThreadNotStarted(),
// started threads
new sp01t001ThreadFinished()
};
threads = new Thread[] {
threadWrappers[0].getThread(),
threadWrappers[1].getThread()
};
indexStartedThread = 1;
// run threads
try {
// start threads
for (int i = indexStartedThread; i < threads.length; i++) {
synchronized (threads[i].startingMonitor) {
synchronized (threadWrappers[i].startingMonitor) {
threads[i].start();
threads[i].startingMonitor.wait();
threadWrappers[i].startingMonitor.wait();
}
}
@ -98,7 +105,7 @@ public class sp01t001 extends DebugeeClass {
/* =================================================================== */
// basic class for tested threads
abstract class sp01t001Thread extends Thread {
abstract class sp01t001Thread extends ThreadWrapper {
public Object startingMonitor = new Object();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2026, 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
@ -34,7 +34,7 @@ extern "C" {
/* constant names */
#define DEBUGEE_CLASS_NAME "nsk/jvmti/scenarios/sampling/SP01/sp01t001"
#define THREAD_CLASS_NAME "nsk/jvmti/scenarios/sampling/SP01/sp01t001Thread"
#define THREAD_CLASS_NAME "java/lang/Thread"
#define THREADS_FIELD_NAME "threads"
#define THREADS_FIELD_SIG "[L" THREAD_CLASS_NAME ";"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, 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
@ -63,6 +63,8 @@ public class ExtraClassesBuilder {
JDKToolLauncher javac = JDKToolLauncher.create("javac")
.addToolArg("-d")
.addToolArg(dst.toString())
.addToolArg("-sourcepath")
.addToolArg(Utils.TEST_SRC_PATH)
.addToolArg("-cp")
.addToolArg(Utils.TEST_CLASS_PATH);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2026, 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
@ -105,6 +105,11 @@ public final class Utils {
*/
public static final String TEST_SRC = System.getProperty("test.src", "").trim();
/**
* Returns the value of 'test.src.path' system property.
*/
public static final String TEST_SRC_PATH = System.getProperty("test.src.path", "").trim();
/**
* Returns the value of 'test.root' system property.
*/

View File

@ -0,0 +1,246 @@
/*
* Copyright (c) 2026, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.test.lib.thread;
import java.time.Duration;
import java.util.Map;
/*
The ThreadWrapper is a helper class that allows to extend
coverage of virtual threads testing for existing tests with threads.
Specifically, it is useful for the pattern where Thread is extended
by some class. Example:
class resumethrd02Thread extends Thread {...}
...
resumethrd02Thread thr = new resumethrd02Thread();
The test can be updated to use this wrapper:
class resumethrd02Thread extends ThreadWrapper {...}
...
resumethrd02Thread thr = new resumethrd02Thread();
So resumethrd02Thread can be run with platform or virtual threads.
Method getThread() is used to get instance of Thread.
It is not expected to use this wrapper for new tests or classes that
are not extending Thread. The TestThreadFactory should be used to
create threads in such cases.
*/
public class ThreadWrapper implements Runnable {
private final Thread thread;
@SuppressWarnings("this-escape")
public ThreadWrapper() {
// thread is a platform or virtual thread
thread = TestThreadFactory.newThread(this);
}
@SuppressWarnings("this-escape")
public ThreadWrapper(String name) {
// thread is a platform or virtual thread
thread = TestThreadFactory.newThread(this, name);
}
public Thread getThread() {
return thread;
}
public static Thread currentThread() {
return Thread.currentThread();
}
public static void yield() {
Thread.yield();
}
public static void sleep(long millis) throws InterruptedException {
Thread.sleep(millis);
}
public static void sleep(long millis, int nanos) throws InterruptedException {
Thread.sleep(millis, nanos);
}
public static void sleep(Duration duration) throws InterruptedException {
Thread.sleep(duration);
}
public static void onSpinWait() {
Thread.onSpinWait();
}
public static Thread.Builder.OfPlatform ofPlatform() {
return Thread.ofPlatform();
}
public static Thread.Builder.OfVirtual ofVirtual() {
return Thread.ofVirtual();
}
public static Thread startVirtualThread(Runnable task) {
return Thread.startVirtualThread(task);
}
public boolean isVirtual() {
return thread.isVirtual();
}
public void start() {
thread.start();
}
public void run() {
}
public void interrupt() {
thread.interrupt();
}
public static boolean interrupted() {
return Thread.interrupted();
}
public boolean isInterrupted() {
return thread.isInterrupted();
}
public boolean isAlive() {
return thread.isAlive();
}
public void setPriority(int newPriority) {
thread.setPriority(newPriority);
}
public int getPriority() {
return thread.getPriority();
}
public void setName(String name) {
thread.setName(name);
}
public String getName() {
return thread.getName();
}
public ThreadGroup getThreadGroup() {
return thread.getThreadGroup();
}
public static int activeCount() {
return Thread.activeCount();
}
public static int enumerate(Thread[] tarray) {
return Thread.enumerate(tarray);
}
public void join(long millis) throws InterruptedException {
thread.join(millis);
}
public void join(long millis, int nanos) throws InterruptedException {
thread.join(millis, nanos);
}
public void join() throws InterruptedException {
thread.join();
}
public boolean join(Duration duration) throws InterruptedException {
return thread.join(duration);
}
public static void dumpStack() {
Thread.dumpStack();
}
public void setDaemon(boolean on) {
thread.setDaemon(on);
}
public boolean isDaemon() {
return thread.isDaemon();
}
@Override
public String toString() {
return thread.toString();
}
public ClassLoader getContextClassLoader() {
return thread.getContextClassLoader();
}
public void setContextClassLoader(ClassLoader cl) {
thread.setContextClassLoader(cl);
}
public static boolean holdsLock(Object obj) {
return Thread.holdsLock(obj);
}
public StackTraceElement[] getStackTrace() {
return thread.getStackTrace();
}
public static Map<Thread, StackTraceElement[]> getAllStackTraces() {
return Thread.getAllStackTraces();
}
@Deprecated(since = "19")
public long getId() {
return thread.getId();
}
public long threadId() {
return thread.threadId();
}
public Thread.State getState() {
return thread.getState();
}
public static void setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler ueh) {
Thread.setDefaultUncaughtExceptionHandler(ueh);
}
public static Thread.UncaughtExceptionHandler getDefaultUncaughtExceptionHandler() {
return Thread.getDefaultUncaughtExceptionHandler();
}
public Thread.UncaughtExceptionHandler getUncaughtExceptionHandler() {
return thread.getUncaughtExceptionHandler();
}
public void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler ueh) {
thread.setUncaughtExceptionHandler(ueh);
}
}