[OpenJDK 2D-Dev] RFR: 8260695: The java.awt.color.ICC_Profile#getData/getData(int) are not thread safe
Sergey Bylokhov
serb at openjdk.java.net
Mon Feb 1 09:09:03 UTC 2021
On Mon, 1 Feb 2021 09:00:18 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
> Both methods are implemented in a similar way.
> 1. Requests the size of the profile/tag data
> 2. Creates an array of the correct size
> 3. Requests the data and copy it to the array
>
> If the data will be changed concurrently between steps 2. and 3. then we will get a mismatch between the array and copied data.
>
> In the fix, all steps above are merged to just one step return the data when requested.
src/java.desktop/share/classes/java/awt/color/ICC_Profile.java line 1210:
> 1208: public byte[] getData() {
> 1209: activate();
> 1210: return CMSManager.getModule().getProfileData(cmmProfile);
Just one step, the array will be created in the native code under proper synchronization.
src/java.desktop/share/classes/java/awt/color/ICC_Profile.java line 1236:
> 1234: private static byte[] getData(Profile p, int tagSignature) {
> 1235: try {
> 1236: return CMSManager.getModule().getTagData(p, tagSignature);
Just one step, the array will be created in the native code under proper synchronization.
src/java.desktop/share/native/liblcms/LCMS.c line 330:
> 328: }
> 329:
> 330: jbyteArray data = (*env)->NewByteArray(env, pfSize);
Here we create the new array.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2330
More information about the 2d-dev
mailing list