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

Unable to access static getter method as field

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.1, 3.0.2
    • 3.0.3
    • groovy-runtime
    • None

    Description

      The field-like access for a static property does not work anymore. Following is the sample code which works in Groovy 2.x but fails in Groovy 3:

      class MongoEntity {
          static String getDB() { "default" }
      }
      MongoEntity.DB // //throws groovy.lang.MissingPropertyException: No such property: DB for class: MongoEntity
      

      Please note that if I change the method to getDb() then I can access the property as MongoEntity.db. Also, it works when `getDB()` is an instance method.

      Attachments

        Activity

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

          People

            paulk Paul King
            behlp Puneet Behl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment