Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5.0-alpha-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)

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: