JDK-6470454 : Substitute CharSequence for String arguments whenever possible
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2006-09-13
  • Updated: 2017-05-23
Related Reports
Relates :  
Description
Swing-related portions of bug 4838318:

With the introduction of the CharSequence interface, the String class is no longer the lowest-common-denominator for character data, and yet String arguments are still a pervasive requirement throughout the API.

All API methods currently specifying String arguments should be relaxed to CharSequence arguments unless they require immutability, equals(), hashCode(), or other String-specific behavior.

This change would not affect any existing code.

Here are a few candidate methods found by simply searching the API for the string, err, I mean the CharSequence ;-)
---> "(String"

JTextComponent.replaceSelection(String content)
JTextComponent.setText(String t)
JEditorPane.setText(String text)
JTextArea(String text)
JTextArea(String text, int rows, int columns)
JTextArea.append(String str)
JTextArea.insert(String str, int pos)
JTextArea.replaceRange(String str, int start, int end)
JEditorPane(String url)
JEditorPane(String type, String text)
JList.getNextMatch(String prefix, int startIndex, Position.Bias bias)
AbstractWriter.setLineSeparator(String value)
AbstractWriter.write(String content)

[ non-swing methods removed from the list ]