Add appropriate checks in java.awt.image.Kernel constructor

XMLWordPrintable

    • Type: CSR
    • Resolution: Approved
    • Priority: P3
    • 26
    • Component/s: client-libs
    • None
    • 2d
    • behavioral
    • low
    • Hide
      The only meaningful change here is to verify width and height up front in the constructor.
      The Kernel class is used in image processing when transforming an input pixel of an image to an output pixel of a destination image by computing the output pixel value based on surrounding input pixels.
      The width and height of the kernel are therefore typically small positive integers
      So any real usage of this class will be wholly unaffected as negative and overflowing values are not useful.
      Show
      The only meaningful change here is to verify width and height up front in the constructor. The Kernel class is used in image processing when transforming an input pixel of an image to an output pixel of a destination image by computing the output pixel value based on surrounding input pixels. The width and height of the kernel are therefore typically small positive integers So any real usage of this class will be wholly unaffected as negative and overflowing values are not useful.
    • Java API
    • SE

      Summary

      The behavior and specification of the java.awt.image.Kernel(..) constructor is updated to document exceptions and the conditions under which they may be thrown.

      Problem

      java.awt.image.Kernel(..) constructor does not validate the width and height input arguments and throw appropriate exceptions. NullPointerException is currently thrown for null data, but this is not specified.

      Solution

      Add explicit checks for invalid arguments and throw appropriate exceptions, and update the specification to document this.

      Specification

      class java.awt.image.Kernel

            * @param data          kernel data in row major order
      +     * @throws IllegalArgumentException if {@code data} is null
      +     * @throws IllegalArgumentException if {@code width} or {@code height}
      +     *         is not positive
      +     * @throws IllegalArgumentException if product of {@code width} and
      +     *         {@code height} overflows an int
            * @throws IllegalArgumentException if the length of {@code data}
            *         is less than the product of {@code width} and
            *         {@code height}
            */
           public Kernel(int width, int height, float[] data) ;
      

            Assignee:
            Jayathirth D V
            Reporter:
            Jayathirth D V
            Alexander Zvegintsev, Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: