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

ICC_ColorSpace.toCIEXYZ(float[]): NPE is not specified

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 22
    • client-libs
    • None
    • 2d
    • behavioral
    • minimal
    • Document existing behavior.
    • Java API
    • SE

      Summary

      Some public and private(but serialisation related) methods in the java.awt.color package do not specify behaviour if null value is passed.

      Problem

      Most of the methods in the java.awt.color package throw unspecified NPE on null, and just a few intentionally accept it.

      Solution

      The specification should be updated and aligned to the current behaviour.

      Specification

      src/java.desktop/share/classes/java/awt/color/CMMException.java
      
           /**
            * Constructs a {@code CMMException} with the specified detail message.
            *
      -     * @param  s the specified detail message
      +     * @param  message the specified detail message, or {@code null}
            */
           public CMMException(String message) {
      
      
      src/java.desktop/share/classes/java/awt/color/ColorSpace.java
      
            * @return a float array of length 3
            * @throws ArrayIndexOutOfBoundsException if array length is not at least
            *         the number of components in this {@code ColorSpace}
      +     * @throws NullPointerException if {@code colorvalue} is {@code null}
            */
           public abstract float[] toRGB(float[] colorvalue);
      
            * @return a float array with length equal to the number of components in
            *         this {@code ColorSpace}
            * @throws ArrayIndexOutOfBoundsException if array length is not at least 3
      +     * @throws NullPointerException if {@code rgbvalue} is {@code null}
            */
           public abstract float[] fromRGB(float[] rgbvalue);
      
            *         components in this {@code ColorSpace}
            * @return a float array of length 3
            * @throws ArrayIndexOutOfBoundsException if array length is not at least
      -     *         the number of components in this {@code ColorSpace}.
      +     *         the number of components in this {@code ColorSpace}
      +     * @throws NullPointerException if {@code colorvalue} is {@code null}
            */
           public abstract float[] toCIEXYZ(float[] colorvalue);
      
            * @return a float array with length equal to the number of components in
            *         this {@code ColorSpace}
            * @throws ArrayIndexOutOfBoundsException if array length is not at least 3
      +     * @throws NullPointerException if {@code colorvalue} is {@code null}
            */
           public abstract float[] fromCIEXYZ(float[] colorvalue);
      
      
      src/java.desktop/share/classes/java/awt/color/ICC_ColorSpace.java 
      
            * @param  profile the specified {@code ICC_Profile} object
            * @throws IllegalArgumentException if profile is inappropriate for
            *         representing a {@code ColorSpace}
      +     * @throws NullPointerException if {@code profile} is {@code null}
            */
           public ICC_ColorSpace(ICC_Profile profile) {
      
            * @throws ClassNotFoundException if the class of a serialized object could
            *         not be found
            * @throws IOException if an I/O error occurs
      +     * @throws NullPointerException if {@code s} is {@code null}
            */
           @Serial
           private void readObject(ObjectInputStream s)
      
            * @return a float array of length 3
            * @throws ArrayIndexOutOfBoundsException if array length is not at least
            *         the number of components in this {@code ColorSpace}
      +     * @throws NullPointerException if {@code colorvalue} is {@code null}
            */
           public float[] toRGB(float[] colorvalue) {
      
            * @return a float array with length equal to the number of components in
            *         this {@code ColorSpace}
            * @throws ArrayIndexOutOfBoundsException if array length is not at least 3
      +     * @throws NullPointerException if {@code rgbvalue} is {@code null}
            */
           public float[] fromRGB(float[] rgbvalue) {
      
            * @return a float array of length 3
            * @throws ArrayIndexOutOfBoundsException if array length is not at least
            *         the number of components in this {@code ColorSpace}
      +     * @throws NullPointerException if {@code colorvalue} is {@code null}
            */
           public float[] toCIEXYZ(float[] colorvalue) {
      
            * @return a float array with length equal to the number of components in
            *         this {@code ColorSpace}
            * @throws ArrayIndexOutOfBoundsException if array length is not at least 3
      +     * @throws NullPointerException if {@code colorvalue} is {@code null}
            */
           public float[] fromCIEXYZ(float[] colorvalue) {
      
      
      src/java.desktop/share/classes/java/awt/color/ICC_Profile.java
      
            *
            * @param  s stream used for serialization
            * @throws IOException thrown by {@code ObjectInputStream}
      +     * @throws NullPointerException if {@code s} is {@code null}
            * @serialData the {@code String} is the name of one of
            *         <code>CS_<var>*</var></code> constants defined in the
            *         {@link ColorSpace} class if the profile object is a profile for a
          private void writeObject(ObjectOutputStream s) throws IOException {
      
      
            *
            * @param  s stream used for deserialization
            * @throws IOException thrown by {@code ObjectInputStream}
      -     * @throws ClassNotFoundException thrown by {@code
      -     *         ObjectInputStream}
      +     * @throws ClassNotFoundException thrown by {@code ObjectInputStream}
      +     * @throws NullPointerException if {@code s} is {@code null}
            * @serialData the {@code String} is the name of one of
            *         <code>CS_<var>*</var></code> constants defined in the
            *         {@link ColorSpace} class if the profile object is a profile for a
          private void readObject(ObjectInputStream s)
      
      src/java.desktop/share/classes/java/awt/color/ProfileDataException.java
      
            * Constructs a {@code ProfileDataException} with the specified detail
            * message.
            *
      -     * @param  s the specified detail message
      +     * @param  message the specified detail message, or {@code null}
            */
          public ProfileDataException(String message) {

      link for convenience: https://github.com/openjdk/jdk/pull/14821

            serb Sergey Bylokhov
            ydanilev Yury Danilevich (Inactive)
            Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: