8 |
|
|
9 |
|
/* |
10 |
|
* @test |
11 |
< |
* @summary JSR-166 tck tests |
11 |
> |
* @summary JSR-166 tck tests (conformance testing mode) |
12 |
> |
* @build * |
13 |
|
* @modules java.management |
14 |
+ |
* @run junit/othervm/timeout=1000 JSR166TestCase |
15 |
+ |
*/ |
16 |
+ |
|
17 |
+ |
/* |
18 |
+ |
* @test |
19 |
+ |
* @summary JSR-166 tck tests (whitebox tests allowed) |
20 |
|
* @build * |
21 |
< |
* @run junit/othervm/timeout=1000 -Djsr166.testImplementationDetails=true JSR166TestCase |
22 |
< |
* @run junit/othervm/timeout=1000 -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 -Djsr166.testImplementationDetails=true JSR166TestCase |
23 |
< |
* @run junit/othervm/timeout=1000 -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -Djava.util.secureRandomSeed=true JSR166TestCase |
21 |
> |
* @modules java.base/java.util.concurrent:open |
22 |
> |
* java.management |
23 |
> |
* @run junit/othervm/timeout=1000 |
24 |
> |
* -Djsr166.testImplementationDetails=true |
25 |
> |
* JSR166TestCase |
26 |
> |
* @run junit/othervm/timeout=1000 |
27 |
> |
* -Djsr166.testImplementationDetails=true |
28 |
> |
* -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 |
29 |
> |
* JSR166TestCase |
30 |
> |
* @run junit/othervm/timeout=1000 |
31 |
> |
* -Djsr166.testImplementationDetails=true |
32 |
> |
* -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 |
33 |
> |
* -Djava.util.secureRandomSeed=true |
34 |
> |
* JSR166TestCase |
35 |
|
*/ |
36 |
|
|
37 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
1871 |
|
} |
1872 |
|
|
1873 |
|
/** |
1874 |
+ |
* A version of serialClone that leaves error handling (for |
1875 |
+ |
* e.g. NotSerializableException) up to the caller. |
1876 |
+ |
*/ |
1877 |
+ |
@SuppressWarnings("unchecked") |
1878 |
+ |
<T> T serialClonePossiblyFailing(T o) |
1879 |
+ |
throws ReflectiveOperationException, java.io.IOException { |
1880 |
+ |
ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
1881 |
+ |
ObjectOutputStream oos = new ObjectOutputStream(bos); |
1882 |
+ |
oos.writeObject(o); |
1883 |
+ |
oos.flush(); |
1884 |
+ |
oos.close(); |
1885 |
+ |
ObjectInputStream ois = new ObjectInputStream |
1886 |
+ |
(new ByteArrayInputStream(bos.toByteArray())); |
1887 |
+ |
T clone = (T) ois.readObject(); |
1888 |
+ |
if (o == clone) assertImmutable(o); |
1889 |
+ |
assertSame(o.getClass(), clone.getClass()); |
1890 |
+ |
return clone; |
1891 |
+ |
} |
1892 |
+ |
|
1893 |
+ |
/** |
1894 |
|
* If o implements Cloneable and has a public clone method, |
1895 |
|
* returns a clone of o, else null. |
1896 |
|
*/ |