8006000: TEST_BUG: java/lang/invoke/lambda/LambdaAccessControlTest.java fails intermittently
authoralanb
Fri, 08 Mar 2013 12:03:26 +0000
changeset 16062 c64ef2b01401
parent 16061 c80133bafef0
child 16063 18e7ee7b4301
8006000: TEST_BUG: java/lang/invoke/lambda/LambdaAccessControlTest.java fails intermittently Reviewed-by: chegar
jdk/test/java/lang/invoke/lambda/LUtils.java
jdk/test/java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java
jdk/test/java/lang/invoke/lambda/LambdaAccessControlTest.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/lambda/LUtils.java	Fri Mar 08 12:03:26 2013 +0000
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/*
+ * support infrastructure to invoke a java class from the command line
+ */
+class LUtils {
+    static final sun.tools.jar.Main jarTool =
+            new sun.tools.jar.Main(System.out, System.err, "jar-tool");
+    static final com.sun.tools.javac.Main javac =
+            new com.sun.tools.javac.Main();
+    static final File cwd = new File(".").getAbsoluteFile();
+    static final String JAVAHOME = System.getProperty("java.home");
+    static final boolean isWindows =
+            System.getProperty("os.name", "unknown").startsWith("Windows");
+    //static final boolean isSDK = JAVAHOME.endsWith("jre");
+    static final File JAVA_BIN_FILE = new File(JAVAHOME, "bin");
+    static final File JAVA_CMD = new File(JAVA_BIN_FILE,
+            isWindows ? "java.exe" : "java");
+
+    protected LUtils() {
+    }
+
+    public static void compile(String... args) {
+        if (javac.compile(args) != 0) {
+            throw new RuntimeException("compilation fails");
+        }
+    }
+
+    static void createFile(File outFile, List<String> content) {
+        try {
+            Files.write(outFile.getAbsoluteFile().toPath(), content,
+                    Charset.defaultCharset());
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    static File getClassFile(File javaFile) {
+        return javaFile.getName().endsWith(".java")
+                ? new File(javaFile.getName().replace(".java", ".class"))
+                : null;
+    }
+
+    static String getSimpleName(File inFile) {
+        String fname = inFile.getName();
+        return fname.substring(0, fname.indexOf("."));
+    }
+
+    static TestResult doExec(String... cmds) {
+        return doExec(null, null, cmds);
+    }
+
+    /*
+     * A method which executes a java cmd and returns the results in a container
+     */
+    static TestResult doExec(Map<String, String> envToSet,
+            java.util.Set<String> envToRemove, String... cmds) {
+        String cmdStr = "";
+        for (String x : cmds) {
+            cmdStr = cmdStr.concat(x + " ");
+        }
+        ProcessBuilder pb = new ProcessBuilder(cmds);
+        Map<String, String> env = pb.environment();
+        if (envToRemove != null) {
+            for (String key : envToRemove) {
+                env.remove(key);
+            }
+        }
+        if (envToSet != null) {
+            env.putAll(envToSet);
+        }
+        BufferedReader rdr = null;
+        try {
+            List<String> outputList = new ArrayList<>();
+            pb.redirectErrorStream(true);
+            Process p = pb.start();
+            rdr = new BufferedReader(new InputStreamReader(p.getInputStream()));
+            String in = rdr.readLine();
+            while (in != null) {
+                outputList.add(in);
+                in = rdr.readLine();
+            }
+            p.waitFor();
+            p.destroy();
+
+            return new TestResult(cmdStr, p.exitValue(), outputList,
+                    env, new Throwable("current stack of the test"));
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            throw new RuntimeException(ex.getMessage());
+        }
+    }
+
+    static class TestResult {
+        String cmd;
+        int exitValue;
+        List<String> testOutput;
+        Map<String, String> env;
+        Throwable t;
+
+        public TestResult(String str, int rv, List<String> oList,
+                Map<String, String> env, Throwable t) {
+            cmd = str;
+            exitValue = rv;
+            testOutput = oList;
+            this.env = env;
+            this.t = t;
+        }
+
+        void assertZero(String message) {
+            if (exitValue != 0) {
+                System.err.println(this);
+                throw new RuntimeException(message);
+            }
+        }
+
+        @Override
+        public String toString() {
+            StringWriter sw = new StringWriter();
+            PrintWriter status = new PrintWriter(sw);
+            status.println("Cmd: " + cmd);
+            status.println("Return code: " + exitValue);
+            status.println("Environment variable:");
+            for (String x : env.keySet()) {
+                status.println("\t" + x + "=" + env.get(x));
+            }
+            status.println("Output:");
+            for (String x : testOutput) {
+                status.println("\t" + x);
+            }
+            status.println("Exception:");
+            status.println(t.getMessage());
+            t.printStackTrace(status);
+
+            return sw.getBuffer().toString();
+        }
+    }
+}
--- a/jdk/test/java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java	Thu Mar 07 10:07:13 2013 +0000
+++ b/jdk/test/java/lang/invoke/lambda/LambdaAccessControlDoPrivilegedTest.java	Fri Mar 08 12:03:26 2013 +0000
@@ -26,20 +26,12 @@
  * @bug 8003881
  * @summary tests DoPrivileged action (implemented as lambda expressions) by
  * inserting them into the BootClassPath.
- * @compile -XDignore.symbol.file LambdaAccessControlDoPrivilegedTest.java
+ * @compile -XDignore.symbol.file LambdaAccessControlDoPrivilegedTest.java LUtils.java
  * @run main/othervm LambdaAccessControlDoPrivilegedTest
  */
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.nio.charset.Charset;
-import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 public class LambdaAccessControlDoPrivilegedTest extends LUtils {
     public static void main(String... args) {
@@ -87,140 +79,3 @@
         jarFile.delete();
     }
 }
-
-/*
- * support infrastructure to invoke a java class from the command line
- */
-class LUtils {
-    static final sun.tools.jar.Main jarTool =
-            new sun.tools.jar.Main(System.out, System.err, "jar-tool");
-    static final com.sun.tools.javac.Main javac =
-            new com.sun.tools.javac.Main();
-    static final File cwd = new File(".").getAbsoluteFile();
-    static final String JAVAHOME = System.getProperty("java.home");
-    static final boolean isWindows =
-            System.getProperty("os.name", "unknown").startsWith("Windows");
-    //static final boolean isSDK = JAVAHOME.endsWith("jre");
-    static final File JAVA_BIN_FILE = new File(JAVAHOME, "bin");
-    static final File JAVA_CMD = new File(JAVA_BIN_FILE,
-            isWindows ? "java.exe" : "java");
-
-    protected LUtils() {
-    }
-
-    public static void compile(String... args) {
-        if (javac.compile(args) != 0) {
-            throw new RuntimeException("compilation fails");
-        }
-    }
-
-    static void createFile(File outFile, List<String> content) {
-        try {
-            Files.write(outFile.getAbsoluteFile().toPath(), content,
-                    Charset.defaultCharset());
-        } catch (IOException ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-
-    static File getClassFile(File javaFile) {
-        return javaFile.getName().endsWith(".java")
-                ? new File(javaFile.getName().replace(".java", ".class"))
-                : null;
-    }
-
-    static String getSimpleName(File inFile) {
-        String fname = inFile.getName();
-        return fname.substring(0, fname.indexOf("."));
-    }
-
-    static TestResult doExec(String... cmds) {
-        return doExec(null, null, cmds);
-    }
-
-    /*
-     * A method which executes a java cmd and returns the results in a container
-     */
-    static TestResult doExec(Map<String, String> envToSet,
-            java.util.Set<String> envToRemove, String... cmds) {
-        String cmdStr = "";
-        for (String x : cmds) {
-            cmdStr = cmdStr.concat(x + " ");
-        }
-        ProcessBuilder pb = new ProcessBuilder(cmds);
-        Map<String, String> env = pb.environment();
-        if (envToRemove != null) {
-            for (String key : envToRemove) {
-                env.remove(key);
-            }
-        }
-        if (envToSet != null) {
-            env.putAll(envToSet);
-        }
-        BufferedReader rdr = null;
-        try {
-            List<String> outputList = new ArrayList<>();
-            pb.redirectErrorStream(true);
-            Process p = pb.start();
-            rdr = new BufferedReader(new InputStreamReader(p.getInputStream()));
-            String in = rdr.readLine();
-            while (in != null) {
-                outputList.add(in);
-                in = rdr.readLine();
-            }
-            p.waitFor();
-            p.destroy();
-
-            return new TestResult(cmdStr, p.exitValue(), outputList,
-                    env, new Throwable("current stack of the test"));
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            throw new RuntimeException(ex.getMessage());
-        }
-    }
-
-    static class TestResult {
-        String cmd;
-        int exitValue;
-        List<String> testOutput;
-        Map<String, String> env;
-        Throwable t;
-
-        public TestResult(String str, int rv, List<String> oList,
-                Map<String, String> env, Throwable t) {
-            cmd = str;
-            exitValue = rv;
-            testOutput = oList;
-            this.env = env;
-            this.t = t;
-        }
-
-        void assertZero(String message) {
-            if (exitValue != 0) {
-                System.err.println(this);
-                throw new RuntimeException(message);
-            }
-        }
-
-        @Override
-        public String toString() {
-            StringWriter sw = new StringWriter();
-            PrintWriter status = new PrintWriter(sw);
-            status.println("Cmd: " + cmd);
-            status.println("Return code: " + exitValue);
-            status.println("Environment variable:");
-            for (String x : env.keySet()) {
-                status.println("\t" + x + "=" + env.get(x));
-            }
-            status.println("Output:");
-            for (String x : testOutput) {
-                status.println("\t" + x);
-            }
-            status.println("Exception:");
-            status.println(t.getMessage());
-            t.printStackTrace(status);
-
-            return sw.getBuffer().toString();
-        }
-    }
-}
--- a/jdk/test/java/lang/invoke/lambda/LambdaAccessControlTest.java	Thu Mar 07 10:07:13 2013 +0000
+++ b/jdk/test/java/lang/invoke/lambda/LambdaAccessControlTest.java	Fri Mar 08 12:03:26 2013 +0000
@@ -25,7 +25,7 @@
  * @test
  * @bug 8003881
  * @summary tests Lambda expression with a a security manager at top level
- * @compile -XDignore.symbol.file LambdaAccessControlTest.java
+ * @compile -XDignore.symbol.file LambdaAccessControlTest.java LUtils.java
  *
  * @run main/othervm LambdaAccessControlTest
  */