JDK-6476646 : (str) Make AbstractStringBuilder class public
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-09-29
  • Updated: 2012-08-21
  • Resolved: 2012-08-21
Description
A DESCRIPTION OF THE REQUEST :
AbstractBuilder is an excellent basis for an efficient growable String class, but it is package-private.

Please either:
a) make AbstractStringBuilder public, OR
b) provide a concrete sub-class of AbstractStringBuilder that provides a char[] getCharArray() method that allows direct access to the char[] array (clearly StringBuffer cannot fulfill this need as it would violate it's contract)

Option a) requires no work, does not break any contracts within the JDK and allows developers who need performance to leverage it.

JUSTIFICATION :
Java's core value classes are justly careful about synchronization and state protection, but there should be efficient alternatives.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Need a means to use or create a sub-class of AbstractStringBuilder that provides access to it's internal char[] value.

CUSTOMER SUBMITTED WORKAROUND :
Violate Sun's copyright and duplicate the source code of AbstractStringBuilder (not viable).

Comments
EVALUATION Opening this up as public, although somewhat beneficial, would make it less feasible to change the underlying implementation of StringBuilder and StringBuffer should future improvements be revealed. Being locked into a public API in AbstractStringBuilder might make it hard to make changes that would benefit the vast majority of users that use StringBuffer and StringBuilder directly.
21-08-2012