--- jsr166/src/test/tck/JSR166TestCase.java 2016/11/06 05:00:55 1.209 +++ jsr166/src/test/tck/JSR166TestCase.java 2016/12/09 07:26:04 1.214 @@ -8,12 +8,30 @@ /* * @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 * - * @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 + * @modules java.base/java.util.concurrent:open + * java.management + * @run junit/othervm/timeout=1000 + * -Djsr166.testImplementationDetails=true + * JSR166TestCase + * @run junit/othervm/timeout=1000 + * -Djsr166.testImplementationDetails=true + * -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 + * JSR166TestCase + * @run junit/othervm/timeout=1000 + * -Djsr166.testImplementationDetails=true + * -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 + * -Djava.util.secureRandomSeed=true + * JSR166TestCase */ import static java.util.concurrent.TimeUnit.MILLISECONDS; @@ -1828,7 +1846,7 @@ public class JSR166TestCase extends Test } } - void assertImmutable(Object o) { + void assertImmutable(final Object o) { if (o instanceof Collection) { assertThrows( UnsupportedOperationException.class, @@ -1853,6 +1871,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. */