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

Statically compiled calls to protected methods of an outerclass' superclass result in IllegalAccessErrors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.7
    • 2.5.0-alpha-1
    • Static compilation
    • None

    Description

      Example:

      package one;
      public class Base {
          protected int foo() {
              123
          }
      }
      
      package two;
      class SubBase extends Base {
          class Inner {
              int test() {
                  foo()
              }
          }
          
          int innerTest() {
              new Inner().test()
          }
      }
      assert new SubBase().innerTest() == 123
      

      The code above will fail with the following error:

      java.lang.IllegalAccessError: tried to access method one.Base.foo()I from class two.SubBase$Inner
      

      This is due to bridge methods for protected methods not being correctly generated (and subsequently used when writing protected method invocations.)

      Attachments

        Issue Links

          Activity

            People

              shils Shil Sinha
              shils Shil Sinha
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: