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

java.awt.image.DirectColorModel exception does not match javadoc

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs
    • 2d
    • generic
    • generic



      Name: naC79102 Date: 07/14/99

      =
      java.awt.image.DirectColorModel.createCompatibleWritableRaster(int
      w,int h) - The specs state that an IllegalArgumentException is thrown =
      "if w or h is less than or equal to zero" whereas it is seen that this =
      exception is thrown only if either w or h equal zero or if both w and h =
      are less than zero. If only width or height are negetive, then it throws =
      a NegetiveArraySizeException.

      import java.awt.image.DirectColorModel;
      import java.awt.color.ColorSpace;
      import java.awt.image.WritableRaster;
      import java.awt.image.DataBuffer;

      public class Test {
       public Test() {
       =20
        ColorSpace cs =3D ColorSpace.getInstance(ColorSpace.CS_sRGB);
          int bits =3D 32;

          int rmask =3D 0x00ff0000;
          int gmask =3D 0x0000ff00;
          int bmask =3D 0x000000ff;
          int amask =3D 0xff000000;

          DirectColorModel dCM =3D new DirectColorModel(
            cs,32,0x00ff0000,0x0000ff00,0x000000ff,0xff000000,
            false,DataBuffer.TYPE_INT);
        WritableRaster raster =3D null;
       =20
        try {
               raster =3D dCM.createCompatibleWritableRaster(-10,-10);
        } catch (IllegalArgumentException e) {
           System.out.println("For w & h negetive got "+e);
              } catch (NegativeArraySizeException e) {
           System.out.println("For w=3D-10 h=3D-10 got "+e);
              }
             =20
              try {
               raster =3D dCM.createCompatibleWritableRaster(-10,0);
        } catch (IllegalArgumentException e) {
           System.out.println("For either w or h =3D 0 got "+e);
              } catch (NegativeArraySizeException e) {
           System.out.println("For w=3D-10 h=3D0 got "+e);
              }
             =20
              try {
               raster =3D dCM.createCompatibleWritableRaster(0,0);
        } catch (IllegalArgumentException e) {
           System.out.println("For both w & h =3D 0 got "+e);
              } catch (NegativeArraySizeException e) {
           System.out.println("For w=3D0 h=3D0 got "+e);
              }

              try {
               raster =3D dCM.createCompatibleWritableRaster(-10,10);
        } catch (IllegalArgumentException e) {
           System.out.println("For w=3D-10 h=3D10 (either one positive) got =
      "+e);
              } catch (NegativeArraySizeException e) {
           System.out.println("For w=3D-10 h=3D10 (either one positive) got =
      "+e);
              }
             =20
       }
      =20
       public static void main(String[] args) {
        new Test();
       }
       =20

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

            tdv Dmitri Trembovetski (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: