-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b25
-
generic
-
generic
Name: viR10068 Date: 09/28/2003
The description for the methods ThreadMBean.getThreadCpuTime(long id) says:
" If the thread of the specified ID is not alive or does not exist,
this method returns -1."
But jdk1.5.0-b21 throws the IllegalArgumentException in these cases.
Note, the jdk1.5.0-b20 returns -1 so it is may be a side effect of the
bug 4911671 integration.
Source code:
=========================== getTMB12.java ====================================
mport java.io.PrintStream;
import java.lang.management.*;
public class getTMB12 {
public static int run(String argv[], PrintStream out) {
ThreadMBean c = ManagementFactory.getThreadMBean();
Thread trd1 = new Thread(), trd2 = new Thread(), trd3 = new Thread();
long [] idArr = {trd1.getId(), trd2.getId(), trd3.getId()};
try {
trd3.setDaemon(!trd3.isDaemon());
trd2.start(); trd3.start();
trd2.join(); trd3.join();
} catch (InterruptedException ie) {
out.println("Unexpected exception" + ie);
return 1;
}
try {
if (!c.isThreadCpuTimeEnabled()) {
c.setThreadCpuTimeEnabled(true);
}
for (int i = 0; i < idArr.length; i++) {
out.println("info for thread ID " + idArr[i]);
if (c.getThreadCpuTime(idArr[i]) != -1) {
out.println("incorrect thread's CPU time for ID = " + idArr[i]);
return 1;
}
}
} catch (UnsupportedOperationException ue) {
out.println("Passed with UnsupportedOperationException");
}
out.println("OKAY");
return 0;
}
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
}
=======================================================================
Execution log:
% javac getTMB12.java && jdk1.5.0-b21/solaris-sparc/bin/java -showversion getTMB12
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b21)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b21, mixed mode)
info for thread ID 7
Exception in thread "main" java.lang.IllegalArgumentException: Invalid thread ID
at sun.management.ThreadImpl.getThreadCpuTime0(Native Method)
at sun.management.ThreadImpl.getThreadCpuTime(ThreadImpl.java:209)
at getTMB12.run(getTMB12.java:27)
at getTMB12.main(getTMB12.java:40)
%
======================================================================
- duplicates
-
JDK-4931356 REGRESSION: JCK1.5 api/java_lang/management/ThreadMBean/index.html#TrdMBean fail
-
- Closed
-
-
JDK-4931357 REGRESSION: JCK1.5 api/java_lang/management/ThreadMBean/index.html#TrdMBean_MB
-
- Closed
-
- relates to
-
JDK-4911671 ThreadMBean.getThreadCpuTime(long id) does not throw IllegalArgumentException
-
- Closed
-