Details
-
Sub-task
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
Ubuntu 6.10 Edgy Eft + Groovy r4630
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) |
Attachments
Issue Links
- causes
-
GROOVY-9595 Groovy final keyword behaves more like Immutable, doesn't follow java's final keyword behaviour
-
- Closed
-
- is duplicated by
-
GROOVY-2752 final keyword does not work
-
- Closed
-
-
GROOVY-1416 final modifier ignored in scripts
-
- Closed
-
-
GROOVY-4681 implement final for local variables
-
- Closed
-
- is related to
-
GROOVY-3088 Modifiers on local variables are ignored
-
- Closed
-
- relates to
-
GROOVY-1475 final modifier on a method parameter is not respected
-
- Closed
-
-
GROOVY-3088 Modifiers on local variables are ignored
-
- Closed
-