From 88e4766c9f1b9aeadcbca6e1190e31197012b648 Mon Sep 17 00:00:00 2001 From: duke Date: Mon, 8 Dec 2025 06:25:04 +0000 Subject: [PATCH] Backport b0f59f6021a00dc569e08810b34db21553a5b68d --- .../from/from001/TestDescription.java | 3 +- .../from_c/from_c001/TestDescription.java | 3 +- .../getlockname001/TestDescription.java | 3 +- .../getlockownername001/TestDescription.java | 3 +- .../isinnative001/TestDescription.java | 3 +- .../BaseBehaviorTest.java | 70 +++++++++++++------ .../GetThreadCpuTime/BaseBehaviorTest.java | 42 +++++++---- 7 files changed, 87 insertions(+), 40 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryUsage/from/from001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryUsage/from/from001/TestDescription.java index a066b636bb3..083e91243e8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryUsage/from/from001/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryUsage/from/from001/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -43,6 +43,7 @@ * 5014783 Move ThreadState class from java.lang.management to java.lang * 5024531 Fix MBeans design flaw that restricts to use JMX CompositeData * + * @requires test.thread.factory != "Virtual" * @library /vmTestbase * /test/lib * @run main/othervm nsk.monitoring.MemoryUsage.from.from001 -testMode=server diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/from_c/from_c001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/from_c/from_c001/TestDescription.java index 9ff6e066fe1..6483673deef 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/from_c/from_c001/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/from_c/from_c001/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -43,6 +43,7 @@ * 5014783 Move ThreadState class from java.lang.management to java.lang * 5024531 Fix MBeans design flaw that restricts to use JMX CompositeData * + * @requires test.thread.factory != "Virtual" * @library /vmTestbase * /test/lib * @run main/othervm nsk.monitoring.ThreadInfo.from_c.from_c001 -testMode=server -MBeanServer=custom diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockName/getlockname001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockName/getlockname001/TestDescription.java index 571f121beac..8e956e98929 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockName/getlockname001/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockName/getlockname001/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -47,6 +47,7 @@ * Updated according to: * 5024531 Fix MBeans design flaw that restricts to use JMX CompositeData * + * @requires test.thread.factory != "Virtual" * @library /vmTestbase * /test/lib * @run main/othervm nsk.monitoring.ThreadInfo.getLockName.getlockname001 diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockOwnerName/getlockownername001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockOwnerName/getlockownername001/TestDescription.java index 1b2e7d90eb2..0cc78a6ad97 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockOwnerName/getlockownername001/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/getLockOwnerName/getlockownername001/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -42,6 +42,7 @@ * Updated according to: * 5024531 Fix MBeans design flaw that restricts to use JMX CompositeData * + * @requires test.thread.factory != "Virtual" * @library /vmTestbase * /test/lib * @run main/othervm nsk.monitoring.ThreadInfo.getLockOwnerName.getlockownername001 diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/isInNative/isinnative001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/isInNative/isinnative001/TestDescription.java index a411958c852..3cce37baa4d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/isInNative/isinnative001/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadInfo/isInNative/isinnative001/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -41,6 +41,7 @@ * Updated according to: * 5024531 Fix MBeans design flaw that restricts to use JMX CompositeData * + * @requires test.thread.factory != "Virtual" * @library /vmTestbase * /test/lib * @run main/othervm nsk.monitoring.ThreadInfo.isInNative.isinnative001 diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/BaseBehaviorTest.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/BaseBehaviorTest.java index bc0af5ae1cd..c338d392416 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/BaseBehaviorTest.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadAllocatedBytes/BaseBehaviorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -59,16 +59,30 @@ public void run() { + "return -1 if ThreadAllocatedMemoryEnabled is set to false. " + "Received : " + result); threadMXBean.setThreadAllocatedMemoryEnabled(true); - // Expect >= 0 value for current thread + // Expect >= 0 value for current platform thread. result = threadMXBean.getCurrentThreadAllocatedBytes(); - if (result < 0) - throw new TestFailure("Failure! getCurrentThreadAllocatedBytes() should " - + "return >= 0 value for current thread. Received : " + result); - // Expect >= 0 value for current thread from getThreadAllocatedBytes(id) + if (Thread.currentThread().isVirtual()) { + if (result != -1) + throw new TestFailure("Failure! getCurrentThreadAllocatedBytes() should " + + "return -1 for virtual thread. " + + "Received : " + result); + } else { + if (result < 0) + throw new TestFailure("Failure! getCurrentThreadAllocatedBytes() should " + + "return >= 0 value for current thread. Received : " + result); + } + // Expect >= 0 value for current iplatform thread from getThreadAllocatedBytes(id). result = threadMXBean.getThreadAllocatedBytes(Thread.currentThread().getId()); - if (result < 0) - throw new TestFailure("Failure! getThreadAllocatedBytes(id) should " - + "return >= 0 value for current thread. Received : " + result); + if (Thread.currentThread().isVirtual()) { + if (result != -1) + throw new TestFailure("Failure! getThreadAllocatedBytes(id) should " + + "return -1 for virtual thread. " + + "Received : " + result); + } else { + if (result < 0) + throw new TestFailure("Failure! getThreadAllocatedBytes(id) should " + + "return >= 0 value for current thread. Received : " + result); + } MXBeanTestThread thread = new MXBeanTestThread(); long id = thread.getId(); @@ -79,11 +93,11 @@ public void run() { result = threadMXBean.getThreadAllocatedBytes(id); if (result != -1) throw new TestFailure("Failure! getThreadAllocatedBytes(long id) should " - + "return -1 for not started threads. Recieved : " + result); + + "return -1 for not started threads. Received : " + result); resultArr = threadMXBean.getThreadAllocatedBytes(idArr); if (resultArr[0] != -1) throw new TestFailure("Failure! getThreadAllocatedBytes(long[] ids) should " - + "return -1 for not started threads. Recieved : " + resultArr[0]); + + "return -1 for not started threads. Received : " + resultArr[0]); BarrierHandler handler = startThreads(thread); try { handler.proceed(); @@ -93,23 +107,37 @@ public void run() { if (result != -1) throw new TestFailure("Failure! getThreadAllocatedBytes(long id) should " + "return -1 if ThreadAllocatedMemoryEnabled is set to false. " - + "Recieved : " + result); + + "Received : " + result); resultArr = threadMXBean.getThreadAllocatedBytes(idArr); if (resultArr[0] != -1) throw new TestFailure("Failure! getThreadAllocatedBytes(long[] ids) should " + "return -1 if ThreadAllocatedMemoryEnabled is set to false. " - + "Recieved : " + resultArr[0]); + + "Received : " + resultArr[0]); threadMXBean.setThreadAllocatedMemoryEnabled(true); // Expect >= 0 value for running threads result = threadMXBean.getThreadAllocatedBytes(id); - if (result < 0) - throw new TestFailure("Failure! getThreadAllocatedBytes(long id) should " - + "return > 0 value for RUNNING thread. Recieved : " + result); + if (thread.isVirtual()) { + if (result != -1) + throw new TestFailure("Failure! getThreadAllocatedBytes(long id) should " + + "return -1 for virtual thread. " + + "Received : " + result); + } else { + if (result < 0) + throw new TestFailure("Failure! getThreadAllocatedBytes(long id) should " + + "return > 0 value for RUNNING thread. Received : " + result); + } resultArr = threadMXBean.getThreadAllocatedBytes(idArr); - if (resultArr[0] < 0) - throw new TestFailure("Failure! getThreadAllocatedBytes(long[] ids) should " - + "return > 0 value for RUNNING thread. Recieved : " + resultArr[0]); + if (thread.isVirtual()) { + if (resultArr[0] != -1) + throw new TestFailure("Failure! getThreadAllocatedBytes(long[] ids) should " + + "return -1 for virtual thread. " + + "Received : " + resultArr[0]); + } else { + if (resultArr[0] < 0) + throw new TestFailure("Failure! getThreadAllocatedBytes(long[] ids) should " + + "return > 0 value for RUNNING thread. Received : " + resultArr[0]); + } } finally { // Let thread finish handler.finish(); @@ -121,11 +149,11 @@ public void run() { result = threadMXBean.getThreadAllocatedBytes(id); if (result != -1) throw new TestFailure("Failure! getThreadAllocatedBytes(long id) should " - + "return -1 for finished threads. Recieved : " + result); + + "return -1 for finished threads. Received : " + result); resultArr = threadMXBean.getThreadAllocatedBytes(idArr); if (resultArr[0] != -1) throw new TestFailure("Failure! getThreadAllocatedBytes(long[] ids) should " - + "return -1 for finished threads. Recieved : " + resultArr[0]); + + "return -1 for finished threads. Received : " + resultArr[0]); log.info("BaseBehaviorTest passed."); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/BaseBehaviorTest.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/BaseBehaviorTest.java index 5a16a1ba815..d639ba8b825 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/BaseBehaviorTest.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/ThreadMXBean/GetThreadCpuTime/BaseBehaviorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -57,11 +57,11 @@ public void run() { resultArr = threadMXBean.getThreadCpuTime(idArr); if (resultArr[0] != -1) throw new TestFailure("Failure! getThreadCpuTime(long[] ids) should " - + "return -1 for not started threads. Recieved : " + resultArr[0]); + + "return -1 for not started threads. Received : " + resultArr[0]); resultArr = threadMXBean.getThreadUserTime(idArr); if (resultArr[0] != -1) throw new TestFailure("Failure! getThreadUserTime(long[] ids) should " - + "return -1 for not started threads. Recieved : " + resultArr[0]); + + "return -1 for not started threads. Received : " + resultArr[0]); BarrierHandler handler = startThreads(thread); try { handler.proceed(); @@ -71,22 +71,36 @@ public void run() { if (resultArr[0] != -1) throw new TestFailure("Failure! getThreadCpuTime(long[] ids) should " + "return -1 if threadCpuTimeEnabled is set to false. " - + "Recieved : " + resultArr[0]); + + "Received : " + resultArr[0]); resultArr = threadMXBean.getThreadUserTime(idArr); if (resultArr[0] != -1) throw new TestFailure("Failure! getThreadUserTime(long[] ids) should " + "return -1 if threadCpuTimeEnabled is set to false. " - + "Recieved : " + resultArr[0]); + + "Received : " + resultArr[0]); threadMXBean.setThreadCpuTimeEnabled(true); - // Expect > 0 value for running threads + // Expect > 0 value for running platform threads and -1 for virtual threads. resultArr = threadMXBean.getThreadCpuTime(idArr); - if (resultArr[0] < 0) - throw new TestFailure("Failure! getThreadCpuTime(long[] ids) should " - + "return > 0 value for RUNNING thread. Recieved : " + resultArr[0]); + if (thread.isVirtual()) { + if (resultArr[0] != -1) + throw new TestFailure("Failure! getThreadCpuTime(long[] ids) should " + + "return -1 for virtual threads." + + "Received : " + resultArr[0]); + } else { + if (resultArr[0] < 0) + throw new TestFailure("Failure! getThreadCpuTime(long[] ids) should " + + "return > 0 value for RUNNING thread. Received : " + resultArr[0]); + } resultArr = threadMXBean.getThreadUserTime(idArr); - if (resultArr[0] < 0) - throw new TestFailure("Failure! getThreadUserTime(long[] ids) should " - + "return > 0 value for RUNNING thread. Recieved : " + resultArr[0]); + if (thread.isVirtual()) { + if (resultArr[0] != -1) + throw new TestFailure("Failure! getThreadUserTime(long[] ids) should " + + "return -1 for virtual threads." + + "Received : " + resultArr[0]); + } else { + if (resultArr[0] < 0) + throw new TestFailure("Failure! getThreadUserTime(long[] ids) should " + + "return > 0 value for RUNNING thread. Received : " + resultArr[0]); + } } finally { // Let thread finish handler.finish(); @@ -98,11 +112,11 @@ public void run() { resultArr = threadMXBean.getThreadCpuTime(idArr); if (resultArr[0] != -1) throw new TestFailure("Failure! getThreadCpuTime(long[] ids) should " - + "return -1 for finished threads. Recieved : " + resultArr[0]); + + "return -1 for finished threads. Received : " + resultArr[0]); resultArr = threadMXBean.getThreadUserTime(idArr); if (resultArr[0] != -1) throw new TestFailure("Failure! getThreadUserTime(long[] ids) should " - + "return -1 for finished threads. Recieved : " + resultArr[0]); + + "return -1 for finished threads. Received : " + resultArr[0]); log.info("BaseBehaviorTest passed."); }