author | anthony |
Tue, 24 Apr 2012 20:39:40 +0400 | |
changeset 12527 | 22abaf748b5b |
parent 12301 | 201cef0a3f12 |
child 12561 | 63b05f2eabac |
permissions | -rw-r--r-- |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
1 |
/* |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
2 |
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
4 |
* |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
8 |
* |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
14 |
* |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
22 |
*/ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
23 |
|
12527
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
24 |
import java.util.Set; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
25 |
import java.io.BufferedReader; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
26 |
import java.io.File; |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
27 |
import java.io.FileFilter; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
28 |
import java.io.FileNotFoundException; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
29 |
import java.io.FileOutputStream; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
30 |
import java.io.IOException; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
31 |
import java.io.InputStreamReader; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
32 |
import java.io.PrintStream; |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
33 |
import java.nio.charset.Charset; |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
34 |
import java.nio.file.attribute.BasicFileAttributes; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
35 |
import java.nio.file.Files; |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
36 |
import java.nio.file.FileVisitResult; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
37 |
import java.nio.file.SimpleFileVisitor; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
38 |
import java.nio.file.Path; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
39 |
import java.util.ArrayList; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
40 |
import java.util.List; |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
41 |
import java.util.Locale; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
42 |
import java.util.Map; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
43 |
import javax.tools.JavaCompiler; |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
44 |
import javax.tools.ToolProvider; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
45 |
|
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
46 |
import static java.nio.file.StandardCopyOption.*; |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
47 |
import static java.nio.file.StandardOpenOption.*; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
48 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
49 |
/** |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
50 |
* This class provides some common utilities for the launcher tests. |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
51 |
*/ |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
52 |
public class TestHelper { |
11679
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
53 |
// commonly used jtreg constants |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
54 |
static final File TEST_CLASSES_DIR; |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
55 |
static final File TEST_SOURCES_DIR; |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
56 |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
57 |
static final String JAVAHOME = System.getProperty("java.home"); |
12301 | 58 |
static final String JAVA_BIN; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
59 |
static final boolean isSDK = JAVAHOME.endsWith("jre"); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
60 |
static final String javaCmd; |
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
61 |
static final String javawCmd; |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
62 |
static final String java64Cmd; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
63 |
static final String javacCmd; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
64 |
static final JavaCompiler compiler; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
65 |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
66 |
static final boolean debug = Boolean.getBoolean("TestHelper.Debug"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
67 |
static final boolean isWindows = |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
68 |
System.getProperty("os.name", "unknown").startsWith("Windows"); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11687
diff
changeset
|
69 |
static final boolean isMacOSX = |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11687
diff
changeset
|
70 |
System.getProperty("os.name", "unknown").startsWith("Mac"); |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
71 |
static final boolean is64Bit = |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
72 |
System.getProperty("sun.arch.data.model").equals("64"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
73 |
static final boolean is32Bit = |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
74 |
System.getProperty("sun.arch.data.model").equals("32"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
75 |
static final boolean isSolaris = |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
76 |
System.getProperty("os.name", "unknown").startsWith("SunOS"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
77 |
static final boolean isLinux = |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
78 |
System.getProperty("os.name", "unknown").startsWith("Linux"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
79 |
static final boolean isDualMode = isSolaris; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
80 |
static final boolean isSparc = System.getProperty("os.arch").startsWith("sparc"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
81 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
82 |
// make a note of the golden default locale |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
83 |
static final Locale DefaultLocale = Locale.getDefault(); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
84 |
|
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
85 |
static final String JAVA_FILE_EXT = ".java"; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
86 |
static final String CLASS_FILE_EXT = ".class"; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
87 |
static final String JAR_FILE_EXT = ".jar"; |
12301 | 88 |
static final String EXE_FILE_EXT = ".exe"; |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
89 |
static final String JLDEBUG_KEY = "_JAVA_LAUNCHER_DEBUG"; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
90 |
static final String EXPECTED_MARKER = "TRACER_MARKER:About to EXEC"; |
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
91 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
92 |
static int testExitValue = 0; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
93 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
94 |
static { |
11679
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
95 |
String tmp = System.getProperty("test.classes", null); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
96 |
if (tmp == null) { |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
97 |
throw new Error("property test.classes not defined ??"); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
98 |
} |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
99 |
TEST_CLASSES_DIR = new File(tmp).getAbsoluteFile(); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
100 |
|
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
101 |
tmp = System.getProperty("test.src", null); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
102 |
if (tmp == null) { |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
103 |
throw new Error("property test.src not defined ??"); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
104 |
} |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
105 |
TEST_SOURCES_DIR = new File(tmp).getAbsoluteFile(); |
84da476c4537
7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents:
11520
diff
changeset
|
106 |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
107 |
if (is64Bit && is32Bit) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
108 |
throw new RuntimeException("arch model cannot be both 32 and 64 bit"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
109 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
110 |
if (!is64Bit && !is32Bit) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
111 |
throw new RuntimeException("arch model is not 32 or 64 bit ?"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
112 |
} |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
113 |
compiler = ToolProvider.getSystemJavaCompiler(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
114 |
File binDir = (isSDK) ? new File((new File(JAVAHOME)).getParentFile(), "bin") |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
115 |
: new File(JAVAHOME, "bin"); |
12301 | 116 |
JAVA_BIN = binDir.getAbsolutePath(); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
117 |
File javaCmdFile = (isWindows) |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
118 |
? new File(binDir, "java.exe") |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
119 |
: new File(binDir, "java"); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
120 |
javaCmd = javaCmdFile.getAbsolutePath(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
121 |
if (!javaCmdFile.canExecute()) { |
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
122 |
throw new RuntimeException("java <" + TestHelper.javaCmd + |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
123 |
"> must exist and should be executable"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
124 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
125 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
126 |
File javacCmdFile = (isWindows) |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
127 |
? new File(binDir, "javac.exe") |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
128 |
: new File(binDir, "javac"); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
129 |
javacCmd = javacCmdFile.getAbsolutePath(); |
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
130 |
|
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
131 |
if (isWindows) { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
132 |
File javawCmdFile = new File(binDir, "javaw.exe"); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
133 |
javawCmd = javawCmdFile.getAbsolutePath(); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
134 |
if (!javawCmdFile.canExecute()) { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
135 |
throw new RuntimeException("java <" + javawCmd + |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
136 |
"> must exist and should be executable"); |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
137 |
} |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
138 |
} else { |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
139 |
javawCmd = null; |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
140 |
} |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
141 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
142 |
if (!javacCmdFile.canExecute()) { |
11364
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
143 |
throw new RuntimeException("java <" + javacCmd + |
7907324fed4f
7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents:
10126
diff
changeset
|
144 |
"> must exist and should be executable"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
145 |
} |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
146 |
if (isSolaris) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
147 |
File sparc64BinDir = new File(binDir,isSparc ? "sparcv9" : "amd64"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
148 |
File java64CmdFile= new File(sparc64BinDir, "java"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
149 |
if (java64CmdFile.exists() && java64CmdFile.canExecute()) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
150 |
java64Cmd = java64CmdFile.getAbsolutePath(); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
151 |
} else { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
152 |
java64Cmd = null; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
153 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
154 |
} else { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
155 |
java64Cmd = null; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
156 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
157 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
158 |
|
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
159 |
/* |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
160 |
* is a dual mode available in the test jdk |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
161 |
*/ |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
162 |
static boolean dualModePresent() { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
163 |
return isDualMode && java64Cmd != null; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
164 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
165 |
|
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
166 |
/* |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
167 |
* usually the jre/lib/arch-name is the same as os.arch, except for x86. |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
168 |
*/ |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
169 |
static String getJreArch() { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
170 |
String arch = System.getProperty("os.arch"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
171 |
return arch.equals("x86") ? "i386" : arch; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
172 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
173 |
|
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
174 |
/* |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
175 |
* get the complementary jre arch ie. if sparc then return sparcv9 and |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
176 |
* vice-versa. |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
177 |
*/ |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
178 |
static String getComplementaryJreArch() { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
179 |
String arch = System.getProperty("os.arch"); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
180 |
if (arch != null) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
181 |
switch (arch) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
182 |
case "sparc": |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
183 |
return "sparcv9"; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
184 |
case "sparcv9": |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
185 |
return "sparc"; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
186 |
case "x86": |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
187 |
return "amd64"; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
188 |
case "amd64": |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
189 |
return "i386"; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
190 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
191 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
192 |
return null; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
193 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
194 |
|
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
195 |
/* |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
196 |
* A convenience method to create a jar with jar file name and defs |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
197 |
*/ |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
198 |
static void createJar(File jarName, String... mainDefs) |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
199 |
throws FileNotFoundException{ |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
200 |
createJar(null, jarName, new File("Foo"), mainDefs); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
201 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
202 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
203 |
/* |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
204 |
* A convenience method to create a java file, compile and jar it up, using |
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
205 |
* the sole class file name in the jar, as the Main-Class attribute value. |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
206 |
*/ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
207 |
static void createJar(File jarName, File mainClass, String... mainDefs) |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
208 |
throws FileNotFoundException { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
209 |
createJar(null, jarName, mainClass, mainDefs); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
210 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
211 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
212 |
/* |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
213 |
* A convenience method to compile java files. |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
214 |
*/ |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
215 |
static void compile(String... compilerArgs) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
216 |
if (compiler.run(null, null, null, compilerArgs) != 0) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
217 |
String sarg = ""; |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
218 |
for (String x : compilerArgs) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
219 |
sarg.concat(x + " "); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
220 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
221 |
throw new Error("compilation failed: " + sarg); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
222 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
223 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
224 |
|
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
225 |
/* |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
226 |
* A generic jar file creator to create a java file, compile it |
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
227 |
* and jar it up, a specific Main-Class entry name in the |
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
228 |
* manifest can be specified or a null to use the sole class file name |
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
229 |
* as the Main-Class attribute value. |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
230 |
*/ |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
231 |
static void createJar(String mEntry, File jarName, File mainClass, |
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
232 |
String... mainDefs) throws FileNotFoundException { |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
233 |
if (jarName.exists()) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
234 |
jarName.delete(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
235 |
} |
10126
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
236 |
try (PrintStream ps = new PrintStream(new FileOutputStream(mainClass + ".java"))) { |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
237 |
ps.println("public class Foo {"); |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
238 |
if (mainDefs != null) { |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
239 |
for (String x : mainDefs) { |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
240 |
ps.println(x); |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
241 |
} |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
242 |
} |
10126
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
243 |
ps.println("}"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
244 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
245 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
246 |
String compileArgs[] = { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
247 |
mainClass + ".java" |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
248 |
}; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
249 |
if (compiler.run(null, null, null, compileArgs) != 0) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
250 |
throw new RuntimeException("compilation failed " + mainClass + ".java"); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
251 |
} |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
252 |
if (mEntry == null) { |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
253 |
mEntry = mainClass.getName(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
254 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
255 |
String jarArgs[] = { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
256 |
(debug) ? "cvfe" : "cfe", |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
257 |
jarName.getAbsolutePath(), |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
258 |
mEntry, |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
259 |
mainClass.getName() + ".class" |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
260 |
}; |
10126
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
261 |
createJar(jarArgs); |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
262 |
} |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
263 |
|
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
264 |
static void createJar(String... args) { |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
265 |
sun.tools.jar.Main jarTool = |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
266 |
new sun.tools.jar.Main(System.out, System.err, "JarCreator"); |
10126
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
267 |
if (!jarTool.run(args)) { |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
268 |
String message = "jar creation failed with command:"; |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
269 |
for (String x : args) { |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
270 |
message = message.concat(" " + x); |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
271 |
} |
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
272 |
throw new RuntimeException(message); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
273 |
} |
10126
a375b8714147
7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents:
9734
diff
changeset
|
274 |
} |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
275 |
|
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
276 |
static void copyFile(File src, File dst) throws IOException { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
277 |
Path parent = dst.toPath().getParent(); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
278 |
if (parent != null) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
279 |
Files.createDirectories(parent); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
280 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
281 |
Files.copy(src.toPath(), dst.toPath(), COPY_ATTRIBUTES, REPLACE_EXISTING); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
282 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
283 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
284 |
static void createFile(File outFile, List<String> content) throws IOException { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
285 |
Files.write(outFile.getAbsoluteFile().toPath(), content, |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
286 |
Charset.defaultCharset(), CREATE_NEW); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
287 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
288 |
|
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
289 |
static void recursiveDelete(File target) throws IOException { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
290 |
if (!target.exists()) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
291 |
return; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
292 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
293 |
Files.walkFileTree(target.toPath(), new SimpleFileVisitor<Path>() { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
294 |
@Override |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
295 |
public FileVisitResult postVisitDirectory(Path dir, IOException exc) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
296 |
try { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
297 |
Files.deleteIfExists(dir); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
298 |
} catch (IOException ex) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
299 |
System.out.println("Error: could not delete: " + dir.toString()); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
300 |
System.out.println(ex.getMessage()); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
301 |
return FileVisitResult.TERMINATE; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
302 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
303 |
return FileVisitResult.CONTINUE; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
304 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
305 |
@Override |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
306 |
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
307 |
try { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
308 |
Files.deleteIfExists(file); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
309 |
} catch (IOException ex) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
310 |
System.out.println("Error: could not delete: " + file.toString()); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
311 |
System.out.println(ex.getMessage()); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
312 |
return FileVisitResult.TERMINATE; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
313 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
314 |
return FileVisitResult.CONTINUE; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
315 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
316 |
}); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
317 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
318 |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
319 |
static TestResult doExec(String...cmds) { |
12527
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
320 |
return doExec(null, null, cmds); |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
321 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
322 |
|
12527
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
323 |
static TestResult doExec(Map<String, String> envToSet, String...cmds) { |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
324 |
return doExec(envToSet, null, cmds); |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
325 |
} |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
326 |
/* |
1329
ce13b59a8401
4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents:
1323
diff
changeset
|
327 |
* A method which executes a java cmd and returns the results in a container |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
328 |
*/ |
12527
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
329 |
static TestResult doExec(Map<String, String> envToSet, |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
330 |
Set<String> envToRemove, String...cmds) { |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
331 |
String cmdStr = ""; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
332 |
for (String x : cmds) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
333 |
cmdStr = cmdStr.concat(x + " "); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
334 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
335 |
ProcessBuilder pb = new ProcessBuilder(cmds); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
336 |
Map<String, String> env = pb.environment(); |
12527
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
337 |
if (envToRemove != null) { |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
338 |
for (String key : envToRemove) { |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
339 |
env.remove(key); |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
340 |
} |
22abaf748b5b
7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents:
12301
diff
changeset
|
341 |
} |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
342 |
if (envToSet != null) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
343 |
env.putAll(envToSet); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
344 |
} |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
345 |
BufferedReader rdr = null; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
346 |
try { |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
347 |
List<String> outputList = new ArrayList<>(); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
348 |
pb.redirectErrorStream(true); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
349 |
Process p = pb.start(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
350 |
rdr = new BufferedReader(new InputStreamReader(p.getInputStream())); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
351 |
String in = rdr.readLine(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
352 |
while (in != null) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
353 |
outputList.add(in); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
354 |
in = rdr.readLine(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
355 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
356 |
p.waitFor(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
357 |
p.destroy(); |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
358 |
|
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
359 |
return new TestHelper.TestResult(cmdStr, p.exitValue(), outputList, |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
360 |
env, new Throwable("current stack of the test")); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
361 |
} catch (Exception ex) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
362 |
ex.printStackTrace(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
363 |
throw new RuntimeException(ex.getMessage()); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
364 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
365 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
366 |
|
11520
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
367 |
static FileFilter createFilter(final String extension) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
368 |
return new FileFilter() { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
369 |
@Override |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
370 |
public boolean accept(File pathname) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
371 |
String name = pathname.getName(); |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
372 |
if (name.endsWith(extension)) { |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
373 |
return true; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
374 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
375 |
return false; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
376 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
377 |
}; |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
378 |
} |
1c485b79de81
7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents:
11364
diff
changeset
|
379 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
380 |
static boolean isEnglishLocale() { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
381 |
return Locale.getDefault().getLanguage().equals("en"); |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
382 |
} |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
11679
diff
changeset
|
383 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
384 |
/* |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
385 |
* A class to encapsulate the test results and stuff, with some ease |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
386 |
* of use methods to check the test results. |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
387 |
*/ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
388 |
static class TestResult { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
389 |
StringBuilder status; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
390 |
int exitValue; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
391 |
List<String> testOutput; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
392 |
Map<String, String> env; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
393 |
Throwable t; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
394 |
|
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
395 |
public TestResult(String str, int rv, List<String> oList, |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
396 |
Map<String, String> env, Throwable t) { |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
397 |
status = new StringBuilder("Executed command: " + str + "\n"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
398 |
exitValue = rv; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
399 |
testOutput = oList; |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
400 |
this.env = env; |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
401 |
this.t = t; |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
402 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
403 |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
404 |
void appendStatus(String x) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
405 |
status = status.append(" " + x + "\n"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
406 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
407 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
408 |
void checkNegative() { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
409 |
if (exitValue == 0) { |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
410 |
appendStatus("Error: test must not return 0 exit value"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
411 |
testExitValue++; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
412 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
413 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
414 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
415 |
void checkPositive() { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
416 |
if (exitValue != 0) { |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
417 |
appendStatus("Error: test did not return 0 exit value"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
418 |
testExitValue++; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
419 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
420 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
421 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
422 |
boolean isOK() { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
423 |
return exitValue == 0; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
424 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
425 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
426 |
boolean isZeroOutput() { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
427 |
if (!testOutput.isEmpty()) { |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
428 |
appendStatus("Error: No message from cmd please"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
429 |
testExitValue++; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
430 |
return false; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
431 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
432 |
return true; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
433 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
434 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
435 |
boolean isNotZeroOutput() { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
436 |
if (testOutput.isEmpty()) { |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
437 |
appendStatus("Error: Missing message"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
438 |
testExitValue++; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
439 |
return false; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
440 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
441 |
return true; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
442 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
443 |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
444 |
@Override |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
445 |
public String toString() { |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
446 |
status.append("++++Begin Test Info++++\n"); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
447 |
status.append("++++Test Environment++++\n"); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
448 |
for (String x : env.keySet()) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
449 |
status.append(x).append("=").append(env.get(x)).append("\n"); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
450 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
451 |
status.append("++++Test Output++++\n"); |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
452 |
for (String x : testOutput) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
453 |
appendStatus(x); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
454 |
} |
9244
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
455 |
status.append("++++Test Stack Trace++++\n"); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
456 |
status.append(t.toString()); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
457 |
for (StackTraceElement e : t.getStackTrace()) { |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
458 |
status.append(e.toString()); |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
459 |
} |
84d85c90d5db
7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents:
5506
diff
changeset
|
460 |
status.append("++++End of Test Info++++\n"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
461 |
return status.toString(); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
462 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
463 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
464 |
boolean contains(String str) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
465 |
for (String x : testOutput) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
466 |
if (x.contains(str)) { |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
467 |
return true; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
468 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
469 |
} |
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
470 |
appendStatus("Error: string <" + str + "> not found"); |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
471 |
testExitValue++; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
472 |
return false; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
473 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
474 |
|
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
475 |
boolean matches(String stringToMatch) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
476 |
for (String x : testOutput) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
477 |
if (x.matches(stringToMatch)) { |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
478 |
return true; |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
479 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
480 |
} |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
1329
diff
changeset
|
481 |
appendStatus("Error: string <" + stringToMatch + "> not found"); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
482 |
testExitValue++; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
483 |
return false; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
484 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
485 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff
changeset
|
486 |
} |