[
https://issues.apache.org/jira/browse/GROOVY-10429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17463374#comment-17463374
]
Aleks Tamarkin commented on GROOVY-10429:
-----------------------------------------
The Java 17 official documentation states this as a public method (Joe's link
above). Not sure it makes sense to hide this.
> StringBuilder misses setLength method in Java17
> -----------------------------------------------
>
> Key: GROOVY-10429
> URL: https://issues.apache.org/jira/browse/GROOVY-10429
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 3.0.9
> Environment: Java11, Java17, Windows 10
> Reporter: Joe Li
> Priority: Major
>
> The following code will break on Groovy 3.0.9 with Java 17 but works with
> Java 11:
> {code:java}
> def sb = new StringBuilder()
> sb << 'a'
> sb << 'b'
> println sb.toString()
> sb.setLength(0) {code}
> The error is
> {code:java}
> groovy.lang.MissingMethodException: No signature of method:
> java.lang.StringBuilder.setLength() is applicable for argument types:
> (Integer) values: [0]{code}
> This error can be reproduced in Groovy Console.
> The doc for Java's StringBuilder.setLength method
> [https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/StringBuilder.html#setLength(int)]
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)