Skip to content


8312411: MessageFormat.formatToCharacterIterator() can be improved
Browse files Browse the repository at this point in the history
Reviewed-by: naoto
  • Loading branch information
Justin Lu committed Jul 28, 2023
1 parent e2cb0bc commit 23755f9
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/java.base/share/classes/java/text/
Original file line number Diff line number Diff line change
Expand Up @@ -948,20 +948,16 @@ public final StringBuffer format(Object arguments, StringBuffer result,
* @since 1.4
public AttributedCharacterIterator formatToCharacterIterator(Object arguments) {
Objects.requireNonNull(arguments, "arguments must not be null");
StringBuffer result = new StringBuffer();
ArrayList<AttributedCharacterIterator> iterators = new ArrayList<>();

if (arguments == null) {
throw new NullPointerException(
"formatToCharacterIterator must be passed non-null object");
subformat((Object[]) arguments, result, null, iterators);
if (iterators.size() == 0) {
return createAttributedCharacterIterator("");
return createAttributedCharacterIterator(
new AttributedCharacterIterator[iterators.size()]));
iterators.toArray(new AttributedCharacterIterator[0]));

Expand Down

1 comment on commit 23755f9

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.