--- jsr166/src/test/tck/JSR166TestCase.java 2016/11/06 05:00:55 1.209 +++ jsr166/src/test/tck/JSR166TestCase.java 2016/12/09 04:24:07 1.212 @@ -9,7 +9,8 @@ /* * @test * @summary JSR-166 tck tests - * @modules java.management + * @modules java.base/java.util.concurrent:open + * java.management * @build * * @run junit/othervm/timeout=1000 -Djsr166.testImplementationDetails=true JSR166TestCase * @run junit/othervm/timeout=1000 -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 -Djsr166.testImplementationDetails=true JSR166TestCase @@ -1828,7 +1829,7 @@ public class JSR166TestCase extends Test } } - void assertImmutable(Object o) { + void assertImmutable(final Object o) { if (o instanceof Collection) { assertThrows( UnsupportedOperationException.class, @@ -1853,6 +1854,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. */