[ https://issues.apache.org/jira/browse/GROOVY-6498?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-6498: -------------------------------- Description: If a class has a static initializer, it is not called before static properties are resolved or before propertyMissing is called. This was not a problem in Groovy 1.8. Example 1: {code:groovy} class Config1 { private static props = [ x: 1 ] static { Config1.metaClass.static.propertyMissing = { name -> props[name] } } } println Config1.x {code} Result in Groovy 1.8: 1 Result in Groovy 2.2: exception Example 2: {code:groovy} class Config2 { private static props = [ y: 1 ] static { Config2.metaClass.static.getY = { -> props.y } } } println Config2.y {code} Result in Groovy 1.8: 1 Result in Groovy 2.2: exception was: If a class has a static initializer, it is not called before static properties are resolved or before propertyMissing is called. This was not a problem in Groovy 1.8. Example 1: class Config1 { private static props = [ x: 1 ] static { Config1.metaClass.static.propertyMissing = { name -> props[name] } } } println Config1.x Result in Groovy 1.8: 1 Result in Groovy 2.2: exception Example 2: class Config2 { private static props = [ y: 1 ] static { Config2.metaClass.static.getY = { -> props.y } } } println Config2.y Result in Groovy 1.8: 1 Result in Groovy 2.2: exception > Static initializer not called before static property resolution > --------------------------------------------------------------- > > Key: GROOVY-6498 > URL: https://issues.apache.org/jira/browse/GROOVY-6498 > Project: Groovy > Issue Type: Bug > Components: groovy-runtime > Affects Versions: 2.2.1, 2.4.0-rc-1 > Environment: Windows > Reporter: Thornton Rose > Priority: Major > > If a class has a static initializer, it is not called before static > properties are resolved or before propertyMissing is called. This was not a > problem in Groovy 1.8. > Example 1: > {code:groovy} > class Config1 { > private static props = [ x: 1 ] > static { > Config1.metaClass.static.propertyMissing = { name -> props[name] } > } > } > println Config1.x > {code} > Result in Groovy 1.8: 1 > Result in Groovy 2.2: exception > Example 2: > {code:groovy} > class Config2 { > private static props = [ y: 1 ] > static { Config2.metaClass.static.getY = { -> props.y } } > } > println Config2.y > {code} > Result in Groovy 1.8: 1 > Result in Groovy 2.2: exception -- This message was sent by Atlassian Jira (v8.20.10#820010)