Affects Version/s: 1.8.6, 2.0-beta-3
Fix Version/s: None
Mac OSX 10.6.8
Groovy versions tested:
Groovy Version: 2.0.0-beta-3-SNAPSHOT JVM: 1.6.0_29
Groovy Version: 1.8.6 JVM: 1.6.0_29
Groovy Version: 1.7.10 JVM: 1.6.0_29
It seems Groovy does not have a predictable behavior for reading static fields
on sub-interfaces which "hide" a field from their super-interface.
You would expect, based on Java's behavior, that IB.NAME should always equal "IB",
but groovy sometimes gives "IB" and sometimes "IA."
This seems to happen whether the interface is defined in Java or groovy, and whether or
not the field is static/final.
However, it does seem to only happen with interfaces, not with classes.
i.e. the following works as expected:
B.NAME will always give "B" in that case.
See attached test case in bug.zip (unzip bug.zip, cd into 'bug' directory, run test_java.sh and test_groovy.sh)
test_java.sh shows the behavior you get from Java, which is the behavior I would expect, and test_groovy.sh shows the actual behavior (sometimes prints "A", sometimes prints "B"). I can't find any pattern to the wrong behavior. Seems like it's just luck of the draw as to which field gets read (sub-interface or super-interface).