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

          Russel Winder created issue -
          Guillaume Delcroix made changes -
          Field Original Value New Value
          Assignee Guillaume Laforge [ guillaume ]
          Jochen Theodorou made changes -
          Assignee Jochen Theodorou [ blackdrag ]
          Paul King made changes -
          Link This issue relates to GROOVY-1475 [ GROOVY-1475 ]
          Paul King made changes -
          Link This issue is duplicated by GROOVY-1416 [ GROOVY-1416 ]
          Paul King made changes -
          Link This issue is duplicated by GROOVY-2752 [ GROOVY-2752 ]
          Jochen Theodorou made changes -
          Fix Version/s 1.7-beta-1 [ 14014 ]
          Guillaume Delcroix made changes -
          Fix Version/s 1.7-beta-1 [ 14014 ]
          Fix Version/s 1.7-beta-x [ 15538 ]
          Martin C. Martin made changes -
          Link This issue is related to GROOVY-3088 [ GROOVY-3088 ]
          Martin C. Martin made changes -
          Link This issue relates to GROOVY-3088 [ GROOVY-3088 ]
          Jochen Theodorou made changes -
          Parent GROOVY-4681 [ 121966 ]
          Issue Type Bug [ 1 ] Sub-task [ 7 ]
          Jochen Theodorou made changes -
          Fix Version/s 1.7.x [ 15538 ]
          Jochen Theodorou made changes -
          Component/s Compiler [ 13529 ]
          Cédric Champeau made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.5.0-beta-1 [ 20927 ]
          Assignee blackdrag blackdrag [ blackdrag ] Cédric Champeau [ melix ]
          Resolution Fixed [ 1 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Mark Thomas made changes -
          Workflow jira [ 12730758 ] Default workflow, editable Closed status [ 12742579 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12968972 ] Default workflow, editable Closed status [ 12976749 ]

            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