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

Add a check in setData() to restrict the update of Built-In ICC_Profiles

XMLWordPrintable

    • 2d
    • behavioral
    • minimal
    • Hide
      The Risk is minimal.
      ICC_Profile::setData() already has an IllegalArgumentException declared in the API, so the application should be prepared for this exception.
      Show
      The Risk is minimal. ICC_Profile::setData() already has an IllegalArgumentException declared in the API, so the application should be prepared for this exception.
    • Other

      Summary

      The method java.awt.color.ICC_Profile.setData(int, byte[]) will throw IllegalArgumentException if applied to a JDK provided (built-in) ICC_Profile instance.

      This is a clean copy of JDK25 CSR JDK-8350025

      Problem

      JDK includes built-in ICC profiles for the sRGB, Linear RGB, GRAY, PYCC and CIEZYZ color spaces, as defined in the java.awt.color.ColorSpace class.

      The data for these profiles is embedded in the java.desktop module and instances are obtained by calling java.awt.color.ICC_Profile.getInstance(int colorSpaceID).

      Also, ICC_Profile provides a setData() method which allows applications to directly modify the data backing a profile.

      The built-in profiles are singleton objects, if an application modifies a shared profile object via ICC_Profile.setData(), then the modified version of the profile is returned each time the same built-in profile is requested via ICC_Profile.getInstance(). This would impact all color space transformations using the modified color space.

      Solution

      ICC_Profile.setData() will throw an IllegalArgumentException if the profile is a built-in profile. IllegalArgumentException is already a documented exception for this case, and although it's not a checked exception, any application using this API should really be prepared to handle it.

      Specification

      java/awt/color/ICC_Profile.setData(int tag, byte[] data)

      +    * <p>
      +    * Note: JDK built-in ICC Profiles cannot be updated using this method
      +    * as it will result in {@code IllegalArgumentException}. JDK built-in
      +    * profiles are those obtained by {@code ICC_Profile.getInstance(int colorSpaceID)}
      +    * where {@code colorSpaceID} is one of the following:
      +    * {@link ColorSpace#CS_sRGB}, {@link ColorSpace#CS_LINEAR_RGB},
      +    * {@link ColorSpace#CS_PYCC}, {@link ColorSpace#CS_GRAY} or
      +    * {@link ColorSpace#CS_CIEXYZ}.
      +    * 
      
      +    * @throws IllegalArgumentException if this is a built-in profile for one
      +    *         of the pre-defined color spaces, that is those which can be obtained
      +    *         by calling {@code ICC_Profile.getInstance(int colorSpaceID)}
      
      +    * @see ColorSpace

            abakhtin Alexey Bakhtin
            honkar Harshitha Onkar
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: