Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4911671

ThreadMBean.getThreadCpuTime(long id) does not throw IllegalArgumentException

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      tiger
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description



      Name: viR10068 Date: 08/25/2003


      The description for the methods ThreadMBean.getThreadCpuTime(long id) says:
      "Throws: java.lang.IllegalArgumentException - if id <= 0"
      But jdk1.5.0-b16 does not throw the IllegalArgumentException for invalid id.

      Source code:
      =========================== a.java ====================================
      import java.lang.management.*;
      import java.io.PrintStream;

      class a {
          
          void test() {

              ThreadMBean c = ManagementFactory.getThreadMBean();
              int cnt = 0;
              long [] idArr = {0, -1, -2, (Long.MIN_VALUE + 1), Long.MIN_VALUE};
       
              try {
                  for (int i = 0; i < idArr.length; i++) {
                      try {
                          c.getThreadCpuTime(idArr[i]);
                          System.out.println("Test failed. IllegalArgumentException expected for
      ID = " + idArr[i]);
                      } catch (IllegalArgumentException iae) {
                          cnt++;
                      }
                  }
              } catch (UnsupportedOperationException ue) {
              }
              System.out.println("OKAY");
          }

          public static void main(String argv[]) {
              new a().test();
          }
      }
      =======================================================================
      Execution log:
      % jdk1.5.0-b16/solaris-sparc/bin/javac a.java && jdk1.5.0-b16/solaris-sparc/bin/java
      -showversion a
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b16)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b16, mixed mode)

      Test failed. IllegalArgumentException expected for ID = 0
      Test failed. IllegalArgumentException expected for ID = -1
      Test failed. IllegalArgumentException expected for ID = -2
      Test failed. IllegalArgumentException expected for ID = -9223372036854775807
      Test failed. IllegalArgumentException expected for ID = -9223372036854775808
      OKAY
      %


      ======================================================================

      Name: viR10068 Date: 08/25/2003


      This bug causes the failure of the JCK tests:
      api/java_lang/management/ThreadMBean/index.html#TrdMBean[getThreadMBean0015]
      api/java_lang/management/ThreadMBean/index.html#TrdMBean_MB[getThreadMBean0115]


      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mchung Mandy Chung
              Reporter:
              vivsunw Viv Viv (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: