RFR: JDK-8302323 Add repeat methods to StringBuilder/StringBuffer [v2]

Tagir F. Valeev tvaleev at openjdk.org
Sun Feb 26 17:28:04 UTC 2023


On Thu, 23 Feb 2023 16:17:00 GMT, Jim Laskey <jlaskey at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 1839:
>> 
>>> 1837:      * @throws StringIndexOutOfBoundsException  if the result overflows the buffer
>>> 1838:      */
>>> 1839:     public AbstractStringBuilder repeat(char c, int count) {
>> 
>> The shadowing of the count field is a hidden maintenance trap.
>
> I know but Stuart requested it.

But this method is overridden in the subclasses. We may keep it `count` in subclasses for the API but use different name here for the implementation. What do you think?

-------------

PR: https://git.openjdk.org/jdk/pull/12728


More information about the core-libs-dev mailing list