< prev index next >

jdk/test/java/io/Serializable/failureAtomicity/FailureAtomicity.java

Print this page
rev 17249 : 8180887: move FileUtils to top level testlibrary
Reviewed-by: duke
   1 /*
   2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8071474
  27  * @summary Better failure atomicity for default read object.
  28  * @modules jdk.compiler
  29  * @library /lib/testlibrary
  30  * @build jdk.testlibrary.FileUtils
  31  * @compile FailureAtomicity.java SerialRef.java
  32  * @run main failureAtomicity.FailureAtomicity
  33  */
  34 
  35 package failureAtomicity;
  36 
  37 import java.io.ByteArrayInputStream;
  38 import java.io.ByteArrayOutputStream;
  39 import java.io.File;
  40 import java.io.IOException;
  41 import java.io.InputStream;
  42 import java.io.ObjectInputStream;
  43 import java.io.ObjectOutputStream;
  44 import java.io.ObjectStreamClass;
  45 import java.io.UncheckedIOException;
  46 import java.lang.reflect.Constructor;
  47 import java.net.URL;
  48 import java.net.URLClassLoader;
  49 import java.nio.file.Files;
  50 import java.nio.file.Path;
  51 import java.nio.file.Paths;
  52 import java.util.ArrayList;
  53 import java.util.Arrays;
  54 import java.util.List;
  55 import java.util.function.BiConsumer;
  56 import java.util.stream.Collectors;
  57 import javax.tools.JavaCompiler;
  58 import javax.tools.JavaFileObject;
  59 import javax.tools.StandardJavaFileManager;
  60 import javax.tools.StandardLocation;
  61 import javax.tools.ToolProvider;
  62 import jdk.testlibrary.FileUtils;
  63 
  64 @SuppressWarnings("unchecked")
  65 public class FailureAtomicity {
  66     static final Path TEST_SRC = Paths.get(System.getProperty("test.src", "."));
  67     static final Path TEST_CLASSES = Paths.get(System.getProperty("test.classes", "."));
  68     static final Path fooTemplate = TEST_SRC.resolve("Foo.template");
  69     static final Path barTemplate = TEST_SRC.resolve("Bar.template");
  70 
  71     static final String[] PKGS = { "a.b.c", "x.y.z" };
  72 
  73     public static void main(String[] args) throws Exception {
  74         test_Foo();
  75         test_BadFoo();  // 'Bad' => incompatible type; cannot be "fully" deserialized
  76         test_FooWithReadObject();
  77         test_BadFooWithReadObject();
  78 
  79         test_Foo_Bar();
  80         test_Foo_BadBar();
  81         test_BadFoo_Bar();
  82         test_BadFoo_BadBar();


   1 /*
   2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8071474
  27  * @summary Better failure atomicity for default read object.
  28  * @modules jdk.compiler
  29  * @library /test/lib

  30  * @compile FailureAtomicity.java SerialRef.java
  31  * @run main failureAtomicity.FailureAtomicity
  32  */
  33 
  34 package failureAtomicity;
  35 
  36 import java.io.ByteArrayInputStream;
  37 import java.io.ByteArrayOutputStream;
  38 import java.io.File;
  39 import java.io.IOException;
  40 import java.io.InputStream;
  41 import java.io.ObjectInputStream;
  42 import java.io.ObjectOutputStream;
  43 import java.io.ObjectStreamClass;
  44 import java.io.UncheckedIOException;
  45 import java.lang.reflect.Constructor;
  46 import java.net.URL;
  47 import java.net.URLClassLoader;
  48 import java.nio.file.Files;
  49 import java.nio.file.Path;
  50 import java.nio.file.Paths;
  51 import java.util.ArrayList;
  52 import java.util.Arrays;
  53 import java.util.List;
  54 import java.util.function.BiConsumer;
  55 import java.util.stream.Collectors;
  56 import javax.tools.JavaCompiler;
  57 import javax.tools.JavaFileObject;
  58 import javax.tools.StandardJavaFileManager;
  59 import javax.tools.StandardLocation;
  60 import javax.tools.ToolProvider;
  61 import jdk.test.lib.util.FileUtils;
  62 
  63 @SuppressWarnings("unchecked")
  64 public class FailureAtomicity {
  65     static final Path TEST_SRC = Paths.get(System.getProperty("test.src", "."));
  66     static final Path TEST_CLASSES = Paths.get(System.getProperty("test.classes", "."));
  67     static final Path fooTemplate = TEST_SRC.resolve("Foo.template");
  68     static final Path barTemplate = TEST_SRC.resolve("Bar.template");
  69 
  70     static final String[] PKGS = { "a.b.c", "x.y.z" };
  71 
  72     public static void main(String[] args) throws Exception {
  73         test_Foo();
  74         test_BadFoo();  // 'Bad' => incompatible type; cannot be "fully" deserialized
  75         test_FooWithReadObject();
  76         test_BadFooWithReadObject();
  77 
  78         test_Foo_Bar();
  79         test_Foo_BadBar();
  80         test_BadFoo_Bar();
  81         test_BadFoo_BadBar();


< prev index next >