ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/JSR166TestCase.java
(Generate patch)

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.209 by jsr166, Sun Nov 6 05:00:55 2016 UTC vs.
Revision 1.212 by jsr166, Fri Dec 9 04:24:07 2016 UTC

# Line 9 | Line 9
9   /*
10   * @test
11   * @summary JSR-166 tck tests
12 < * @modules java.management
12 > * @modules java.base/java.util.concurrent:open
13 > *          java.management
14   * @build *
15   * @run junit/othervm/timeout=1000 -Djsr166.testImplementationDetails=true JSR166TestCase
16   * @run junit/othervm/timeout=1000 -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 -Djsr166.testImplementationDetails=true JSR166TestCase
# Line 1828 | Line 1829 | public class JSR166TestCase extends Test
1829          }
1830      }
1831  
1832 <    void assertImmutable(Object o) {
1832 >    void assertImmutable(final Object o) {
1833          if (o instanceof Collection) {
1834              assertThrows(
1835                  UnsupportedOperationException.class,
# Line 1853 | Line 1854 | public class JSR166TestCase extends Test
1854      }
1855  
1856      /**
1857 +     * A version of serialClone that leaves error handling (for
1858 +     * e.g. NotSerializableException) up to the caller.
1859 +     */
1860 +    @SuppressWarnings("unchecked")
1861 +    <T> T serialClonePossiblyFailing(T o)
1862 +        throws ReflectiveOperationException, java.io.IOException {
1863 +        ByteArrayOutputStream bos = new ByteArrayOutputStream();
1864 +        ObjectOutputStream oos = new ObjectOutputStream(bos);
1865 +        oos.writeObject(o);
1866 +        oos.flush();
1867 +        oos.close();
1868 +        ObjectInputStream ois = new ObjectInputStream
1869 +            (new ByteArrayInputStream(bos.toByteArray()));
1870 +        T clone = (T) ois.readObject();
1871 +        if (o == clone) assertImmutable(o);
1872 +        assertSame(o.getClass(), clone.getClass());
1873 +        return clone;
1874 +    }
1875 +
1876 +    /**
1877       * If o implements Cloneable and has a public clone method,
1878       * returns a clone of o, else null.
1879       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines