--- jsr166/src/test/tck/JSR166TestCase.java 2011/06/22 07:46:57 1.90 +++ jsr166/src/test/tck/JSR166TestCase.java 2011/12/08 18:54:46 1.91 @@ -1202,16 +1202,33 @@ public class JSR166TestCase extends Test } } - @SuppressWarnings("unchecked") - T serialClone(T o) { + void assertSerialEquals(Object x, Object y) { + assertTrue(Arrays.equals(serialBytes(x), serialBytes(y))); + } + + void assertNotSerialEquals(Object x, Object y) { + assertFalse(Arrays.equals(serialBytes(x), serialBytes(y))); + } + + byte[] serialBytes(Object o) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(o); oos.flush(); oos.close(); + return bos.toByteArray(); + } catch (Throwable t) { + threadUnexpectedException(t); + return new byte[0]; + } + } + + @SuppressWarnings("unchecked") + T serialClone(T o) { + try { ObjectInputStream ois = new ObjectInputStream - (new ByteArrayInputStream(bos.toByteArray())); + (new ByteArrayInputStream(serialBytes(o))); T clone = (T) ois.readObject(); assertSame(o.getClass(), clone.getClass()); return clone;