[ https://issues.apache.org/jira/browse/GROOVY-8398?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
jacob shnaidman updated GROOVY-8398: ------------------------------------ Description: The following code fails in two unexpected ways: {code:java} class PropClass { String myString = 'groovyClass' String otherProp = 'other Property' void myMethod() { //do nothing } void registerMethod(Closure closure) { this.metaClass.myMethod = closure } def getProperty(String name) { if (name == 'otherProp') //forward the request to getter return metaClass.getProperty(this, name) else if (name == 'myString') { return 'myString' } else return "new var $name" } } PropClass properties = new PropClass() //this shouldn't fail GroovyAssert.shouldFail { println properties.metaClass.getAttribute(properties, 'myString') } // and this shouldn't fail properties.registerMethod { -> println 'this fails' } {code} This happens whenever you override getProperties was: The following code fails in two unexpected ways: {code:java} class PropClass { String myString = 'groovyClass' String otherProp = 'other Property' void myMethod() { //do nothing } void registerMethod(Closure closure) { this.metaClass.myMethod = closure } def getProperty(String name) { if (name == 'otherProp') //forward the request to getter return metaClass.getProperty(this, name) else if (name == 'myString') { return 'myString' } else return "new var $name" } } PropClass properties = new PropClass() GroovyAssert.shouldFail { println properties.metaClass.getAttribute(properties, 'myString') } properties.registerMethod { -> println 'this fails' } {code} This happens whenever you override getProperties > Overriding getProperty makes getAttribute throw missing property exception > -------------------------------------------------------------------------- > > Key: GROOVY-8398 > URL: https://issues.apache.org/jira/browse/GROOVY-8398 > Project: Groovy > Issue Type: Bug > Affects Versions: 2.4.12 > Environment: Ubuntu > Reporter: jacob shnaidman > > The following code fails in two unexpected ways: > {code:java} > class PropClass { > String myString = 'groovyClass' > String otherProp = 'other Property' > void myMethod() { > //do nothing > } > void registerMethod(Closure closure) { > this.metaClass.myMethod = closure > } > def getProperty(String name) { > if (name == 'otherProp') > //forward the request to getter > return metaClass.getProperty(this, name) > else if (name == 'myString') { > return 'myString' > } > else > return "new var $name" > } > } > PropClass properties = new PropClass() > //this shouldn't fail > GroovyAssert.shouldFail { > println properties.metaClass.getAttribute(properties, 'myString') > } > // and this shouldn't fail > properties.registerMethod { -> > println 'this fails' > } > {code} > This happens whenever you override getProperties -- This message was sent by Atlassian JIRA (v6.4.14#64029)