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

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

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 25
    • client-libs
    • None
    • 2d
    • behavioral
    • medium
    • Hide
      Applications which call ICC_Profile.setData(..) on a "built-in" (ie shared) profile instance will be broken by this change.
      This might be a "high" risk, except that this is an expert-level API and other than tests written to verify this API, it is likely to be extremely rarely used.
      And the compatibility issue is only to apps that modify a built-in profile, which is not a wise thing to do.
      Show
      Applications which call ICC_Profile.setData(..) on a "built-in" (ie shared) profile instance will be broken by this change. This might be a "high" risk, except that this is an expert-level API and other than tests written to verify this API, it is likely to be extremely rarely used. And the compatibility issue is only to apps that modify a built-in profile, which is not a wise thing to do.
    • Java API
    • SE

      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.

      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

            honkar Harshitha Onkar
            honkar Harshitha Onkar
            Alexey Ivanov, Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: