class Parent { final static String newLine = "*" } class Child extends Parent{ List body = [3, 4, 5] String toString() { def str = new StringBuilder() body.each { str.append(it + newLine) } str } } def c = new Child() println c
The above example is a trivial example illustrating the problem. It cannot be compiled using the Groovy plugin on Eclipse . Remove either final or static in the superclass field. However, I have no idea why this is so.
http://groovy.codehaus.org/Groovy+Beans This link mentions the rules for properties and fields used in Groovy. I believe that the one that was applied should be the last, i.e. Meta class. Unfortunately, I still could not understand the behavior.
The behavior is played sequentially in all versions of Groovy. Perhaps someone might report the error to the Groovy team. I have never done this before. It would be more effective if someone experienced this.
source share