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

poor doc for javax.swing.SizeSequence.insertEntries

XMLWordPrintable

    • beta2
    • sparc
    • solaris_2.6



      Name: sdC67446 Date: 09/20/99


      The doc for method
          public void insertEntries(int start, int length, int value)
      of class
          javax.swing.SizeSequence
      has some holes in documentation.
      The expected behavior of the method is unclear:

        1) if 'index' == 0 and setSizes(..) has not been called previously
        2) if 'index' != 0 and setSizes(..) has not been called previously
        3) if 'length' < 0: 'start' + 'length' >= 0
        4) if 'length' < 0: 'start' + 'length' < 0
        5) if 'index' < 0;
        6) if 'index' > getSizes().length

      Currently all six (except 1 & 3) cases cause the method to throw
      ArrayIndexOutOfBoundsException.

      The doc says:
      ------------------------------------------------------------
       public void insertEntries(int start,
                                int length,
                                int value)

           Adds a contiguous group of entries to this SizeSequence.
           Parameters:
               start - the index to be assigned to the first entry in the group
               length - the number of entries in the group
               value - the size to be assigned to each new entry

      The demo test:
      ------------------------------------------------------------
      import javax.swing.SizeSequence;
      public class Test {
          static void test(int caseno,
                           SizeSequence ss,
                           int index,
                           int length,
                           int size) {
              try {
                  ss.insertEntries(index,length,size);
              } catch (ArrayIndexOutOfBoundsException e) {
                  System.out.println(caseno+") "+e);
              }
          }

          public static void main(String argv[]) {
              int[] sizes = {1000, 2000, 3000};

              SizeSequence ss = new SizeSequence();
              test(1,ss,0,1,1999);

              ss = new SizeSequence();
              test(2,ss,1,1,1999);

              ss = new SizeSequence();
              ss.setSizes(sizes);
              test(3,ss,1,-1,1999);

              ss = new SizeSequence();
              ss.setSizes(sizes);
              test(4,ss,1,-2,1999);

              ss = new SizeSequence();
              ss.setSizes(sizes);
              test(5,ss,-1,1,1999);

              ss = new SizeSequence();
              ss.setSizes(sizes);
              test(6,ss,ss.getSizes().length+1,1,1999);
          }
      }

      Output:
      ------------------------------------------------------------
      2) java.lang.ArrayIndexOutOfBoundsException
      4) java.lang.ArrayIndexOutOfBoundsException
      5) java.lang.ArrayIndexOutOfBoundsException
      6) java.lang.ArrayIndexOutOfBoundsException

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

            sharonz Sharon Zakhour (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: