Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10429

StringBuilder misses setLength method in Java17

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.9
    • 4.0.0-rc-1
    • None
    • None
    • Java11, Java17, Windows 10

    Description

      The following code will break on Groovy 3.0.9 with Java 17 but works with Java 11:

      def sb = new StringBuilder()
      sb << 'a'
      sb << 'b'
      println sb.toString()
      sb.setLength(0) 

      The error is

      groovy.lang.MissingMethodException: No signature of method: java.lang.StringBuilder.setLength() is applicable for argument types: (Integer) values: [0]

      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)

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              astrogg Joe Li
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: