groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ocs@ocs" <...@ocs.cz>
Subject static block called too late for installing a propertyMissing (sans indy only)
Date Sat, 18 Aug 2018 14:23:54 GMT
Ladies and gentlemen,

I have bumped into another suspicious behaviour: is this all right? Happens both with 2.4
and 3.0 same way.

Thanks and all the best,
OC

===
717 /tmp> <q.groovy                                            
class zz {
  static {
    println "propertyMissing installed to $this"
    zz.metaClass.static.propertyMissing={ println "prop $it OK" }
  }
}
zz.bar // sans indy, crashes before static called and propertyMissing installed
718 /tmp> /usr/local/groovy-3.0.0-alpha-3/bin/groovy q       
WARNING: Using incubator modules: jdk.incubator.httpclient
Caught: groovy.lang.MissingPropertyException: No such property: bar for class: zz
groovy.lang.MissingPropertyException: No such property: bar for class: zz
	at q.run(q.groovy:7)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
719 /tmp> /usr/local/groovy-3.0.0-alpha-3/bin/groovy --indy q
WARNING: Using incubator modules: jdk.incubator.httpclient
propertyMissing installed to class zz
prop bar OK
720 /tmp> 
===
Mime
View raw message