We should never throw a VerifyError, so that is a bug. But you probably don't want to use "this" in a static context. You probably just want $q.metaClass or ${getMetaClass()}.
Cheers, Paul. On Fri, Jun 5, 2020 at 9:33 PM OCsite <o...@ocs.cz> wrote: > And another thing which I don't understand and seems highly suspicious — > do I just miss something of importance, or is it a bug? > > === > 127 ocs */tmp>* <q.groovy > class q { > static main(av) { > println "my MC is $this.metaClass" > } > } > 128 ocs */tmp>* /usr/local/groovy-3.0.4/bin/groovy q > Caught: java.lang.VerifyError: Bad type on operand stack > Exception Details: > Location: > q.main([Ljava/lang/String;)V @21: getfield > Reason: > Type '[Ljava/lang/String;' (current frame, stack[7]) is not assignable > to 'q' > Current Frame: > bci: @21 > flags: { } > locals: { '[Ljava/lang/String;', > '[Lorg/codehaus/groovy/runtime/callsite/CallSite;' } > stack: { 'org/codehaus/groovy/runtime/callsite/CallSite', > 'java/lang/Class', uninitialized 10, uninitialized 10, > '[Ljava/lang/Object;', '[Ljava/lang/Object;', integer, > '[Ljava/lang/String;' } > Bytecode: > 0000000: b800 144c 2b12 2132 1202 bb00 2359 04bd > 0000010: 0004 5903 2ab4 001c 5305 bd00 2559 0312 > 0000020: 2753 5904 1229 53b7 002c b900 3203 0057 > 0000030: b1 > > java.lang.VerifyError: Bad type on operand stack > Exception Details: > Location: > q.main([Ljava/lang/String;)V @21: getfield > Reason: > Type '[Ljava/lang/String;' (current frame, stack[7]) is not assignable > to 'q' > Current Frame: > bci: @21 > flags: { } > locals: { '[Ljava/lang/String;', > '[Lorg/codehaus/groovy/runtime/callsite/CallSite;' } > stack: { 'org/codehaus/groovy/runtime/callsite/CallSite', > 'java/lang/Class', uninitialized 10, uninitialized 10, > '[Ljava/lang/Object;', '[Ljava/lang/Object;', integer, > '[Ljava/lang/String;' } > Bytecode: > 0000000: b800 144c 2b12 2132 1202 bb00 2359 04bd > 0000010: 0004 5903 2ab4 001c 5305 bd00 2559 0312 > 0000020: 2753 5904 1229 53b7 002c b900 3203 0057 > 0000030: b1 > > 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) > 129 ocs */tmp>* > === > > On 27 May 2020, at 23:42, o...@ocs.cz wrote: > > 484 ocs /tmp> <q.groovy > class q { > static main(av) { > new Foo().test() > } > } > class Foo extends Root { } > class Root { > private _objects=[] > void test() { > println "this is OK" > _objects<<'hi' > println "this crashes" > 1.times { _objects<<it } > } > } > 485 ocs /tmp> /usr/local/groovy-3.0.4/bin/groovy q > this is OK > this crashes > Caught: groovy.lang.MissingPropertyException: No such property: _objects > for class: Foo > groovy.lang.MissingPropertyException: No such property: _objects for > class: Foo > at Root$_test_closure1.doCall(q.groovy:13) > at Root.test(q.groovy:13) > at Root$test.call(Unknown Source) > at q.main(q.groovy:3) > 486 ocs /tmp> > > >