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

Add new metaClass property to all objects to unify access to meta class across instances

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0, 1.1-beta-1, 1.1-beta-2, 1.1-beta-3
    • 1.1-rc-1
    • None
    • None

    Description

      Currently you have to check before hand if an object is a GroovyObject and then have selective logic to obtain the MetaClass:

      def metaClass
      if(obj instanceof GroovyObject) metaClass = obj.metaClass
      else {
        metaClass = GroovySystem.metaClassRegistry.getMetaClass(obj.class)
      }
      

      This is ugly and error prone. There should be a property on all objects that simplifies this logic to just:

      def metaClass = obj.metaClass
      

      Attachments

        Activity

          People

            graemerocher Graeme Rocher
            graemerocher Graeme Rocher
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: