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

Non writeable properties witreable

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0
    • 1.1-beta-1
    • class generator
    • None
    • Windows XP Pro

    Description

      class Bidule implements Serializable {
      String a
      final String b = 'final'
      }

      x = new Bidule()
      x.b = 'not final any more'
      println x.b // The result is 'not final any more'

      // Groovy in Action p.201 : "When the final keyword is used with a property declaration, the property will only be readable (no setter method is created and the backing filed is final)

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            blackdrag Jochen Theodorou
            louis martin Louis Martin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment