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
Activity
Guillaume Laforge
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Priority | Major [ 3 ] | Blocker [ 1 ] |
| Fix Version/s | 1.7-rc-2 [ 16011 ] |
Roshan Dawrani
made changes -
| Assignee | Roshan Dawrani [ roshandawrani ] |
Roshan Dawrani
made changes -
| Fix Version/s | 1.8-beta-x [ 15750 ] | |
| Fix Version/s | 1.7.0 [ 14665 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 1.7.X [ 15538 ] | |
| Resolution | Fixed [ 1 ] | |
| Fix Version/s | 1.7-rc-2 [ 16011 ] |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Paul King
made changes -
| Resolution | Fixed [ 1 ] | |
| Status | Closed [ 6 ] | Reopened [ 4 ] |
Paul King
made changes -
| Fix Version/s | 1.7.0 [ 14665 ] | |
| Fix Version/s | 1.7.X [ 15538 ] | |
| Fix Version/s | 1.8-beta-x [ 15750 ] | |
| Fix Version/s | 1.7-rc-2 [ 16011 ] |
Paul King
made changes -
| Status | Reopened [ 4 ] | Closed [ 6 ] |
| Resolution | Fixed [ 1 ] |
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.