Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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.");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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.");
}

Expand Down