title: is it possible to mock transient fields in tests?
body: <p>I have a class that contains a transient field. But the other part of the class is serializable.
  In the tests I mock the field and the class and use the mocked class object in a deep copy function which looks like below:</p>
  
  <pre><code>try {
        final ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
        objectOut = new ObjectOutputStream(bytesOut);
        // serialize and pass the object
        objectOut.writeObject(original);
        objectOut.flush();
        final ByteArrayInputStream bytesIn =
            new ByteArrayInputStream(bytesOut.toByteArray());
        objectIn = new ObjectInputStream(bytesIn);
        @SuppressWarnings("unchecked")
        final T clone = (T) objectIn.readObject();
        // return the new object
        return clone;
      }
  catch () {...}
  </code></pre>
  
  <p>the writeObject(original) method is supposed to write all non-transient and non-static fields. But I've got an error saying java.io.NotSerializableException for the mock transient field. I wonder if the transient field cannot be recognised in the tests? I use mockito as my framework.</p>