JDK-6850361 : Avoid 2-step lookup in sun.nio.cs charset providers
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 6u10
  • Priority: P5
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2009-06-11
  • Updated: 2017-04-17
Description
A DESCRIPTION OF THE REQUEST :
By retrieving a Charset object from FastCharsetProvider or AbstractCharsetProvider via charsetForName(String name), the canonical name of the charset is first lookuped from alias->canonical map, and 2ndly lookuped from canonical->charset map.

JUSTIFICATION :
Directly mapping from alias name to Charset instance by only 1 map would perform better.
Additionally is would save some memory.
Comment copied from http://bugs.openjdk.java.net/show_bug.cgi?id=100095
Description From UlfZibis 2009-07-23 22:36:04 PDT

Created an attachment (id=117) [details]
webrev including patch

- Now FastCharsetProvider only has 1 HashMap 'cache' to lookup.
- AbstractCharsetProvider was replaced by ExternalCharsetProvider, which now
inherits from FastCharsetProvider.
- A Reference object contains all needed names of a Charset to lookup and
create it.

Comments
Two older webrev to fix the issue.
17-04-2017

SUGGESTED FIX See attached patch from OpenJDK bugzilla.
23-07-2012