Details
Description
I'm just checking if this is intended .... as it seems a difference from 1.7beta2 and also a difference from pure java.
This compiles under javac:
class A {
static final String foo;
static {
if (true) {
foo = "roshan";
} else {
foo = "jochen";
}
}
}
and it compiles under 1.7beta2, but under 1.7rc1 I get:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: A.groovy: 7: cannnot access final field or property outside of constructor. @ line 7, column 7. foo = "roshan"; ^ A.groovy: 9: cannnot access final field or property outside of constructor. @ line 9, column 7. foo = "jochen"; ^ 2 errors
I think it is a bug - when the final variable is static, it should be allowed to be set in static constructor - same as instance level final variables are allowed to be set in non-static constructors.