[ https://issues.apache.org/jira/browse/GROOVY-10429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17676694#comment-17676694 ]
Eric Milles commented on GROOVY-10429: -------------------------------------- Indeed {{setLength(int)}} is public and {{StringBuilder}} supplies a public bridge method that delegates to the implementation in {{AbstractStringBuilder}}. This commit fixes the issue of bridge method selection: https://github.com/apache/groovy/commit/63515db24581d2c516f21b58e253bcce6d9d130d > 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 > Fix For: 4.0.0-rc-1 > > > 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.10#820010)