test/runtime/6819213/TestBootNativeLibraryPath.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 1907
c18cbe5936b8
child 6876
710a3c8b516e
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

phh@1126 1 /*
trims@1907 2 * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
phh@1126 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
phh@1126 4 *
phh@1126 5 * This code is free software; you can redistribute it and/or modify it
phh@1126 6 * under the terms of the GNU General Public License version 2 only, as
phh@1126 7 * published by the Free Software Foundation.
phh@1126 8 *
phh@1126 9 * This code is distributed in the hope that it will be useful, but WITHOUT
phh@1126 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
phh@1126 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
phh@1126 12 * version 2 for more details (a copy is included in the LICENSE file that
phh@1126 13 * accompanied this code).
phh@1126 14 *
phh@1126 15 * You should have received a copy of the GNU General Public License version
phh@1126 16 * 2 along with this work; if not, write to the Free Software Foundation,
phh@1126 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
phh@1126 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
phh@1126 22 */
phh@1126 23
phh@1126 24 /*
phh@1126 25 * @test TestBootNativeLibraryPath.java
phh@1126 26 * @bug 6819213
phh@1126 27 * @compile -XDignore.symbol.file TestBootNativeLibraryPath.java
phh@1126 28 * @summary verify sun.boot.native.library.path is expandable on 32 bit systems
phh@1126 29 * @run main TestBootNativeLibraryPath
phh@1126 30 * @author ksrini
phh@1126 31 */
phh@1126 32
phh@1126 33 import java.io.BufferedReader;
phh@1126 34 import java.io.File;
phh@1126 35 import java.io.FileOutputStream;
phh@1126 36 import java.io.IOException;
phh@1126 37 import java.io.InputStreamReader;
phh@1126 38 import java.io.PrintStream;
phh@1126 39 import java.util.ArrayList;
phh@1126 40 import java.util.List;
phh@1126 41 import java.util.Map;
phh@1126 42 import java.util.logging.Level;
phh@1126 43 import java.util.logging.Logger;
phh@1126 44 import javax.tools.JavaCompiler;
phh@1126 45 import javax.tools.ToolProvider;
phh@1126 46
phh@1126 47 public class TestBootNativeLibraryPath {
phh@1126 48
phh@1126 49 private static final String TESTFILE = "Test6";
phh@1126 50
phh@1126 51 static void createTestClass() throws IOException {
phh@1126 52 FileOutputStream fos = new FileOutputStream(TESTFILE + ".java");
phh@1126 53 PrintStream ps = new PrintStream(fos);
phh@1126 54 ps.println("public class " + TESTFILE + "{");
phh@1126 55 ps.println("public static void main(String[] args) {\n");
phh@1126 56 ps.println("System.out.println(System.getProperty(\"sun.boot.library.path\"));\n");
phh@1126 57 ps.println("}}\n");
phh@1126 58 ps.close();
phh@1126 59 fos.close();
phh@1126 60
phh@1126 61 JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
phh@1126 62 String javacOpts[] = {TESTFILE + ".java"};
phh@1126 63 if (javac.run(null, null, null, javacOpts) != 0) {
phh@1126 64 throw new RuntimeException("compilation of " + TESTFILE + ".java Failed");
phh@1126 65 }
phh@1126 66 }
phh@1126 67
phh@1126 68 static List<String> doExec(String... args) {
phh@1126 69 String javaCmd = System.getProperty("java.home") + "/bin/java";
phh@1126 70 if (!new File(javaCmd).exists()) {
phh@1126 71 javaCmd = System.getProperty("java.home") + "/bin/java.exe";
phh@1126 72 }
phh@1126 73
phh@1126 74 ArrayList<String> cmds = new ArrayList<String>();
phh@1126 75 cmds.add(javaCmd);
phh@1126 76 for (String x : args) {
phh@1126 77 cmds.add(x);
phh@1126 78 }
phh@1126 79 System.out.println("cmds=" + cmds);
phh@1126 80 ProcessBuilder pb = new ProcessBuilder(cmds);
phh@1126 81
phh@1126 82 Map<String, String> env = pb.environment();
phh@1126 83 pb.directory(new File("."));
phh@1126 84
phh@1126 85 List<String> out = new ArrayList<String>();
phh@1126 86 try {
phh@1126 87 pb.redirectErrorStream(true);
phh@1126 88 Process p = pb.start();
phh@1126 89 BufferedReader rd = new BufferedReader(new InputStreamReader(p.getInputStream()),8192);
phh@1126 90 String in = rd.readLine();
phh@1126 91 while (in != null) {
phh@1126 92 out.add(in);
phh@1126 93 System.out.println(in);
phh@1126 94 in = rd.readLine();
phh@1126 95 }
phh@1126 96 int retval = p.waitFor();
phh@1126 97 p.destroy();
phh@1126 98 if (retval != 0) {
phh@1126 99 throw new RuntimeException("Error: test returned non-zero value");
phh@1126 100 }
phh@1126 101 return out;
phh@1126 102 } catch (Exception ex) {
phh@1126 103 ex.printStackTrace();
phh@1126 104 throw new RuntimeException(ex.getMessage());
phh@1126 105 }
phh@1126 106 }
phh@1126 107
phh@1126 108 public static void main(String[] args) {
phh@1126 109 try {
phh@1126 110 if (!System.getProperty("sun.arch.data.model").equals("32")) {
phh@1126 111 System.out.println("Warning: test skipped for 64-bit systems\n");
phh@1126 112 return;
phh@1126 113 }
phh@1126 114 String osname = System.getProperty("os.name");
phh@1126 115 if (osname.startsWith("Windows")) {
phh@1126 116 osname = "Windows";
phh@1126 117 }
phh@1126 118
phh@1126 119 createTestClass();
phh@1126 120
phh@1126 121 // Test a simple path
phh@1126 122 String libpath = File.pathSeparator + "tmp" + File.pathSeparator + "foobar";
phh@1126 123 List<String> processOut = null;
phh@1126 124 String sunbootlibrarypath = "-Dsun.boot.library.path=" + libpath;
phh@1126 125 processOut = doExec(sunbootlibrarypath, "-cp", ".", TESTFILE);
phh@1126 126 if (processOut == null || !processOut.get(0).endsWith(libpath)) {
phh@1126 127 throw new RuntimeException("Error: did not get expected error string");
phh@1126 128 }
phh@1126 129 } catch (IOException ex) {
phh@1126 130 throw new RuntimeException("Unexpected error " + ex);
phh@1126 131 }
phh@1126 132 }
phh@1126 133 }

mercurial