On Sat, 1 Mar 2025 01:11:45 GMT, Harshitha Onkar <hon...@openjdk.org> wrote:

>> Built-in Profiles are singleton objects and if the user happens to modify 
>> this shared profile object via setData() then the modified version of the 
>> profile is returned each time the same built-in profile is requested via 
>> getInstance().
>> 
>> It is good to protect Built-in profiles from such direct modification by 
>> adding BuiltIn profile check in `setData()` such that **only copies** of 
>> Built-In profiles are allowed to be updated.
>> 
>> With the proposed fix, if Built-In profile is updated using `.setData()` it 
>> throws _**IAE - "BuiltIn profile cannot be modified"**_
>> 
>> There are no restrictions on creating copies of BuiltIn profile and then 
>> modifying it, but what is being restricted with this fix is - the direct 
>> modification of the shared BuiltIn profile instance.
>> 
>> Applications which need a modified version of the ICC Profile should instead 
>> do the following:
>> 
>> 
>> byte[] profileData = ICC_Profile.getData() // get the byte array 
>> representation of BuiltIn- profile
>> ICCProfile newProfile = ICC_Profile.getInstance(profileData) // create a new 
>> profile
>> newProfile.setData() // to modify and customize the profile
>> 
>> 
>> Following existing tests are modified to update a copy of Built-In profile.
>> 
>> - java/awt/color/ICC_Profile/SetHeaderInfo.java
>> - java/awt/color/ICC_ProfileSetNullDataTest.java
>> - sun/java2d/cmm/ProfileOp/SetDataTest.java
>
> Harshitha Onkar has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   doc update

src/java.desktop/share/classes/java/awt/color/ICC_Profile.java line 784:

> 782:      * Note: {@code ProfileDeferralInfo} is used for only built-in 
> profile
> 783:      * creation and all built-in profiles should be constructed using it.
> 784:      * </p>

</p> is not necessary here.

src/java.desktop/share/classes/java/awt/color/ICC_Profile.java line 1156:

> 1154:      * {@link ColorSpace#CS_sRGB}, {@link ColorSpace#CS_LINEAR_RGB},
> 1155:      * {@link ColorSpace#CS_PYCC}, {@link ColorSpace#CS_GRAY} or
> 1156:      * {@link ColorSpace#CS_CIEXYZ}.

The standard profile could be acquired by the application via serialization as 
well, but I'm not sure if we should mention it.

src/java.desktop/share/classes/java/awt/color/ICC_Profile.java line 1169:

> 1167:      * @throws IllegalArgumentException if this is a built-in profile 
> for one
> 1168:      *         of the pre-defined ColorSpaces, i.e. those which can be 
> obtained
> 1169:      *         by calling {@code ICC_Profile.getInstance(int 
> colorSpaceID)}

can we just ignore it instead and did not use suspicion 
IllegalArgumentException for correct parameters? or change the type to 
something unrelated to "..ArgumentException"?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23606#discussion_r1977924842
PR Review Comment: https://git.openjdk.org/jdk/pull/23606#discussion_r1977928295
PR Review Comment: https://git.openjdk.org/jdk/pull/23606#discussion_r1977930093

Reply via email to