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.210 by jsr166, Mon Nov 7 01:59:17 2016 UTC vs.
Revision 1.211 by jsr166, Mon Nov 14 23:52:22 2016 UTC

# Line 1853 | Line 1853 | public class JSR166TestCase extends Test
1853      }
1854  
1855      /**
1856 +     * A version of serialClone that leaves error handling (for
1857 +     * e.g. NotSerializableException) up to the caller.
1858 +     */
1859 +    @SuppressWarnings("unchecked")
1860 +    <T> T serialClonePossiblyFailing(T o)
1861 +        throws ReflectiveOperationException, java.io.IOException {
1862 +        ByteArrayOutputStream bos = new ByteArrayOutputStream();
1863 +        ObjectOutputStream oos = new ObjectOutputStream(bos);
1864 +        oos.writeObject(o);
1865 +        oos.flush();
1866 +        oos.close();
1867 +        ObjectInputStream ois = new ObjectInputStream
1868 +            (new ByteArrayInputStream(bos.toByteArray()));
1869 +        T clone = (T) ois.readObject();
1870 +        if (o == clone) assertImmutable(o);
1871 +        assertSame(o.getClass(), clone.getClass());
1872 +        return clone;
1873 +    }
1874 +
1875 +    /**
1876       * If o implements Cloneable and has a public clone method,
1877       * returns a clone of o, else null.
1878       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines