RFR: JDK-8346465 : Add a check in setData() to restrict the update of Built-In ICC_Profiles [v5]
Alexey Ivanov
aivanov at openjdk.org
Thu Feb 20 15:16:58 UTC 2025
On Thu, 20 Feb 2025 15:11:47 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> src/java.desktop/share/classes/java/awt/color/ICC_Profile.java line 116:
>>
>>> 114: * BuiltInProfile.
>>> 115: */
>>> 116: private boolean isBuiltIn = false;
>>
>> Can't this field be `final` and be set in constructor of the class?
>
> Indeed, it *can be*, and I prefer this design. This way, the `isBuiltIn` field can't be changed after the object is constructed. I think it's a cleaner design.
>
> To achieve this, you have to add a constructor which accepts a boolean flag: `ICC_Profile(ProfileDeferralInfo pdi, boolean builtIn)`, and `ICC_ProfileRGB` and `ICC_ProfileGray` need to provide an additional constructor as well.
>
> Here's [a diff to your branch which achieves this](https://github.com/honkar-jdk/jdk/compare/BuiltInCheck...aivanov-jdk:jdk:harshitha/8346465-built-inprofiles).
>
> When [you compare the changeset that I propose to `jdk/master`](https://github.com/openjdk/jdk/compare/master...aivanov-jdk:jdk:harshitha/8346465-built-inprofiles), there are less differences, and `BuiltInProfile` remains an interface. Yet two more files `ICC_ProfileRGB` and `ICC_ProfileGray` are modified.
After adding a constructor which accepts a boolean parameter, the constructors `ICC_ProfileRGB(ProfileDeferralInfo pdi)` and `ICC_ProfileGray(ProfileDeferralInfo pdi)` — these two can be removed then.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23606#discussion_r1963768913
More information about the client-libs-dev
mailing list