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

access error for inaccessible getter of super class

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.21, 4.0.21
    • 3.0.22, 4.0.22
    • Static compilation
    • None

    Description

      Consider the following:

      package p;
      abstract class A {
        private Object getX() { return "X"; }
        /*package*/ Object getY() { return "Y"; }
      }
      
      @groovy.transform.CompileStatic
      class C extends p.A implements Map<String,String> {
        @Delegate Map<String,String> map = [:]
        void test() {
          print this.x // Cannot access method: getX() of class: p.A
          print this.y // IllegalAccessError: class C tried to access method p.A.getY()
        }
      }
      

      STC is happy with both property expressions since they can be satisfied via the Map interface. Classgen emits error for the private getter and writes out a call to the package-private getter. In GROOVY-11367, these are noted in #5: "this.any // getter (public, protected, package-private if same-package) or entry (private, package-private if other-package)"

      GROOVY-6277, GROOVY-11367

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: