title: Groovy @Immutable class with (im)mutable property
body: <p>I'm trying to use Groovy <code>@groovy.transform.Immutable</code> to implement classes with properties of unsupported "immutable" types. In my case it is <code>java.io.File</code></p>
  
  <p>For example, having class like</p>
  
  <pre><code>@groovy.transform.Immutable class TwoFiles {
      File file1,file2
  }
  </code></pre>
  
  <p>gives me following compile error</p>
  
  <blockquote>
    <p>Groovyc: @Immutable processor doesn't know how to handle field 'file1' of type 'java.io.File' while compiling class TwoFiles.
        @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</p>
  </blockquote>
  
  <p>One option I found it to extend <code>java.io.File</code> to make it <code>Cloneable</code> but I'm not happy with this solution. Following code compiles and works, but having own subclass of <code>java.io.File</code> is not what I'd like.</p>
  
  <pre><code>@groovy.transform.Immutable class TwoCloneableFiles {
      FileCloneable file1,file2
  
      class FileCloneable extends File implements Cloneable{
  
          FileCloneable(String s) {
              super(s)
          }
  
          // ... and other constructors ...
      }
  }
  </code></pre>
  
  <p>So my question is: Is there any other option how to use <code>java.io.File</code> <em>directly</em> in such class?</p>
  
  <p>Possibly to mark <code>java.io.File</code> as "known immutable" for the purpose of <code>@groovy.transform.Immutable</code> (same as it seems to be done for <code>java.awt.Color</code>, <code>java.net.URI</code>)?</p>