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

PageRanges(String s) allows a lower bound of a set to be 0

XMLWordPrintable

    • 2d
    • beta2
    • generic
    • generic



      Name: ooR10006 Date: 04/03/2001


      The spec of constructor javax.print.attribute.standard.PageRanges(String members)
      says:
      "public PageRanges(String members)
       Throws:
               IllegalArgumentException - (Unchecked exception) Thrown if members
               does not obey the proper syntax."
      Although "0:22" range obeys members syntax, it doesn't follow the semantics
      of the class, since it is assumed that page ranges may lie between 1 and
      Integer.MAX_VALUE. In accordance with this assumption other constructors
      don't allow the lower bound of a set to be less then 1 throwing
      IllegalArgumentException.
      But PageRanges(String members) allows lower bound of a range to be 0.
      This is incorrect.

      The following simple test shows this:

      import javax.print.attribute.standard.PageRanges;

      public class Test {
          public static void main(String[] args){
              try {
                  PageRanges pr = new PageRanges("0:22");
                  System.out.println("wrong: no exceptions");
              } catch (IllegalArgumentException ie){
                  System.out.println("OKAY: IllegalArgumentException");
              }
          }
      }
               
      Due to this new JCK test fails:
      api/javax_print/attribute/standard/index.html#Ctor[PageRanges0005]

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

            jgodinez Jennifer Godinez (Inactive)
            ovosunw Ovo Ovo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: