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

Doc probs in java.awt.image.ComponentSampleModel

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • P4
    • None
    • 1.4.0
    • docs
    • generic
    • generic

    Description



      Name: naC79102 Date: 11/23/2000


      Several methods in java.awt.image.ComponentSampleModel state that "An
      ArrayIndexOutOfBoundsException might be thrown if the
      coordinates are not in bounds." but the actual algorithm to reproduce
      the condition which will produce this Exception is not mentioned.
      Exception is not thrown when x,y < 0, but some other condition is
      satisfied (presumabily when y*scanlineStride + x*pixelStride +
      bandOffsets[band] < 0).
      The same problem holds true for even the bounds on the width and height.

      Sample code follows....
      package
      javasoft.sqe.tests.api.java.awt.java2d.image.ComponentSampleModel;

      import java.awt.image.ComponentSampleModel;
      import java.awt.image.DataBufferInt;
      import java.awt.image.DataBuffer;

      public class test {
      public test() {

       ComponentSampleModel csm = new ComponentSampleModel(
         DataBuffer.TYPE_BYTE,5,5,1,5,
                  new int[]{0,1,2});
          DataBufferInt db = new DataBufferInt(4000,2);
          int b = 5;

         try {
        // x<0
               csm.setSample(-1,25,1,b,db);
               System.out.println("No Exception. ");
         } catch (Exception e) {
           System.out.println("Caught "+e);
         }

         try {
        // y<0
               csm.setSample(25,-1,1,b,db);
               System.out.println("No Exception. ");
         } catch (Exception e) {
           System.out.println("Caught "+e);
         }

         try {
        // y*scanlineStride + x*pixelStride + bandOffsets[b] < 0
         csm.setSample(-1,-1,1,b,db);
         System.out.println("No Exception. ");
       } catch (Exception e) {
        System.out.println("Caught "+e);
       }
      }

      public static void main(String[] args) {
              new test();
      }
      }
      ======================================================================

      Attachments

        Activity

          People

            sharonz Sharon Zakhour (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: