-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8358623: Avoid unnecessary data copying in ICC_Profile #25650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back serb! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
&& getData(p, icSigRedTRCTag) != null | ||
&& getData(p, icSigGreenTRCTag) != null | ||
&& getData(p, icSigBlueTRCTag) != null) { | ||
} else if (type == ColorSpace.TYPE_RGB) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above checks are moved to the corresponding constructors.
throw new RuntimeException("Test failed for ColorSpace: " + cs); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also added a test for the changed methods, since they were not covered by any jtreg tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, ICC_Profile.getMinorVersion() does not return just the minor version as specified, but instead returns the raw byte, which includes both the minor and patch versions. Perhaps the specification should be updated to reflect this behavior?
This PR simplifies several aspects of the ICC_Profile class:
Change 1:
The ICC_Profile.getInstance(byte[] data) method used to copy the profile header for validation. This copy appears redundant, as the original data array is used later anyway. This logic was originally introduced by JDK-8347377.
Change 2:
In some places, the code retrieves the profile header using getData(icSigHead), which always creates a new array. It is now replaced with private getData(cmmProfile(), icSigHead) to avoid unnecessary copying. To clarify the purpose of the private method, I have added documentation.
Change 3:
After Change 2, static analysis tools began reporting a potential NPE when using getData(cmmProfile(), icSigHead), since it may return null. To address this, the internal implementation of getData was updated to always return a non-null value or throw an exception. The public method now catches this exception and returns null, as required by the specification. Note: this potential NPE is not a regression introduced by any changes, it simply became easier for tools to detect due to the simplified code.
@prrace @honkar-jdk please take a look
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25650/head:pull/25650
$ git checkout pull/25650
Update a local copy of the PR:
$ git checkout pull/25650
$ git pull https://git.openjdk.org/jdk.git pull/25650/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25650
View PR using the GUI difftool:
$ git pr show -t 25650
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25650.diff
Using Webrev
Link to Webrev Comment