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