On Tue, 11 Mar 2025 21:26:23 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: > > redudant stmt removed test/jdk/java/awt/color/ICC_Profile/BuiltInProfileCheck.java line 40: > 38: > 39: public static void main(String[] args) { > 40: System.out.println("CASE 1: Testing BuiltIn Profile"); I suggest to add the cases when both(BuiltIn and Custom) profiles are tested after serialisation->deserialisation. test/jdk/java/awt/color/ICC_Profile/BuiltInProfileCheck.java line 50: > 48: > 49: private static void updateProfile(boolean isBuiltIn) { > 50: ICC_Profile builtInProfile = > ICC_Profile.getInstance(ColorSpace.CS_sRGB); It would be good to check all types of BuiltIn profiles to prove that it works in case we decide to implement/change some them differently(w/o cache for example). ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/23606#discussion_r2006354501 PR Review Comment: https://git.openjdk.org/jdk/pull/23606#discussion_r2006355768