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

8272805: Avoid looking up standard charsets #5210

Closed

Conversation

@mrserb
Copy link
Member

@mrserb mrserb commented Aug 22, 2021

This is the continuation of JDK-8233884, JDK-8271456, and JDK-8272120.

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

This could be done more efficiently(up to 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.

This change includes:

  • demo/utils
  • jdk.xx packages
  • Some places were missed in the previous changes. I have found it by tracing the calls to the Charset.forName() by executing tier1,2,3 and desktop tests.

Some performance discussion: #5063

Code excluded in this fix: the Xerces library(should be fixed upstream), J2DBench(should be compatible to 1.4), some code in the network(the change there are not straightforward, will do it later).

Tested by the tier1/tier2/tier3 tests on Linux/Windows/macOS.


Progress

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

Issue

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5210

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Aug 22, 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.

@openjdk
Copy link

@openjdk openjdk bot commented Aug 22, 2021

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

  • 2d
  • build
  • compiler
  • core-libs
  • hotspot
  • jmx
  • kulla
  • net
  • security
  • serviceability
  • 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 22, 2021

Copy link
Contributor

@wangweij wangweij left a comment

The security related change looks fine to me.

@openjdk
Copy link

@openjdk openjdk bot commented Aug 22, 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:

8272805: Avoid looking up standard charsets

Reviewed-by: weijun, naoto, dfuchs, azvegint, erikj

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 1 new commit pushed to the master branch:

  • 9c392d0: 8273197: ProblemList 2 jtools tests due to JDK-8273187

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 22, 2021
@openjdk openjdk bot removed the jmx label Aug 22, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 22, 2021

@AlanBateman
The jmx label was successfully removed.

@turbanoff
Copy link
Member

@turbanoff turbanoff commented Aug 22, 2021

I think it's worth to update static initializer in sun.datatransfer.DataFlavorUtil.CharsetComparator too.
изображение

naotoj
naotoj approved these changes Aug 23, 2021
Copy link
Member

@naotoj naotoj left a comment

Looks good.

dfuch
dfuch approved these changes Aug 23, 2021
Copy link
Member

@dfuch dfuch left a comment

Changes to http server look good to me.

@mrserb
Copy link
Member Author

@mrserb mrserb commented Aug 23, 2021

I think it's worth to update static initializer in sun.datatransfer.DataFlavorUtil.CharsetComparator too.

Updated as suggested.

@magicus
Copy link
Member

@magicus magicus commented Aug 24, 2021

/label remove build

@openjdk openjdk bot removed the build label Aug 24, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 24, 2021

@magicus
The build label was successfully removed.

@mrserb
Copy link
Member Author

@mrserb mrserb commented Aug 26, 2021

Can somebody take a look too the changes in the "jdk.attach", "jdk.hotspot.agent" and IdealGraphVisualizer?

@fdesu
Copy link
Contributor

@fdesu fdesu commented Aug 26, 2021

@mrserb Not sure if it applies but there are couple of classes in java.xml that use charset names instead of standard charsets. Here they are:

  • src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
  • src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/xs/AnyURIDV.java
  • src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java
  • src/java.xml/share/classes/com/sun/xml/internal/stream/XMLEntityStorage.java

would it make sense to go through them as well?

@mrserb
Copy link
Member Author

@mrserb mrserb commented Aug 26, 2021

@mrserb Not sure if it applies but there are couple of classes in java.xml that use charset names instead of standard charsets.
would it make sense to go through them as well?

Most of the cases in the XML module are related to the Xerces library, I have skipped it to make the future merges from upstream of that library simpler.

Copy link
Member

@erikj79 erikj79 left a comment

Build tool change looks good.

@mrserb
Copy link
Member Author

@mrserb mrserb commented Sep 2, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Sep 2, 2021

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

  • 92b05fe: 8273251: Call check_possible_safepoint() from SafepointMechanism::process_if_requested()
  • 29e0f13: 8272385: Enforce ECPrivateKey d value to be in the range [1, n-1] for SunEC provider
  • aaa6f69: 8273250: Address javadoc issues in Deflater::setDictionationary
  • 5ee5dd9: 8272914: Create hotspot:tier2 and hotspot:tier3 test groups
  • 5245c1c: 8273147: Update and restructure TestGCLogMessages log message list
  • 632a7e0: 8273165: GraphKit::combine_exception_states fails with "matching stack sizes" assert
  • c2e015c: 8273229: Update OS detection code to recognize Windows Server 2022
  • 0c1b16b: 8273243: Fix indentations in java.net.InetAddress methods
  • 152e669: 8273140: Replace usages of Enum.class.getEnumConstants() with Enum.values() where possible
  • 857a930: 8263375: Support stack watermarks in Zero VM
  • ... and 16 more: https://git.openjdk.java.net/jdk/compare/3d657eb0a626e33995af5d5ddf12b26d06317962...master

Your commit was automatically rebased without conflicts.

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

@openjdk openjdk bot commented Sep 2, 2021

@mrserb Pushed as commit 7fff22a.

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

@mrserb mrserb deleted the standard-encodings-in-non-public-modules branch Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment