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

ArrayIndexOutOfBoundsException in WritableRaster.setPixels()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P2 P2
    • None
    • 1.2.0, 1.4.0
    • client-libs
    • None
    • 2d
    • generic
    • generic, solaris_2.6

      This bug came in from Germany:
      Using BufferedImage.TYPE_INT_ARGB causes the same exception.
      Changing the size of imgSize (the array dimension) from 262144 down to 10 causes the same exception.
      Same happens on windows-NT (no further information was given).

      The following program demonstrates the bug:
      //---------------------------------------------------------------------
      import java.util.*;
      import java.awt.*;
      import java.awt.image.*;
      import java.awt.geom.*;

      public class test {

      public static void main(String argv[]) {

              test t = new test();
              t.setImg();
      }

      public void setImg() {
              imgSize= iw*ih;
              ar = new int[imgSize];
              for (int i=0;i<imgSize;i++) ar[i]= 0xFF00AABB;

              bi_in = new BufferedImage (iw,ih,
                              BufferedImage.TYPE_INT_RGB);
              in_rs = bi_in.getRaster();

              in_rs.setPixels(0,0,iw,ih,ar); // <---------------------------
      }

      private BufferedImage bi_in = null;
      private WritableRaster in_rs = null;
      int iw = 512;
      int ih = 512;
      int imgSize= 0;
      int i;
      int ar[];

      }
      //---------------------------------------------------------------------

      tomboy% /net/mulder.eng/export/mulder3/jdk12x/sparc/jdk1.2FCS/bin/java -version
      java version "1.2"
      Classic VM (build JDK-1.2-V, green threads, sunwjit)
      tomboy% /net/mulder.eng/export/mulder3/jdk12x/sparc/jdk1.2FCS/bin/javac test.java
      tomboy% /net/mulder.eng/export/mulder3/jdk12x/sparc/jdk1.2FCS/bin/java test
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 262144
              at java.awt.image.SinglePixelPackedSampleModel.setPixels(Compiled Code)
              at java.awt.image.WritableRaster.setPixels(Compiled Code)
              at test.setImg(Compiled Code)
              at test.main(Compiled Code)


      -----------
      Thomas Meissner | Tel: +49-9131-84-8207
      SHS GmbH & CoKG, PACS E | Fax: +49-9131-84-2040
      Henkestr. 127 | Email:
      ###@###.###
      D-91052 Erlangen (Germany)

            jehung Jeannette Hung (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: