annotate test/runtime/6819213/TestBootNativeLibraryPath.java @ 12986:1b422ef5288a

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