--- jsr166/src/test/tck/JSR166TestCase.java 2016/11/05 16:09:50 1.208 +++ jsr166/src/test/tck/JSR166TestCase.java 2016/12/09 06:58:57 1.213 @@ -8,12 +8,20 @@ /* * @test - * @summary JSR-166 tck tests + * @summary JSR-166 tck tests (conformance testing mode) + * @build * * @modules java.management + * @run junit/othervm/timeout=1000 JSR166TestCase + */ + +/* + * @test + * @summary JSR-166 tck tests (whitebox tests allowed) * @build * + * @modules java.base/java.util.concurrent:open + * java.management * @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 - * @run junit/othervm/timeout=1000 -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -Djava.util.secureRandomSeed=true JSR166TestCase + * @run junit/othervm/timeout=1000 -Djsr166.testImplementationDetails=true -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 JSR166TestCase */ import static java.util.concurrent.TimeUnit.MILLISECONDS; @@ -1828,7 +1836,7 @@ public class JSR166TestCase extends Test } } - void assertImmutable(Object o) { + void assertImmutable(final Object o) { if (o instanceof Collection) { assertThrows( UnsupportedOperationException.class, @@ -1836,7 +1844,7 @@ public class JSR166TestCase extends Test ((Collection) o).add(null);}}); } } - + @SuppressWarnings("unchecked") T serialClone(T o) { try { @@ -1853,6 +1861,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. */