-
CSR
-
Resolution: Approved
-
P3
-
None
-
behavioral
-
medium
-
-
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
- csr of
-
JDK-8346465 Add a check in setData() to restrict the update of Built-In ICC_Profiles
-
- Open
-