Skip to content
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

8271456: Avoid looking up standard charsets in "java.desktop" module #4951

Closed
wants to merge 4 commits into from

Conversation

@mrserb
Copy link
Member

@mrserb mrserb commented Aug 1, 2021

This is a request to clean up a desktop module as was done in JDK-8233884 for "java.base" module.

In many places standard charsets are looked up via their names, for example:
absolutePath.getBytes("UTF-8");

This could be done more efficiently(x20 time faster) with use of java.nio.charset.StandardCharsets:
absolutePath.getBytes(StandardCharsets.UTF_8);

The later variant also makes the code cleaner, as it is known not to throw UnsupportedEncodingException in contrary to the former variant.

Tested by the desktop headless/headful tests on linux/windows.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8271456: Avoid looking up standard charsets in "java.desktop" module

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4951/head:pull/4951
$ git checkout pull/4951

Update a local copy of the PR:
$ git checkout pull/4951
$ git pull https://git.openjdk.java.net/jdk pull/4951/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4951

View PR using the GUI difftool:
$ git pr show -t 4951

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4951.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Aug 1, 2021

👋 Welcome back serb! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@mrserb mrserb marked this pull request as ready for review Aug 1, 2021
@openjdk openjdk bot changed the title 8271456: Avoid looking up standard charsets in "java.desktop" module 8271456: Avoid looking up standard charsets in "java.desktop" module Aug 1, 2021
@openjdk openjdk bot added the rfr label Aug 1, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 1, 2021

@mrserb The following labels will be automatically applied to this pull request:

  • 2d
  • awt
  • sound
  • swing

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Aug 1, 2021

@openjdk
Copy link

@openjdk openjdk bot commented Aug 3, 2021

@mrserb This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8271456: Avoid looking up standard charsets in "java.desktop" module

Reviewed-by: jdv, azvegint, aivanov

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 23 new commits pushed to the master branch:

  • 221e4b9: 8270797: ShortECDSA.java test is not complete
  • 0a27f26: 8265057: G1: Investigate removal of maintenance of two BOT thresholds
  • eec64f5: 8256844: Make NMT late-initializable
  • 4df1bc4: 6350025: API documentation for JOptionPane using deprecated methods.
  • efcdcc7: 8270893: IndexOutOfBoundsException while reading large TIFF file
  • 977b8c4: 8271836: runtime/ErrorHandling/ClassPathEnvVar.java fails with release VMs
  • 04134fc: 8264543: Cross modify fence optimization for x86
  • 9e76909: 8271824: mark hotspot runtime/CompressedOops tests which ignore external VM flags
  • e49b7d9: 8271828: mark hotspot runtime/classFileParserBug tests which ignore external VM flags
  • 68f7847: 8271825: mark hotspot runtime/LoadClass tests which ignore external VM flags
  • ... and 13 more: https://git.openjdk.java.net/jdk/compare/6594d3a3ef175a71ea34c7698ab96537c761f022...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Aug 3, 2021
getTransferData(javaTextEncodingFlavor),
StandardCharsets.UTF_8);
Copy link
Member

@aivanov-jdk aivanov-jdk Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getTransferData(javaTextEncodingFlavor),
StandardCharsets.UTF_8);
getTransferData(javaTextEncodingFlavor),
StandardCharsets.UTF_8);

The parameter on the second line should probably be aligned with the first parameter as it's done in the snippet above.

Copy link
Member Author

@mrserb mrserb Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is aligned already, the StandardCharsets.UTF_8 is parameter of "new String()", not the getTransferData.

Copy link
Member

@aivanov-jdk aivanov-jdk Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right!
But it's confusing: it looks as if StandardCharsets.UTF_8 is a parameter to getTransferData. Maybe avoid breaking the line and leave UTF_8 on the same line? If you import UTF_8 and UTF_16LE statically, line break is unnecessary.

Copy link
Member Author

@mrserb mrserb Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine to do that, if there are no objections I can change the whole fix.

Copy link
Member

@aivanov-jdk aivanov-jdk Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine to do that, if there are no objections I can change the whole fix.

Modifying the entire changeset seems like an overkill.
Using static imports in only one file is inconsistent, yet it makes the places where the encodings are used clearer.

Copy link
Member Author

@mrserb mrserb Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

I admit I prefer static imports in this case: the code is shorter and is as clear. It's pretty obvious where the encoding comes from.

@mrserb
Copy link
Member Author

@mrserb mrserb commented Aug 4, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Aug 4, 2021

Going to push as commit 6b55ef3.
Since your change was applied there have been 26 commits pushed to the master branch:

  • 392fcc9: 8271589: fatal error with variable shift count integer rotate operation.
  • 9f1edaf: 8271599: Javadoc of floorDiv() and floorMod() families is inaccurate in some places
  • 452f7d7: 8271217: Fix race between G1PeriodicGCTask checks and GC request
  • 221e4b9: 8270797: ShortECDSA.java test is not complete
  • 0a27f26: 8265057: G1: Investigate removal of maintenance of two BOT thresholds
  • eec64f5: 8256844: Make NMT late-initializable
  • 4df1bc4: 6350025: API documentation for JOptionPane using deprecated methods.
  • efcdcc7: 8270893: IndexOutOfBoundsException while reading large TIFF file
  • 977b8c4: 8271836: runtime/ErrorHandling/ClassPathEnvVar.java fails with release VMs
  • 04134fc: 8264543: Cross modify fence optimization for x86
  • ... and 16 more: https://git.openjdk.java.net/jdk/compare/6594d3a3ef175a71ea34c7698ab96537c761f022...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Aug 4, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Aug 4, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 4, 2021

@mrserb Pushed as commit 6b55ef3.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@mrserb mrserb deleted the JDK-8271456 branch Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment