changeset 3481:31c2308a7150

8046824: class SJavacTestUtil and *Wrapper are redundant and should be removed Reviewed-by: ksrini
author jjg
date Mon, 14 Jul 2014 11:46:31 -0700
parents dc0620fc24c6
children 14a0a4a35bf2
files test/tools/sjavac/ExclPattern.java test/tools/sjavac/ExclPatternWrapper.java test/tools/sjavac/IgnoreSymbolFile.java test/tools/sjavac/JavacOptionPrep.java test/tools/sjavac/JavacOptionPrepWrapper.java test/tools/sjavac/OptionDecoding.java test/tools/sjavac/OptionDecodingWrapper.java test/tools/sjavac/SJavac.java test/tools/sjavac/SJavacTestUtil.java test/tools/sjavac/SJavacWrapper.java test/tools/sjavac/Serialization.java test/tools/sjavac/SerializationWrapper.java test/tools/sjavac/Wrapper.java
diffstat 13 files changed, 120 insertions(+), 261 deletions(-) [+]
line wrap: on
line diff
--- a/test/tools/sjavac/ExclPattern.java	Mon Jul 14 13:36:30 2014 -0400
+++ b/test/tools/sjavac/ExclPattern.java	Mon Jul 14 11:46:31 2014 -0700
@@ -23,6 +23,16 @@
  * questions.
  */
 
+
+/*
+ * @test
+ * @bug 8037085
+ * @summary Ensures that sjavac can handle various exclusion patterns.
+ *
+ * @build Wrapper
+ * @run main Wrapper ExclPattern
+ */
+
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.nio.charset.Charset;
--- a/test/tools/sjavac/ExclPatternWrapper.java	Mon Jul 14 13:36:30 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8037085
- * @summary Ensures that sjavac can handle various exclusion patterns.
- * @run main ExclPatternWrapper
- */
-public class ExclPatternWrapper {
-    public static void main(String... args) throws Exception {
-        SJavacTestUtil.runSjavacTest("ExclPattern", args);
-    }
-}
--- a/test/tools/sjavac/IgnoreSymbolFile.java	Mon Jul 14 13:36:30 2014 -0400
+++ b/test/tools/sjavac/IgnoreSymbolFile.java	Mon Jul 14 11:46:31 2014 -0700
@@ -27,6 +27,9 @@
  * @test
  * @bug 8047183
  * @summary JDK build fails with sjavac enabled
+ *
+ * @build Wrapper
+ * @run main Wrapper IgnoreSymbolFile
  */
 
 import java.io.File;
@@ -38,12 +41,8 @@
 
 public class IgnoreSymbolFile {
     public static void main(String... args) throws Exception {
-        if (sjavacAvailable()) {
-            IgnoreSymbolFile test = new IgnoreSymbolFile();
-            test.run();
-        } else {
-            System.err.println("sjavac not available; test skipped");
-        }
+        IgnoreSymbolFile test = new IgnoreSymbolFile();
+        test.run();
     }
 
     void run() throws Exception {
@@ -96,13 +95,4 @@
     }
 
     int errors;
-
-    static boolean sjavacAvailable() {
-        try {
-            Class.forName("com.sun.tools.sjavac.Main");
-            return true;
-        } catch (ClassNotFoundException e) {
-            return false;
-        }
-    }
 }
--- a/test/tools/sjavac/JavacOptionPrep.java	Mon Jul 14 13:36:30 2014 -0400
+++ b/test/tools/sjavac/JavacOptionPrep.java	Mon Jul 14 11:46:31 2014 -0700
@@ -23,6 +23,15 @@
  * questions.
  */
 
+/*
+ * @test
+ * @bug 8035063
+ * @summary Tests the preparation of javac-arguments.
+ *
+ * @build Wrapper
+ * @run main Wrapper JavacOptionPrep
+ */
+
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
--- a/test/tools/sjavac/JavacOptionPrepWrapper.java	Mon Jul 14 13:36:30 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8035063
- * @summary Tests the preparation of javac-arguments.
- * @run main JavacOptionPrepWrapper
- */
-public class JavacOptionPrepWrapper {
-    public static void main(String... args) throws Exception {
-        SJavacTestUtil.runSjavacTest("JavacOptionPrep", args);
-    }
-}
--- a/test/tools/sjavac/OptionDecoding.java	Mon Jul 14 13:36:30 2014 -0400
+++ b/test/tools/sjavac/OptionDecoding.java	Mon Jul 14 11:46:31 2014 -0700
@@ -23,6 +23,15 @@
  * questions.
  */
 
+/*
+ * @test
+ * @bug 8035063
+ * @summary Tests decoding of String[] into Options.
+ *
+ * @build Wrapper
+ * @run main Wrapper OptionDecoding
+ */
+
 import static util.OptionTestUtil.assertEquals;
 import static util.OptionTestUtil.checkFilesFound;
 
--- a/test/tools/sjavac/OptionDecodingWrapper.java	Mon Jul 14 13:36:30 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8035063
- * @summary Tests decoding of String[] into Options.
- * @run main OptionDecodingWrapper
- */
-public class OptionDecodingWrapper {
-    public static void main(String... args) throws Exception {
-        SJavacTestUtil.runSjavacTest("OptionDecoding", args);
-    }
-}
--- a/test/tools/sjavac/SJavac.java	Mon Jul 14 13:36:30 2014 -0400
+++ b/test/tools/sjavac/SJavac.java	Mon Jul 14 11:46:31 2014 -0700
@@ -21,6 +21,16 @@
  * questions.
  */
 
+
+/*
+ * @test
+ * @summary Test all aspects of sjavac.
+ * @bug 8004658 8042441 8042699
+ *
+ * @build Wrapper
+ * @run main Wrapper SJavac
+ */
+
 import java.util.*;
 import java.io.*;
 import java.nio.file.*;
@@ -29,8 +39,7 @@
 
 import com.sun.tools.sjavac.Main;
 
-public
-class SJavac {
+public class SJavac {
 
     public static void main(String... args) throws Exception {
         try {
--- a/test/tools/sjavac/SJavacTestUtil.java	Mon Jul 14 13:36:30 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.File;
-import java.lang.reflect.Method;
-
-
-public class SJavacTestUtil {
-
-    public static void runSjavacTest(String testClassName, String[] args)
-            throws Exception {
-
-        if (!isSJavacOnClassPath()) {
-            System.out.println("sjavac not available: pass by default");
-            return;
-        }
-
-        File srcDir = new File(System.getProperty("test.src"));
-        File clsDir = new File(System.getProperty("test.classes"));
-
-        File src = new File(srcDir, testClassName + ".java");
-        File cls = new File(clsDir, testClassName + ".class");
-
-        if (cls.lastModified() < src.lastModified()) {
-            System.err.println("Recompiling test class...");
-            String[] javacArgs = { "-d", clsDir.getPath(), src.getPath() };
-            int rc = com.sun.tools.javac.Main.compile(javacArgs);
-            if (rc != 0)
-                throw new Exception("compilation failed");
-        }
-
-        Class<?> sjavac = Class.forName(testClassName);
-        Method main = sjavac.getMethod("main", String[].class);
-        main.invoke(null, new Object[] { args });
-
-    }
-
-    private static boolean isSJavacOnClassPath() {
-        String cls = "com/sun/tools/sjavac/Main.class";
-        return SJavacTestUtil.class.getClassLoader().getResource(cls) != null;
-    }
-}
--- a/test/tools/sjavac/SJavacWrapper.java	Mon Jul 14 13:36:30 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @summary Test all aspects of sjavac.
- *
- * @bug 8004658
- * @bug 8042441
- * @bug 8042699
- * @summary Add internal smart javac wrapper to solve JEP 139
- *
- * @run main SJavacWrapper
- */
-
-public class SJavacWrapper {
-    public static void main(String... args) throws Exception {
-        SJavacTestUtil.runSjavacTest("SJavac", args);
-    }
-}
--- a/test/tools/sjavac/Serialization.java	Mon Jul 14 13:36:30 2014 -0400
+++ b/test/tools/sjavac/Serialization.java	Mon Jul 14 11:46:31 2014 -0700
@@ -21,6 +21,18 @@
  * questions.
  */
 
+/*
+ * @test
+ * @bug 8035063
+ *
+ * @summary Tests serialization of options. The options needs to be serialized
+ *          and saved in the state file since the files need to be recompiled
+ *          if new options are provided.
+ *
+ * @build Wrapper
+ * @run main Wrapper Serialization
+ */
+
 import static util.OptionTestUtil.assertEquals;
 
 import java.io.IOException;
--- a/test/tools/sjavac/SerializationWrapper.java	Mon Jul 14 13:36:30 2014 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8035063
- *
- * @summary Tests serialization of options. The options needs to be serialized
- *          and saved in the state file since the files need to be recompiled
- *          if new options are provided.
- *
- * @run main SerializationWrapper
- */
-public class SerializationWrapper {
-    public static void main(String... args) throws Exception {
-        SJavacTestUtil.runSjavacTest("Serialization", args);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/sjavac/Wrapper.java	Mon Jul 14 11:46:31 2014 -0700
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
+
+public class Wrapper {
+    public static void main(String... args) throws Exception {
+        if (!isSJavacOnClassPath()) {
+            System.out.println("sjavac not available: pass by default");
+            return;
+        }
+
+        String testClassName = args[0];
+        String[] testArgs = Arrays.copyOfRange(args, 1, args.length);
+
+        File srcDir = new File(System.getProperty("test.src"));
+        File clsDir = new File(System.getProperty("test.classes"));
+
+        File src = new File(srcDir, testClassName + ".java");
+        File cls = new File(clsDir, testClassName + ".class");
+
+        if (cls.lastModified() < src.lastModified()) {
+            System.err.println("Recompiling test class...");
+            String[] javacArgs = { "-d", clsDir.getPath(), src.getPath() };
+            int rc = com.sun.tools.javac.Main.compile(javacArgs);
+            if (rc != 0)
+                throw new Exception("compilation failed");
+        }
+
+        Class<?> sjavac = Class.forName(testClassName);
+        Method main = sjavac.getMethod("main", String[].class);
+        main.invoke(null, new Object[] { testArgs });
+    }
+
+    private static boolean isSJavacOnClassPath() {
+        String cls = "com/sun/tools/sjavac/Main.class";
+        return Wrapper.class.getClassLoader().getResource(cls) != null;
+    }
+}