Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3882

"final" not working as expected

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.7-beta-2
    • 1.7-rc-1
    • None
    • None

    Description

      neither final properties nor final fields are shielded from mutation if the mutator is a method in the same object.

      class Person {
          final String name = "scott"
          def foo() {
              name = "Dierk"
          }
      }
      def p =  new Person()
      p.foo()
      assert "Dierk" != p.name
      
      // credits: Scott Davis  
      

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            codevise Dierk König
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: