Details
-
Type:
Sub-task
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Ubuntu 6.10 Edgy Eft + Groovy r4630
-
Number of attachments :
Description
The following code appears to show that final is being applied inconsistently. A final list can be amended but an object that manipulates a lsit that is final cannot. In the former case the final is being applied to the reference and in the later, it is being applied to the object.
class Blah {
def list = []
public plus ( item ) {
list += [ item ]
return this
}
}
class Foobar {
final static blah = new Blah ( )
}
final x = []
x += [1]
println ( x )
Foobar.blah += 1
println ( Foobar.blah.list )
| > groovy finalProblem.groovy [1] Caught: java.lang.IllegalAccessException: Field is final at finalProblem.run(finalProblem.groovy:17) at finalProblem.main(finalProblem.groovy) |
Issue Links
- is duplicated by
-
GROOVY-2752
final keyword does not work
-
-
GROOVY-1416
final modifier ignored in scripts
-
- is related to
-
GROOVY-3088
Modifiers on local variables are ignored
-
- relates to
-
GROOVY-1475
final modifier on a method parameter is not respected
-
-
GROOVY-3088
Modifiers on local variables are ignored
-
Activity
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Guillaume Laforge [ guillaume ] |
| Assignee | Jochen Theodorou [ blackdrag ] |
| Link |
This issue relates to |
| Link |
This issue is duplicated by |
| Link |
This issue is duplicated by |
| Fix Version/s | 1.7-beta-1 [ 14014 ] |
| Fix Version/s | 1.7-beta-x [ 15538 ] | |
| Fix Version/s | 1.7-beta-1 [ 14014 ] |
| Link |
This issue is related to |
| Link |
This issue relates to |
| Parent | GROOVY-4681 [ 121966 ] | |
| Issue Type | Bug [ 1 ] | Sub-task [ 7 ] |
| Fix Version/s | 1.7.x [ 15538 ] |