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

@Immutable collection members are apparently mutable (sometimes?)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.6, 2.0.5
    • 2.2.2
    • xforms
    • None
    • Ubuntu Precise
      Groovy Version: 1.8.6 JVM: 1.6.0_27 Vendor: Sun Microsystems Inc. OS: Linux
      Groovy Version: 2.0.5 JVM: 1.7.0_25 Vendor: Oracle Corporation OS: Linux

    Description

      Given these classes:

      @Immutable class X

      { Collection c = [] }

      @Immutable class Y

      { Collection c = []; int foo = 1 }

      I get this behaviour:

      x = new X(null); x.c << 1; // UnsupportedOperationException
      y= new Y(null); y.c << 1; // Success !?
      println y; // Y([1], 0)

      See also the discussion with the same subject on the mailing list.

      Attachments

        Activity

          People

            paulk Paul King
            wu-lee Nick Stokoe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: