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

@Immutable annotation should allow Cloneable fields

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8.8, 2.0.2
    • 2.0.5, 2.1.0-beta-1, 1.8.9
    • Static compilation
    • None
    • JDK 1.6, Linux, Groovy 1.8.8 and 2.0.2

    Description

      Classes like the following:

      @Immutable public class Cell {
      Cloneable data;
      Cell next;
      }

      fail to compile with this error message:

      @Immutable processor doesn't know how to handle field 'data' of type 'java.lang.Cloneable' while compiling class Cell.
      @Immutable classes only support properties with effectively immutable types including:

      • Strings, primitive types, wrapper types, BigInteger and BigDecimal, enums
      • other @Immutable classes and known immutables (java.awt.Color, java.net.URI)
      • Cloneable classes, collections, maps and arrays, and other classes with special handling (java.util.Date)
        Other restrictions apply, please see the groovydoc for @Immutable for further details

      The implementation should be able to guarantee immutability for the Cloneable member by using the clone() method appropriately.

      Attachments

        Activity

          People

            paulk Paul King
            davidclark David Clark
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: