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

spec: ImageTypeSpecifier - unspecified exceptions in factory methods

XMLWordPrintable

    • beta2
    • generic
    • generic



      Name: bkR10012 Date: 03/26/2001



        The factory methods of the class javax.imageio.ImageTypeSpecifier
      return a specifier that will use some ColorModel and some SampleModel.
      These methods try to create corresponding ColorModel and SampleModel.
      In some cases creation leads to throwing unspecified exceptions because
      of improper parameters.

        From my point of view, all parameter restrictions should be specified,
      and only IllegalArgumentException should be thrown when these
      restrictions are violated.

      Here is the list of revealed unspecified exceptions.
      ------------------------------
      createPacked(colorSpace, redMask, greenMask, blueMask, alphaMask, transferType,
      isAlphaPremultiplied)

      - NullPointerException if colorSpace is null;
      - IllegalArgumentException: ColorSpace must be TYPE_RGB.
      if colorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
      - IllegalArgumentException: There must be at least one component with > 0 pixel
      bits.
      if redMask, greenMask, blueMask and alphaMask are zero;
      - IllegalArgumentException: Unsupported dataType: -1
      if transferType is -1;

      ------------------------------
      createInterleaved(colorSpace, bandOffsets, dataType, hasAlpha,
      isAlphaPremultiplied)

      - NullPointerException if colorSpace is null;
      - NullPointerException if bandOffsets is null;
      - IllegalArgumentException: Offsets between bands must be less than the scanline
      stride
      if bandOffsets = {0,100,1000,99999};
      - llegalArgumentException: Number of color/alpha components should be 4 but
      length of bits array is 0
      if bandOffsets = {};

      ------------------------------
      createBanded(colorSpace, bankIndices, bandOffsets, dataType, hasAlpha,
      isAlphaPremultiplied)

      - NullPointerException if colorSpace is null;
      - llegalArgumentException: Number of color/alpha components should be 4 but
      length of bits array is 0
      if bandOffsets = {}; bankIndices = {};
      - IllegalArgumentException: dataType = 9999
      if dataType is 99999;

      ------------------------------
      createGrayscale(bits, dataType, isSigned)
      createGrayscale(bits, dataType, isSigned, isAlphaPremultiplied)

      - IllegalArgumentException: Number of bits must be between 1 and 16.
      if bits = 100;
      - java.awt.image.RasterFormatException: MultiPixelPackedSampleModel does not
      allow pixels to span data element boundaries
      if bits = 10; dataType = DataBuffer.TYPE_BYTE;
      - IllegalArgumentException: Unknown data type 100
      if dataType = 100;

      ------------------------------
      createIndexed(redLUT, greenLUT, blueLUT, alphaLUT, bits, dataType)

      - IllegalArgumentException: Number of pixel bits must be > 0
      if bits = 0;
      - IllegalArgumentException: Number of bits must be between 1 and 16.
      if bits = 17;
      - java.awt.image.RasterFormatException: MultiPixelPackedSampleModel does
      not allow pixels to span data element boundaries, if
          redLUT = {0};
          greenLUT = {0};
          blueLUT = {0};
          alphaLUT = {0};
          bits = 10;
          dataType = DataBuffer.TYPE_BYTE;
      - ArrayIndexOutOfBoundsException if
          byte[] redLUT = {1};
          byte[] greenLUT = {};
          byte[] blueLUT = {1,2,3};
      - IllegalArgumentException: Map size (0) must be >= 1, if
          byte[] redLUT = {};
          byte[] greenLUT = {1};
          byte[] blueLUT = {1,2,3};
      - ArrayIndexOutOfBoundsException if
          byte[] redLUT = {1};
          byte[] greenLUT = {1};
          byte[] blueLUT = {1,2,3};
          byte[] alphaLUT = {};
      - IllegalArgumentException: Unknown data type 100
      if dataType = 100;
      ------------------------------
      ======================================================================

            dricesunw Daniel Rice (Inactive)
            kuzsunw Kuz Kuz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: