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

CompileStatic doesn't call property accessors on super classes correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 2.4.0
    • 2.4.1
    • Static compilation
    • None
    • OSX Yosemite

    Description

      Overloading a getter from a super class and then delegating to that parent class requires using the actual method and not the property accessor when using static compilation in groovy 2.4.0. This is something we do to add hibernate validators to a subclass of generated code. Not using static compilation on the subclass or switching to groovy 2.3.x resolves the issue.

      import groovy.transform.CompileStatic
       
      class A {
          private String field1 = 'test'
          
          String getField1() {
              return this.field1
         } 
      }
       
      @CompileStatic
      class B extends A {
          @Override
          String getField1() {
              super.field1
          }
      }
       
      B b = new B() 
       
      println b.field1
      

      >>> 2.4.0 output
      Exception thrown

      java.lang.StackOverflowError
      	at B.getField1(ConsoleScript1:15)
      	at B.getField1(ConsoleScript1:15)
      	at B.getField1(ConsoleScript1:15)
      

      >>> 2.3.6 output

      test
      

      Attachments

        Issue Links

          Activity

            People

              melix Cédric Champeau
              kyleboon Kyle Boon
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: