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

(thread) ThreadGroup.setMaxPriority changes priority if param is out of range

    Details

    • Subcomponent:
    • Resolved In Build:
      b15
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Not verified

      Backports

        Description

        Name: skR10005 Date: 06/26/2002


        The API spec for method ThreadGroup.setMaxPriopity reads

          If the pri argument is less than Thread.MIN_PRIORITY or greater than
          Thread.MAX_PRIORITY, the maximum priority of the group remains unchanged.

        The new JCK test
        api/java_lang/ThreadGroup/setMaxPriority01/setMaxPriority0105/setMaxPriority0105.html
        checks this assertion. However, this test failed under all previous
        JDK versions up to JDK 1.4.1-rc.

        To reproduce this failure, a simple example can be used:
        =================setMaxPriority0105.java=================
        import java.io.PrintStream;

        public class setMaxPriority0105 {

            public void run(String argv[], PrintStream log, PrintStream out) {

                ThreadGroup thg = new ThreadGroup("setMaxPriority0105");
                int prio = thg.getMaxPriority();
                thg.setMaxPriority(Thread.MIN_PRIORITY - 1);
                if(prio != thg.getMaxPriority()) {
                    out.println("thread group priority is changed:" +
                            prio + "-" + thg.getMaxPriority());
                }

            }

            public static void main(String args[]) {
             (new setMaxPriority0105()).run(args, System.err, System.out);
            }

        }
        ========================================================
        The log of execution is following:
        $ javac -d . setMaxPriority0105.java
        $ java -version
        java version "1.4.1-rc"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b15)
        Java HotSpot(TM) Client VM (build 1.4.1-rc-b15, mixed mode)
        $ $ java -cp . setMaxPriority0105
        thread group priority is changed:10-1

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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  psoper Pete Soper (Inactive)
                  Reporter:
                  serjsunw Serj Serj (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: