Details

    • Type: Sub-task Sub-task
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5.0-beta-1
    • Component/s: Compiler
    • Labels:
      None
    • Environment:
      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)

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Cédric Champeau
              Reporter:
              Russel Winder
            • Votes:
              4 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development