--- jsr166/src/test/tck/JSR166TestCase.java 2016/11/07 01:59:17 1.210 +++ jsr166/src/test/tck/JSR166TestCase.java 2016/11/14 23:52:22 1.211 @@ -1853,6 +1853,26 @@ public class JSR166TestCase extends Test } /** + * A version of serialClone that leaves error handling (for + * e.g. NotSerializableException) up to the caller. + */ + @SuppressWarnings("unchecked") + T serialClonePossiblyFailing(T o) + throws ReflectiveOperationException, java.io.IOException { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(o); + oos.flush(); + oos.close(); + ObjectInputStream ois = new ObjectInputStream + (new ByteArrayInputStream(bos.toByteArray())); + T clone = (T) ois.readObject(); + if (o == clone) assertImmutable(o); + assertSame(o.getClass(), clone.getClass()); + return clone; + } + + /** * If o implements Cloneable and has a public clone method, * returns a clone of o, else null. */