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

Unable to access static getter method as field

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.1, 3.0.2
    • Fix Version/s: 3.0.3
    • Component/s: groovy-runtime
    • Labels:
      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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: