jdk/test/tools/launcher/TestHelper.java
author lana
Thu, 02 Jun 2016 21:14:26 +0000
changeset 38627 6dea0d12ee02
parent 37540 e92d95400f31
child 45944 882cea808912
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
     1
/*
27773
938fb14f357a 8060026: Update jdk/test/tools/launcher tests to eliminate dependency on sun.tools.jar.Main
ksrini
parents: 22602
diff changeset
     2
 * Copyright (c) 2008, 2014, 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
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4340
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4340
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4340
diff changeset
    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
13675
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
    24
import java.io.OutputStream;
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
    25
import java.io.InputStream;
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
    26
import java.lang.annotation.ElementType;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
    27
import java.lang.annotation.Retention;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
    28
import java.lang.annotation.RetentionPolicy;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
    29
import java.lang.annotation.Target;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
    30
import java.lang.reflect.Method;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
    31
import java.util.regex.Pattern;
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
    32
import java.io.StringWriter;
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
    33
import java.io.PrintWriter;
12527
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents: 12301
diff changeset
    34
import java.util.Set;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    35
import java.io.BufferedReader;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    36
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
    37
import java.io.FileFilter;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    38
import java.io.FileNotFoundException;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    39
import java.io.FileOutputStream;
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
    40
import java.io.IOException;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    41
import java.io.InputStreamReader;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    42
import java.io.PrintStream;
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
    43
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
    44
import java.nio.file.attribute.BasicFileAttributes;
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
    45
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
    46
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
    47
import java.nio.file.SimpleFileVisitor;
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
    48
import java.nio.file.Path;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    49
import java.util.ArrayList;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    50
import java.util.List;
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
    51
import java.util.Locale;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    52
import java.util.Map;
27773
938fb14f357a 8060026: Update jdk/test/tools/launcher tests to eliminate dependency on sun.tools.jar.Main
ksrini
parents: 22602
diff changeset
    53
import java.util.Arrays;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    54
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
    55
import javax.tools.ToolProvider;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    56
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
    57
import static java.nio.file.StandardCopyOption.*;
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
    58
import static java.nio.file.StandardOpenOption.*;
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
    59
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    60
/**
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
    61
 * This class provides some common utilities for the launcher tests.
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    62
 */
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
    63
public class TestHelper {
11679
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
    64
    // commonly used jtreg constants
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
    65
    static final File TEST_CLASSES_DIR;
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
    66
    static final File TEST_SOURCES_DIR;
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
    67
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
    68
    static final String JAVAHOME = System.getProperty("java.home");
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 12047
diff changeset
    69
    static final String JAVA_BIN;
21812
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
    70
    static final String JAVA_LIB;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    71
    static final String javaCmd;
11364
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
    72
    static final String javawCmd;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    73
    static final String javacCmd;
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
    74
    static final String jarCmd;
21812
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
    75
    static final boolean haveServerVM;
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
    76
    static final boolean haveClientVM;
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
    77
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    78
    static final JavaCompiler compiler;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    79
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
    80
    static final boolean debug = Boolean.getBoolean("TestHelper.Debug");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    81
    static final boolean isWindows =
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
    82
            System.getProperty("os.name", "unknown").startsWith("Windows");
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11687
diff changeset
    83
    static final boolean isMacOSX =
12538
211d6e82fe51 7130404: [macosx] "os.arch" value should be "x86_64" for compatibility with Apple JDK6
jmelvin
parents: 12301
diff changeset
    84
            System.getProperty("os.name", "unknown").contains("OS X");
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
    85
    static final boolean is64Bit =
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
    86
            System.getProperty("sun.arch.data.model").equals("64");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
    87
    static final boolean is32Bit =
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
    88
            System.getProperty("sun.arch.data.model").equals("32");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
    89
    static final boolean isSolaris =
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
    90
            System.getProperty("os.name", "unknown").startsWith("SunOS");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
    91
    static final boolean isLinux =
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
    92
            System.getProperty("os.name", "unknown").startsWith("Linux");
22602
0d9a07b0d7e9 8028537: PPC64: Updated the JDK regression tests to run on AIX
simonis
parents: 21812
diff changeset
    93
    static final boolean isAIX =
0d9a07b0d7e9 8028537: PPC64: Updated the JDK regression tests to run on AIX
simonis
parents: 21812
diff changeset
    94
            System.getProperty("os.name", "unknown").startsWith("AIX");
21812
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
    95
    static final String LIBJVM = isWindows
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
    96
                        ? "jvm.dll"
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
    97
                        : "libjvm" + (isMacOSX ? ".dylib" : ".so");
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
    98
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
    99
    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
   100
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   101
    // make a note of the golden default locale
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   102
    static final Locale DefaultLocale = Locale.getDefault();
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   103
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
   104
    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
   105
    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
   106
    static final String JAR_FILE_EXT   = ".jar";
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 12047
diff changeset
   107
    static final String EXE_FILE_EXT   = ".exe";
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   108
    static final String JLDEBUG_KEY     = "_JAVA_LAUNCHER_DEBUG";
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   109
    static final String EXPECTED_MARKER = "TRACER_MARKER:About to EXEC";
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   110
    static final String TEST_PREFIX     = "###TestError###: ";
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
   111
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   112
    static int testExitValue = 0;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   113
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   114
    static {
11679
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   115
        String tmp = System.getProperty("test.classes", null);
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   116
        if (tmp == null) {
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   117
            throw new Error("property test.classes not defined ??");
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   118
        }
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   119
        TEST_CLASSES_DIR = new File(tmp).getAbsoluteFile();
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   120
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   121
        tmp = System.getProperty("test.src", null);
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   122
        if (tmp == null) {
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   123
            throw new Error("property test.src not defined ??");
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   124
        }
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   125
        TEST_SOURCES_DIR = new File(tmp).getAbsoluteFile();
84da476c4537 7132270: tools/launcher/DefaultLocaleTestRun.java failing (win)
ksrini
parents: 11520
diff changeset
   126
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   127
        if (is64Bit && is32Bit) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   128
            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
   129
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   130
        if (!is64Bit && !is32Bit) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   131
            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
   132
        }
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   133
        compiler = ToolProvider.getSystemJavaCompiler();
21812
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   134
28115
3931c251d78f 8061442: Update jdk/tools tests to remove check for the "jre" directory
ksrini
parents: 27773
diff changeset
   135
        File binDir = new File(JAVAHOME, "bin");
12301
201cef0a3f12 7156976: improve java tools testing
ksrini
parents: 12047
diff changeset
   136
        JAVA_BIN = binDir.getAbsolutePath();
28115
3931c251d78f 8061442: Update jdk/tools tests to remove check for the "jre" directory
ksrini
parents: 27773
diff changeset
   137
        File libDir = new File(JAVAHOME, "lib");
21812
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   138
        JAVA_LIB = libDir.getAbsolutePath();
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   139
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   140
        File javaCmdFile = (isWindows)
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   141
                ? new File(binDir, "java.exe")
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   142
                : new File(binDir, "java");
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   143
        javaCmd = javaCmdFile.getAbsolutePath();
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   144
        if (!javaCmdFile.canExecute()) {
11364
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   145
            throw new RuntimeException("java <" + TestHelper.javaCmd +
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   146
                    "> must exist and should be executable");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   147
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   148
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   149
        File javacCmdFile = (isWindows)
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   150
                ? new File(binDir, "javac.exe")
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   151
                : new File(binDir, "javac");
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   152
        javacCmd = javacCmdFile.getAbsolutePath();
11364
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   153
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   154
        File jarCmdFile = (isWindows)
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   155
                ? new File(binDir, "jar.exe")
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   156
                : new File(binDir, "jar");
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   157
        jarCmd = jarCmdFile.getAbsolutePath();
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   158
        if (!jarCmdFile.canExecute()) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   159
            throw new RuntimeException("java <" + TestHelper.jarCmd +
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   160
                    "> must exist and should be executable");
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   161
        }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   162
11364
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   163
        if (isWindows) {
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   164
            File javawCmdFile = new File(binDir, "javaw.exe");
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   165
            javawCmd = javawCmdFile.getAbsolutePath();
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   166
            if (!javawCmdFile.canExecute()) {
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   167
                throw new RuntimeException("java <" + javawCmd +
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   168
                        "> must exist and should be executable");
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   169
            }
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   170
        } else {
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   171
            javawCmd = null;
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   172
        }
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   173
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   174
        if (!javacCmdFile.canExecute()) {
11364
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   175
            throw new RuntimeException("java <" + javacCmd +
7907324fed4f 7124443: (launcher) test DefaultsLocaleTest fails with Windows shells.
ksrini
parents: 10126
diff changeset
   176
                    "> must exist and should be executable");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   177
        }
21812
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   178
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   179
        haveClientVM = haveVmVariant("client");
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   180
        haveServerVM = haveVmVariant("server");
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   181
    }
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   182
    private static boolean haveVmVariant(String type) {
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   183
        if (isWindows) {
28115
3931c251d78f 8061442: Update jdk/tools tests to remove check for the "jre" directory
ksrini
parents: 27773
diff changeset
   184
            File vmDir = new File(JAVA_BIN, type);
21812
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   185
            File jvmFile = new File(vmDir, LIBJVM);
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   186
            return jvmFile.exists();
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   187
        } else {
28115
3931c251d78f 8061442: Update jdk/tools tests to remove check for the "jre" directory
ksrini
parents: 27773
diff changeset
   188
            File vmDir = new File(JAVA_LIB, type);
21812
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   189
            File vmArchDir = new File(vmDir, getJreArch());
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   190
            File jvmFile = new File(vmArchDir, LIBJVM);
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   191
            return jvmFile.exists();
c43ac963db3d 8023978: [TEST_BUG] launcher tests must exclude platforms without server vm
ksrini
parents: 20201
diff changeset
   192
        }
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   193
    }
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   194
    void run(String[] args) throws Exception {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   195
        int passed = 0, failed = 0;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   196
        final Pattern p = (args != null && args.length > 0)
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   197
                ? Pattern.compile(args[0])
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   198
                : null;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   199
        for (Method m : this.getClass().getDeclaredMethods()) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   200
            boolean selected = (p == null)
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   201
                    ? m.isAnnotationPresent(Test.class)
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   202
                    : p.matcher(m.getName()).matches();
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   203
            if (selected) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   204
                try {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   205
                    m.invoke(this, (Object[]) null);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   206
                    System.out.println(m.getName() + ": OK");
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   207
                    passed++;
13416
9732a77088fe 7189944: (launcher) test/tools/launcher/Arrrrghs.java needs a couple of minor fixes
ksrini
parents: 13411
diff changeset
   208
                    System.out.printf("Passed: %d, Failed: %d, ExitValue: %d%n",
9732a77088fe 7189944: (launcher) test/tools/launcher/Arrrrghs.java needs a couple of minor fixes
ksrini
parents: 13411
diff changeset
   209
                                      passed, failed, testExitValue);
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   210
                } catch (Throwable ex) {
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   211
                    System.out.printf("Test %s failed: %s %n", m, ex);
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   212
                    System.out.println("----begin detailed exceptions----");
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   213
                    ex.printStackTrace(System.out);
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   214
                    for (Throwable t : ex.getSuppressed()) {
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   215
                        t.printStackTrace(System.out);
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   216
                    }
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   217
                    System.out.println("----end detailed exceptions----");
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   218
                    failed++;
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   219
                }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   220
            }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   221
        }
13416
9732a77088fe 7189944: (launcher) test/tools/launcher/Arrrrghs.java needs a couple of minor fixes
ksrini
parents: 13411
diff changeset
   222
        System.out.printf("Total: Passed: %d, Failed %d%n", passed, failed);
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   223
        if (failed > 0) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   224
            throw new RuntimeException("Tests failed: " + failed);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   225
        }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   226
        if (passed == 0 && failed == 0) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   227
            throw new AssertionError("No test(s) selected: passed = " +
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   228
                    passed + ", failed = " + failed + " ??????????");
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   229
        }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   230
    }
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   231
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   232
    /*
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   233
     * 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
   234
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   235
    static String getJreArch() {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   236
        String arch = System.getProperty("os.arch");
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   237
        return arch.equals("x86") ? "i386" : arch;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   238
    }
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   239
    static String getArch() {
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   240
        return System.getProperty("os.arch");
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   241
    }
13675
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   242
    static File getClassFile(File javaFile) {
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   243
        String s = javaFile.getAbsolutePath().replace(JAVA_FILE_EXT, CLASS_FILE_EXT);
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   244
        return new File(s);
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   245
    }
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   246
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   247
    static File getJavaFile(File classFile) {
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   248
        String s = classFile.getAbsolutePath().replace(CLASS_FILE_EXT, JAVA_FILE_EXT);
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   249
        return new File(s);
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   250
    }
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   251
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   252
    static String baseName(File f) {
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   253
        String s = f.getName();
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   254
        return s.substring(0, s.indexOf("."));
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   255
    }
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   256
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   257
    /*
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   258
     * 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
   259
     */
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   260
    static void createJar(File jarName, String... mainDefs)
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   261
            throws FileNotFoundException{
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   262
        createJar(null, jarName, new File("Foo"), mainDefs);
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   263
    }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   264
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   265
    /*
1329
ce13b59a8401 4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents: 1323
diff changeset
   266
     * 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
   267
     * 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
   268
     */
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   269
    static void createJar(File jarName, File mainClass, String... mainDefs)
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   270
            throws FileNotFoundException {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   271
            createJar(null, jarName, mainClass, mainDefs);
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   272
    }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   273
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   274
    /*
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   275
     * A convenience method to compile java files.
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   276
     */
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   277
    static void compile(String... compilerArgs) {
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   278
        if (compiler.run(null, null, null, compilerArgs) != 0) {
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   279
            String sarg = "";
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   280
            for (String x : compilerArgs) {
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   281
                sarg.concat(x + " ");
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   282
            }
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   283
            throw new Error("compilation failed: " + sarg);
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   284
        }
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   285
    }
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   286
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   287
    /*
1329
ce13b59a8401 4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents: 1323
diff changeset
   288
     * 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
   289
     * 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
   290
     * 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
   291
     * as the Main-Class attribute value.
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   292
     */
1329
ce13b59a8401 4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents: 1323
diff changeset
   293
    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
   294
            String... mainDefs) throws FileNotFoundException {
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   295
        if (jarName.exists()) {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   296
            jarName.delete();
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   297
        }
10126
a375b8714147 7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents: 9734
diff changeset
   298
        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
   299
            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
   300
            if (mainDefs != null) {
a375b8714147 7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents: 9734
diff changeset
   301
                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
   302
                    ps.println(x);
a375b8714147 7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents: 9734
diff changeset
   303
                }
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   304
            }
10126
a375b8714147 7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents: 9734
diff changeset
   305
            ps.println("}");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   306
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   307
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   308
        String compileArgs[] = {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   309
            mainClass + ".java"
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   310
        };
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   311
        if (compiler.run(null, null, null, compileArgs) != 0) {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   312
            throw new RuntimeException("compilation failed " + mainClass + ".java");
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   313
        }
1329
ce13b59a8401 4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents: 1323
diff changeset
   314
        if (mEntry == null) {
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   315
            mEntry = mainClass.getName();
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   316
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   317
        String jarArgs[] = {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   318
            (debug) ? "cvfe" : "cfe",
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   319
            jarName.getAbsolutePath(),
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   320
            mEntry,
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   321
            mainClass.getName() + ".class"
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   322
        };
10126
a375b8714147 7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents: 9734
diff changeset
   323
        createJar(jarArgs);
a375b8714147 7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents: 9734
diff changeset
   324
    }
a375b8714147 7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents: 9734
diff changeset
   325
a375b8714147 7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents: 9734
diff changeset
   326
   static void createJar(String... args) {
27773
938fb14f357a 8060026: Update jdk/test/tools/launcher tests to eliminate dependency on sun.tools.jar.Main
ksrini
parents: 22602
diff changeset
   327
        List<String> cmdList = new ArrayList<>();
938fb14f357a 8060026: Update jdk/test/tools/launcher tests to eliminate dependency on sun.tools.jar.Main
ksrini
parents: 22602
diff changeset
   328
        cmdList.add(jarCmd);
938fb14f357a 8060026: Update jdk/test/tools/launcher tests to eliminate dependency on sun.tools.jar.Main
ksrini
parents: 22602
diff changeset
   329
        cmdList.addAll(Arrays.asList(args));
938fb14f357a 8060026: Update jdk/test/tools/launcher tests to eliminate dependency on sun.tools.jar.Main
ksrini
parents: 22602
diff changeset
   330
        doExec(cmdList.toArray(new String[cmdList.size()]));
10126
a375b8714147 7067922: (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
ksrini
parents: 9734
diff changeset
   331
   }
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   332
13675
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   333
   static void copyStream(InputStream in, OutputStream out) throws IOException {
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   334
        byte[] buf = new byte[8192];
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   335
        int n = in.read(buf);
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   336
        while (n > 0) {
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   337
            out.write(buf, 0, n);
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   338
            n = in.read(buf);
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   339
        }
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   340
    }
c2999ee84468 7194005: (launcher) needs to be enhanced for 64-bit jar file handling
ksrini
parents: 13416
diff changeset
   341
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   342
   static void copyFile(File src, File dst) throws IOException {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   343
        Path parent = dst.toPath().getParent();
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   344
        if (parent != null) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   345
            Files.createDirectories(parent);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   346
        }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   347
        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
   348
    }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   349
14763
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   350
    /**
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   351
     * Attempt to create a file at the given location. If an IOException
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   352
     * occurs then back off for a moment and try again. When a number of
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   353
     * attempts fail, give up and throw an exception.
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   354
     */
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   355
    void createAFile(File aFile, List<String> contents) throws IOException {
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   356
        IOException cause = null;
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   357
        for (int attempts = 0; attempts < 10; attempts++) {
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   358
            try {
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   359
                Files.write(aFile.getAbsoluteFile().toPath(), contents,
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   360
                    Charset.defaultCharset(), CREATE, TRUNCATE_EXISTING, WRITE);
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   361
                if (cause != null) {
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   362
                    /*
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   363
                     * report attempts and errors that were encountered
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   364
                     * for diagnostic purposes
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   365
                     */
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   366
                    System.err.println("Created batch file " +
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   367
                                        aFile + " in " + (attempts + 1) +
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   368
                                        " attempts");
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   369
                    System.err.println("Errors encountered: " + cause);
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   370
                    cause.printStackTrace();
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   371
                }
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   372
                return;
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   373
            } catch (IOException ioe) {
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   374
                if (cause != null) {
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   375
                    // chain the exceptions so they all get reported for diagnostics
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   376
                    cause.addSuppressed(ioe);
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   377
                } else {
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   378
                    cause = ioe;
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   379
                }
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   380
            }
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   381
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   382
            try {
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   383
                Thread.sleep(500);
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   384
            } catch (InterruptedException ie) {
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   385
                if (cause != null) {
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   386
                    // cause should alway be non-null here
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   387
                    ie.addSuppressed(cause);
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   388
                }
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   389
                throw new RuntimeException("Interrupted while creating batch file", ie);
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   390
            }
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   391
        }
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   392
        throw new RuntimeException("Unable to create batch file", cause);
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   393
    }
c16fa130fa23 8004042: Arrrghs.java test failed on windows with access error.
ksrini
parents: 14518
diff changeset
   394
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   395
    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
   396
        Files.write(outFile.getAbsoluteFile().toPath(), content,
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   397
                Charset.defaultCharset(), CREATE_NEW);
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   398
    }
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   399
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   400
    static void recursiveDelete(File target) throws IOException {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   401
        if (!target.exists()) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   402
            return;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   403
        }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   404
        Files.walkFileTree(target.toPath(), new SimpleFileVisitor<Path>() {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   405
            @Override
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   406
            public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   407
                try {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   408
                    Files.deleteIfExists(dir);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   409
                } catch (IOException ex) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   410
                    System.out.println("Error: could not delete: " + dir.toString());
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   411
                    System.out.println(ex.getMessage());
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   412
                    return FileVisitResult.TERMINATE;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   413
                }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   414
                return FileVisitResult.CONTINUE;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   415
            }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   416
            @Override
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   417
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   418
                try {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   419
                    Files.deleteIfExists(file);
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   420
                } catch (IOException ex) {
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   421
                    System.out.println("Error: could not delete: " + file.toString());
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   422
                    System.out.println(ex.getMessage());
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   423
                    return FileVisitResult.TERMINATE;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   424
                }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   425
                return FileVisitResult.CONTINUE;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   426
            }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   427
        });
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   428
    }
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   429
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   430
    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
   431
        return doExec(null, null, cmds);
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   432
    }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   433
12527
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents: 12301
diff changeset
   434
    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
   435
        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
   436
    }
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   437
    /*
1329
ce13b59a8401 4459600: java -jar fails to run Main-Class if classname followed by whitespace.
ksrini
parents: 1323
diff changeset
   438
     * 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
   439
     */
12527
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents: 12301
diff changeset
   440
    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
   441
                             Set<String> envToRemove, String...cmds) {
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   442
        String cmdStr = "";
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   443
        for (String x : cmds) {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   444
            cmdStr = cmdStr.concat(x + " ");
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   445
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   446
        ProcessBuilder pb = new ProcessBuilder(cmds);
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   447
        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
   448
        if (envToRemove != null) {
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents: 12301
diff changeset
   449
            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
   450
                env.remove(key);
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents: 12301
diff changeset
   451
            }
22abaf748b5b 7131021: [macosx] Consider using system properties to pass arguments from the launcher to AWT/SplashScreen
anthony
parents: 12301
diff changeset
   452
        }
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   453
        if (envToSet != null) {
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   454
            env.putAll(envToSet);
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   455
        }
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   456
        BufferedReader rdr = null;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   457
        try {
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   458
            List<String> outputList = new ArrayList<>();
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   459
            pb.redirectErrorStream(true);
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   460
            Process p = pb.start();
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   461
            rdr = new BufferedReader(new InputStreamReader(p.getInputStream()));
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   462
            String in = rdr.readLine();
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   463
            while (in != null) {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   464
                outputList.add(in);
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   465
                in = rdr.readLine();
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   466
            }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   467
            p.waitFor();
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   468
            p.destroy();
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   469
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   470
            return new TestHelper.TestResult(cmdStr, p.exitValue(), outputList,
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   471
                    env, new Throwable("current stack of the test"));
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   472
        } catch (Exception ex) {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   473
            ex.printStackTrace();
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   474
            throw new RuntimeException(ex.getMessage());
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   475
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   476
    }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   477
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
   478
    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
   479
        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
   480
            @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
   481
            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
   482
                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
   483
                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
   484
                    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
   485
                }
1c485b79de81 7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents: 11364
diff changeset
   486
                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
   487
            }
1c485b79de81 7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents: 11364
diff changeset
   488
        };
1c485b79de81 7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents: 11364
diff changeset
   489
    }
1c485b79de81 7125442: jar application located in two bytes character named folder cannot be run with JRE 7 u1/u2
ksrini
parents: 11364
diff changeset
   490
11687
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   491
    static boolean isEnglishLocale() {
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   492
        return Locale.getDefault().getLanguage().equals("en");
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   493
    }
f13cadbb0bb5 7127906: (launcher) convert the launcher regression tests to java
ksrini
parents: 11679
diff changeset
   494
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   495
    /*
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   496
     * A class to encapsulate the test results and stuff, with some ease
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   497
     * of use methods to check the test results.
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   498
     */
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   499
    static class TestResult {
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   500
        PrintWriter status;
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   501
        StringWriter sw;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   502
        int exitValue;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   503
        List<String> testOutput;
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   504
        Map<String, String> env;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   505
        Throwable t;
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   506
        boolean testStatus;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   507
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   508
        public TestResult(String str, int rv, List<String> oList,
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   509
                Map<String, String> env, Throwable t) {
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   510
            sw = new StringWriter();
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   511
            status = new PrintWriter(sw);
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   512
            status.println("Executed command: " + str + "\n");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   513
            exitValue = rv;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   514
            testOutput = oList;
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   515
            this.env = env;
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   516
            this.t = t;
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   517
            testStatus = true;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   518
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   519
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   520
        void appendError(String x) {
13416
9732a77088fe 7189944: (launcher) test/tools/launcher/Arrrrghs.java needs a couple of minor fixes
ksrini
parents: 13411
diff changeset
   521
            testStatus = false;
9732a77088fe 7189944: (launcher) test/tools/launcher/Arrrrghs.java needs a couple of minor fixes
ksrini
parents: 13411
diff changeset
   522
            testExitValue++;
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   523
            status.println(TEST_PREFIX + x);
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   524
        }
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   525
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   526
        void indentStatus(String x) {
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   527
            status.println("  " + x);
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   528
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   529
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   530
        void checkNegative() {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   531
            if (exitValue == 0) {
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   532
                appendError("test must not return 0 exit value");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   533
            }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   534
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   535
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   536
        void checkPositive() {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   537
            if (exitValue != 0) {
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   538
                appendError("test did not return 0 exit value");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   539
            }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   540
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   541
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   542
        boolean isOK() {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   543
            return exitValue == 0;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   544
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   545
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   546
        boolean isZeroOutput() {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   547
            if (!testOutput.isEmpty()) {
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   548
                appendError("No message from cmd please");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   549
                return false;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   550
            }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   551
            return true;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   552
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   553
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   554
        boolean isNotZeroOutput() {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   555
            if (testOutput.isEmpty()) {
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   556
                appendError("Missing message");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   557
                return false;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   558
            }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   559
            return true;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   560
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   561
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   562
        @Override
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   563
        public String toString() {
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   564
            status.println("++++Begin Test Info++++");
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   565
            status.println("Test Status: " + (testStatus ? "PASS" : "FAIL"));
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   566
            status.println("++++Test Environment++++");
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   567
            for (String x : env.keySet()) {
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   568
                indentStatus(x + "=" + env.get(x));
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   569
            }
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   570
            status.println("++++Test Output++++");
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   571
            for (String x : testOutput) {
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   572
                indentStatus(x);
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   573
            }
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   574
            status.println("++++Test Stack Trace++++");
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   575
            status.println(t.toString());
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   576
            for (StackTraceElement e : t.getStackTrace()) {
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   577
                indentStatus(e.toString());
9244
84d85c90d5db 7029048: (launcher) fence the launcher against LD_LIBRARY_PATH
ksrini
parents: 5506
diff changeset
   578
            }
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   579
            status.println("++++End of Test Info++++");
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   580
            status.flush();
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   581
            String out = sw.toString();
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   582
            status.close();
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   583
            return out;
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   584
        }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   585
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   586
        boolean contains(String str) {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   587
            for (String x : testOutput) {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   588
                if (x.contains(str)) {
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   589
                    return true;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   590
                }
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   591
            }
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12538
diff changeset
   592
            appendError("string <" + str + "> not found");
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   593
            return false;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   594
        }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   595
14518
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13675
diff changeset
   596
        boolean notContains(String str) {
32267
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 28115
diff changeset
   597
            for (String x : testOutput) {
14518
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13675
diff changeset
   598
                if (x.contains(str)) {
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13675
diff changeset
   599
                    appendError("string <" + str + "> found");
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13675
diff changeset
   600
                    return false;
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13675
diff changeset
   601
                }
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13675
diff changeset
   602
            }
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13675
diff changeset
   603
            return true;
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13675
diff changeset
   604
        }
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13675
diff changeset
   605
37540
e92d95400f31 8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents: 32267
diff changeset
   606
        boolean matches(String regexToMatch) {
32267
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 28115
diff changeset
   607
            for (String x : testOutput) {
37540
e92d95400f31 8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents: 32267
diff changeset
   608
                if (x.matches(regexToMatch)) {
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   609
                    return true;
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   610
                }
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 1329
diff changeset
   611
            }
37540
e92d95400f31 8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents: 32267
diff changeset
   612
            appendError("regex <" + regexToMatch + "> not matched");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   613
            return false;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   614
        }
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   615
37540
e92d95400f31 8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents: 32267
diff changeset
   616
        boolean notMatches(String regexToMatch) {
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   617
            for (String x : testOutput) {
37540
e92d95400f31 8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents: 32267
diff changeset
   618
                if (!x.matches(regexToMatch)) {
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   619
                    return true;
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   620
                }
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   621
            }
37540
e92d95400f31 8154470: defines.h confused about PROGNAME and JAVA_ARGS
martin
parents: 32267
diff changeset
   622
            appendError("regex <" + regexToMatch + "> matched");
20201
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   623
            return false;
50cc2d25a60b 8020552: [launcher] changes to support removal of Solaris 32-bit distribution
ksrini
parents: 14763
diff changeset
   624
        }
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   625
    }
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   626
    /**
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   627
    * Indicates that the annotated method is a test method.
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   628
    */
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   629
    @Retention(RetentionPolicy.RUNTIME)
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   630
    @Target(ElementType.METHOD)
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12561
diff changeset
   631
    public @interface Test {}
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents:
diff changeset
   632
}