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

Calling super.toString() with @TypeChecked or @CompileStatic will throw java.lang.StackOverflowError

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.x, 2.5.x
    • 2.5.9, 3.0.0-rc-1
    • Compiler
    • None
    • Any operating systems running Groovy 2.4.x or 2.5.x

    Description

      The following code snippet will throw java.lang.StackOverflowError:

      import groovy.transform.CompileStatic
      import groovy.transform.TypeChecked
      
      @CompileStatic
      class Super {
        String toString() { 'Super' }
      }
      
      @TypeChecked
      @CompileStatic
      class Child extends Super {
        String toString() { 'Child extends ' + super.toString() }
      }
      
      // java.lang.StackOverflowError will happen
      println new Child().toString()

       

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            daniel_sun Daniel Sun
            youzhichao Chih Chao Yu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment