ArrayIndexOutOfBoundsException Not Documented for SinglePixelPackedSampleModel.getSampleSize(int)

XMLWordPrintable

    • Type: CSR
    • Resolution: Approved
    • Priority: P3
    • 27
    • Component/s: client-libs
    • None
    • 2d
    • minimal
    • There is no implementation change, only specification.
    • Java API
    • SE

      Summary

      The specification of overrides of java.awt.image.SampleModel.getSampleSize(int bands) are updated to describe the behavior with invalid values of 'bands'.

      Problem

      There are 3 public SampleModel subclasses with implementations of java.awt.image.SampleModel.getSampleSize(int bands) and they have inconsistent and unspecified behavior for invalid values of 'bands'.

      Solution

      Update the specification of the methods to specify how they use the 'bands' parameter.

      Specification

      java/awt/image/ComponentSampleModel.java
      
           /** Returns the number of bits per sample for the specified band.
      -     *  @param band the specified band
      +     * <p>
      +     * Since all bands of a {@code ComponentSampleModel} are the same
      +     * size, this method ignores the {@code band} parameter and returns
      +     * the size of the first (0th) band.
      +     *  @param band the specified band (ignored)
            *  @return the number of bits per sample for the specified band.
            */
           public final int getSampleSize(int band);
      
      java/awt/image/MultiPixelPackedSampleModel.java
      
           /**
            * Returns the number of bits per sample for the specified band.
      -     * @param band the specified band
      +     * <p>
      +     * Since {@code MultiPixelPackedSampleModel} has only one band,
      +     * this method ignores the {@code band} parameter and returns
      +     * the sample size of the single band.
      +     * @param band the specified band (ignored).
            * @return the number of bits per sample for the specified band.
            */
           public int getSampleSize(int band);
      
      java/awt/image/SinglePixelPackedSampleModel.java
      
      -    /** Returns the number of bits per sample for the specified band. */
      +    /** Returns the number of bits per sample for the specified band.
      +     * @param band the specified band
      +     * @return the size of the samples of the specified band.
      +     * @throws ArrayIndexOutOfBoundsException if the {@code band} index
      +     * is less than zero or greater than or equal to {@code getNumBands()}
      +     */
           public int getSampleSize(int band);
      
      

            Assignee:
            Philip Race
            Reporter:
            Hamza Nassour
            Alexander Zuev, Alexander Zvegintsev, Alexey Ivanov
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: