Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3010 fix private field visibility
  3. GROOVY-5438

Private field inaccessible in closure when using a subclass

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 5.0.0-alpha-1
    • groovy-jdk
    • None

    Description

      If a class defines a private field and a method that uses a closures referencing this private field, then a groovy.lang.MissingPropertyException is thrown any time this method is called from a subclass.

      It can be reproduced in the groovy console with the script in attachment. If "iterate" is called on the parent it works (text is appended to stdout - no exception), but if it is called from the subclass it fails (only the text from outside the closure is displayed and then an exception is thrown).

      This issue come from a deeper investigation on http://groovy.329449.n5.nabble.com/Exception-when-extending-ASTTransformationCustomizer-td5630073.html

      Attachments

        1. reproduce.groovy
          0.3 kB
          Mathieu Bruyen

        Issue Links

          Activity

            People

              emilles Eric Milles
              mathbruyen Mathieu Bruyen
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: