Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2503 MOP 2.0 design inflluencing issues
  3. GROOVY-1327

Closures in a derived class can't access package private fields of the base class in the same package.

Attach filesAttach ScreenshotVotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-6
    • None
    • groovy-runtime
    • None
    • A recent build of 1.0-RC1

    Description

      Java:
      public class A

      { String greeting = "Hello" }

      Groovy
      class B extends A { doGreet =

      { println greeting }

      }
      new B().doGreet().call()

      Both A and B are in the same package.
      Code in the closure will throw a MissingPropertyException, as greeting is not accessible but it should be.
      Changing this to either protected or public is a workaround.

      Attached test cases perform various visibilty tests.

      Attachments

        Issue Links

        Activity

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

          People

            Unassigned Unassigned
            emp Edward Povazan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment