JDK-6862160 : Charset.isSupported() performs too expensive
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 7
  • Priority: P5
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2009-07-20
  • Updated: 2011-02-16
Description
A DESCRIPTION OF THE REQUEST :
- In class Charset move shortcut handling for extendedProvider from lookupExtendedCharset() inside to method lookupViaProviders().
- May be instantiate ExtendedCharsets as singleton.

JUSTIFICATION :
Every time, if lookupExtendedCharset() fails for particular charset, a new ExtendedCharsets object will be instantiated by lookupViaProviders(), which just as well must fail.
Additionally, static variable ExtendedCharsets.instance would be updated, so from this time, it holds different instance than cached in Charset.extendedProvider variable.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
First instantiation of ExtendedCharsets should be reused by lookupViaProviders().
ACTUAL -
Invocation of Charset.isSupported() or Charset.forName() instantiates and initializes superfluous ExtendedCharsets object.