changeset 2733:b790c1ecee19

6981001: (launcher) EnsureJREInstallation is not being called in order Reviewed-by: darcy
author ksrini
date Fri, 03 Sep 2010 07:59:21 -0700
parents b200263f1b68
children 10728041e814
files src/windows/bin/java_md.c test/tools/launcher/MiscTests.java test/tools/launcher/VerifyExceptions.java
diffstat 3 files changed, 94 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/bin/java_md.c	Wed Sep 01 17:37:45 2010 -0700
+++ b/src/windows/bin/java_md.c	Fri Sep 03 07:59:21 2010 -0700
@@ -105,15 +105,15 @@
         exit(1);
     }
 
-    /* Do this before we read jvm.cfg */
-    EnsureJreInstallation(jrepath);
-
     /* Find out where the JRE is that we will be using. */
     if (!GetJREPath(jrepath, so_jrepath)) {
         JLI_ReportErrorMessage(JRE_ERROR1);
         exit(2);
     }
 
+    /* Do this before we read jvm.cfg and after jrepath is initialized */
+    EnsureJreInstallation(jrepath);
+
     /* Find the specified JVM type */
     if (ReadKnownVMs(jrepath, (char*)GetArch(), JNI_FALSE) < 1) {
         JLI_ReportErrorMessage(CFG_ERROR7);
@@ -213,6 +213,7 @@
     }
     /* Does our bundle directory exist ? */
     JLI_Snprintf(tmpbuf, sizeof(tmpbuf), "%s\\lib\\bundles", jrepath);
+    JLI_TraceLauncher("EnsureJreInstallation: %s\n", tmpbuf);
     if (stat(tmpbuf, &s) != 0) {
         return;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/launcher/MiscTests.java	Fri Sep 03 07:59:21 2010 -0700
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2010, 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 6856415 6981001
+ * @summary Miscellaneous tests, Exceptions, EnsureJRE etc.
+ * @compile -XDignore.symbol.file MiscTests.java TestHelper.java
+ * @run main MiscTests
+ */
+
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class MiscTests {
+
+    // 6856415: Checks to ensure that proper exceptions are thrown by java
+    static void test6856415() {
+        // No pkcs library on win-x64, so we bail out.
+        if (TestHelper.is64Bit && TestHelper.isWindows) {
+            return;
+        }
+        StringBuilder sb = new StringBuilder();
+        sb.append("public static void main(String... args) {\n");
+        sb.append("java.security.Provider p = new sun.security.pkcs11.SunPKCS11(args[0]);\n");
+        sb.append("java.security.Security.insertProviderAt(p, 1);\n");
+        sb.append("}");
+        File testJar = new File("Foo.jar");
+        testJar.delete();
+        try {
+            TestHelper.createJar(testJar, sb.toString());
+        } catch (FileNotFoundException fnfe) {
+            throw new RuntimeException(fnfe);
+        }
+        TestHelper.TestResult tr = TestHelper.doExec(TestHelper.javaCmd,
+                "-Djava.security.manager", "-jar", testJar.getName(), "foo.bak");
+        for (String s : tr.testOutput) {
+            System.out.println(s);
+    }
+        if (!tr.contains("java.security.AccessControlException:" +
+                " access denied (\"java.lang.RuntimePermission\"" +
+                " \"accessClassInPackage.sun.security.pkcs11\")")) {
+            System.out.println(tr.status);
+        }
+    }
+    // 6981001 : Check EnsureJreInstallation is ok, note we cannot
+    // thoroughly test this function, we simply do our best.
+    static void test6981001() {
+        if (TestHelper.is64Bit || !TestHelper.isWindows) {
+            return;
+        }
+        Map<String, String> env = new HashMap<String, String>();
+        env.put("_JAVA_LAUNCHER_DEBUG", "true");
+        TestHelper.TestResult tr = TestHelper.doExec(env, TestHelper.javaCmd);
+        if (!tr.contains(TestHelper.JAVAHOME + "\\lib\\bundles")) {
+            System.out.println(tr.status);
+        }
+    }
+    public static void main(String... args) {
+        test6856415();
+        test6981001();
+        if (TestHelper.testExitValue != 0) {
+            throw new Error(TestHelper.testExitValue + " tests failed");
+    }
+}
+}
--- a/test/tools/launcher/VerifyExceptions.java	Wed Sep 01 17:37:45 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2010, 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 6856415
- * @summary Checks to ensure that proper exceptions are thrown by java
- * @compile -XDignore.symbol.file VerifyExceptions.java TestHelper.java
- * @run main VerifyExceptions
- */
-
-
-import java.io.File;
-import java.io.FileNotFoundException;
-
-
-public class VerifyExceptions {
-
-    static void test6856415() {
-        // No pkcs library on win-x64, so we bail out.
-        if (TestHelper.is64Bit && TestHelper.isWindows) {
-            return;
-        }
-        StringBuilder sb = new StringBuilder();
-        sb.append("public static void main(String... args) {\n");
-        sb.append("java.security.Provider p = new sun.security.pkcs11.SunPKCS11(args[0]);\n");
-        sb.append("java.security.Security.insertProviderAt(p, 1);\n");
-        sb.append("}");
-        File testJar = new File("Foo.jar");
-        testJar.delete();
-        try {
-            TestHelper.createJar(testJar, sb.toString());
-        } catch (FileNotFoundException fnfe) {
-            throw new RuntimeException(fnfe);
-        }
-        TestHelper.TestResult tr = TestHelper.doExec(TestHelper.javacCmd,
-                "-Djava.security.manager", "-jar", testJar.getName(), "foo.bak");
-        tr.checkNegative();
-        tr.contains("Exception in thread \"main\" java.security.AccessControlException: access denied (\"java.lang.RuntimePermission\" \"accessClassInPackage.sun.security.pkcs11\")\")");
-    }
-
-    public static void main(String... args) {
-        test6856415();
-    }
-}