RFR: JDK-8346465 : Add a check in setData() to restrict the update of Built-In ICC_Profiles [v11]
Sergey Bylokhov
serb at openjdk.org
Wed Mar 12 19:33:06 UTC 2025
On Wed, 12 Mar 2025 19:27:09 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
>>> There are two other exceptions that may be better suited that ISE in this case - [UnsupportedOperationException ](https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/UnsupportedOperationException.html) and [ProfileDataException](https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/color/ProfileDataException.html) but still IAE was chosen over them as it is existing and documented exception.
>>
>> `UnsupportedOperationException` could be used.
>>
>> `HeadlessException` extends `UnsupportedOperationException` and indicates a situation where a method cannot proceed because of the platform configuration.
>>
>> `ProfileDataException` doesn't suit either because there's nothing wrong with the profile data in the case of built-in profiles.
>
>> The System Properties case isn't something I'd want to follow. It doesn't really make them read-only.
>> It just ensures that the JDK internally caches the original value for use in certain places.
>
> Right. The application may attempt to change these java properties, but it won't affect the behavior of the JDK since the JDK internally will use the initially cached value of the property via StaticProperty.userDir()/userHome()/etc.
>
> This is even specified similarly to what we want for color profiles.
>
>> * <strong>Changing a standard system property may have unpredictable results
> * unless otherwise specified.</strong>
> * Property values may be cached during initialization or on first use.
> * Setting a standard property after initialization using {@link #getProperties()},
> * {@link #setProperties(Properties)}, {@link #setProperty(String, String)}, or
> * {@link #clearProperty(String)} may not have the desired effect.
* Builtin color profiles may be cached during initialization or on first use. Changing a standard profiles after initialization using ICC_Profile.setData may not have the desired effect.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23606#discussion_r1992171181
More information about the client-libs-dev
mailing list