src/java.base/share/native/libjli/java.c
author mbaesken
Thu, 28 Nov 2019 13:02:39 +0100
changeset 59323 ae2eb76c486d
parent 58280 ef8c8cf9256a
permissions -rw-r--r--
8234821: remove unused functions from libjli Reviewed-by: clanger, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
53941
f9302cf718c9 8215009: GCC 8 compilation error in libjli
dchuyko
parents: 51841
diff changeset
     2
 * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4525
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4525
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4525
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4525
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4525
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * Shared source for 'java' command line tool.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * If JAVA_ARGS is defined, then acts as a launcher for applications. For
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * instance, the JDK command line tools such as javac and javadoc (see
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * makefiles for more details) are built with this program.  Any arguments
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * prefixed with '-J' will be passed directly to the 'java' command.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * One job of the launcher is to remove command line options which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * vm does not understand and will not process.  These options include
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * options which select which style of vm is run (e.g. -client and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * -server) as well as options which select the data model to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Additionally, for tools which invoke an underlying vm "-J-foo"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * options are turned into "-foo" options to the vm.  This option
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * filtering is handled in a number of places in the launcher, some of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * it in machine-dependent code.  In this file, the function
4340
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 3054
diff changeset
    44
 * CheckJvmType removes vm style options and TranslateApplicationArgs
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 3054
diff changeset
    45
 * removes "-J" prefixes.  The CreateExecutionEnvironment function processes
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 3054
diff changeset
    46
 * and removes -d<n> options. On unix, there is a possibility that the running
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 3054
diff changeset
    47
 * data model may not match to the desired data model, in this case an exec is
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 3054
diff changeset
    48
 * required to start the desired model. If the data models match, then
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 3054
diff changeset
    49
 * ParseArguments will remove the -d<n> flags. If the data models do not match
ec6ba551fa78 6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents: 3054
diff changeset
    50
 * the CreateExecutionEnviroment will remove the -d<n> flags.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#include "java.h"
49440
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 47251
diff changeset
    55
#include "jni.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * A NOTE TO DEVELOPERS: For performance reasons it is important that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * the program image remain relatively small until after SelectVersion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * CreateExecutionEnvironment have finished their possibly recursive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * processing. Watch everything, but resist all temptations to use Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * interfaces.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
    65
#define USE_STDERR JNI_TRUE     /* we usually print to stderr */
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
    66
#define USE_STDOUT JNI_FALSE
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
    67
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
static jboolean printVersion = JNI_FALSE; /* print and exit */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
static jboolean showVersion = JNI_FALSE;  /* print but continue */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
static jboolean printUsage = JNI_FALSE;   /* print and exit*/
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
    71
static jboolean printTo = USE_STDERR;     /* where to print version/usage */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
static jboolean printXUsage = JNI_FALSE;  /* print and exit*/
39303
5aefc354587e 8159596: Add java --dry-run
mchung
parents: 38753
diff changeset
    73
static jboolean dryRun = JNI_FALSE;       /* initialize VM and exit */
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
    74
static char     *showSettings = NULL;     /* print but continue */
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
    75
static jboolean showResolvedModules = JNI_FALSE;
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
    76
static jboolean listModules = JNI_FALSE;
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
    77
static char     *describeModule = NULL;
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
    78
static jboolean validateModules = JNI_FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
static const char *_program_name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
static const char *_launcher_name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
static jboolean _is_java_args = JNI_FALSE;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
    83
static jboolean _have_classpath = JNI_FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
static const char *_fVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
static jboolean _wc_enabled = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * Entries for splash screen environment variables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * putenv is performed in SelectVersion. We need
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * them in memory until UnsetEnv, so they are made static
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * global instead of auto local.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
static char* splash_file_entry = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
static char* splash_jar_entry = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * List of VM options to be specified when the VM is created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
static JavaVMOption *options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
static int numOptions, maxOptions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * Prototypes for functions internal to launcher.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 */
59323
ae2eb76c486d 8234821: remove unused functions from libjli
mbaesken
parents: 58280
diff changeset
   105
static const char* GetFullVersion();
ae2eb76c486d 8234821: remove unused functions from libjli
mbaesken
parents: 58280
diff changeset
   106
static jboolean IsJavaArgs();
ae2eb76c486d 8234821: remove unused functions from libjli
mbaesken
parents: 58280
diff changeset
   107
static void SetJavaLauncherProp();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
static void SetClassPath(const char *s);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   109
static void SetMainModule(const char *s);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
static void SelectVersion(int argc, char **argv, char **main_class);
25816
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   111
static void SetJvmEnvironment(int argc, char **argv);
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   112
static jboolean ParseArguments(int *pargc, char ***pargv,
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   113
                               int *pmode, char **pwhat,
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   114
                               int *pret, const char *jrepath);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
static jboolean InitializeJVM(JavaVM **pvm, JNIEnv **penv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                              InvocationFunctions *ifn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
static jstring NewPlatformString(JNIEnv *env, char *s);
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   118
static jclass LoadMainClass(JNIEnv *env, int mode, char *name);
14518
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   119
static jclass GetApplicationClass(JNIEnv *env);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
static void TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***pargv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
static jboolean AddApplicationOptions(int cpathc, const char **cpathv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
static void SetApplicationClassPath(const char**);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
static void PrintJavaVersion(JNIEnv *env, jboolean extraLF);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
static void PrintUsage(JNIEnv* env, jboolean doXUsage);
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   127
static void ShowSettings(JNIEnv* env, char *optString);
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   128
static void ShowResolvedModules(JNIEnv* env);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   129
static void ListModules(JNIEnv* env);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   130
static void DescribeModule(JNIEnv* env, char* optString);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   131
static jboolean ValidateModules(JNIEnv* env);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
static void SetPaths(int argc, char **argv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
static void DumpState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   137
enum OptionKind {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   138
    LAUNCHER_OPTION = 0,
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   139
    LAUNCHER_OPTION_WITH_ARGUMENT,
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   140
    LAUNCHER_MAIN_OPTION,
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   141
    VM_LONG_OPTION,
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   142
    VM_LONG_OPTION_WITH_ARGUMENT,
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   143
    VM_OPTION
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   144
};
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   145
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   146
static int GetOpt(int *pargc, char ***pargv, char **poption, char **pvalue);
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   147
static jboolean IsOptionWithArgument(int argc, char **argv);
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   148
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
/* Maximum supported entries from jvm.cfg. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
#define INIT_MAX_KNOWN_VMS      10
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
/* Values for vmdesc.flag */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
enum vmdesc_flag {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    VM_UNKNOWN = -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    VM_KNOWN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    VM_ALIASED_TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    VM_WARN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    VM_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    VM_IF_SERVER_CLASS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    VM_IGNORE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
struct vmdesc {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    char *name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    int flag;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    char *alias;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    char *server_class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
static struct vmdesc *knownVMs = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
static int knownVMsCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
static int knownVMsLimit = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
31476
d1e837c96aba 8130315: Fix wrong prototype of GrowKnownVMs() in java.c
simonis
parents: 29742
diff changeset
   173
static void GrowKnownVMs(int minimum);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
static int  KnownVMIndex(const char* name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
static void FreeKnownVMs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
static jboolean IsWildCardEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   178
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   179
#define SOURCE_LAUNCHER_MAIN_ENTRY "jdk.compiler/com.sun.tools.javac.launcher.Main"
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   180
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   181
/*
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   182
 * This reports error.  VM will not be created and no usage is printed.
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   183
 */
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   184
#define REPORT_ERROR(AC_ok, AC_failure_message, AC_questionable_arg) \
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   185
    do { \
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   186
        if (!AC_ok) { \
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   187
            JLI_ReportErrorMessage(AC_failure_message, AC_questionable_arg); \
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   188
            printUsage = JNI_FALSE; \
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   189
            *pret = 1; \
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   190
            return JNI_FALSE; \
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   191
        } \
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   192
    } while (JNI_FALSE)
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   193
17445
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   194
#define ARG_CHECK(AC_arg_count, AC_failure_message, AC_questionable_arg) \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   195
    do { \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   196
        if (AC_arg_count < 1) { \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   197
            JLI_ReportErrorMessage(AC_failure_message, AC_questionable_arg); \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   198
            printUsage = JNI_TRUE; \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   199
            *pret = 1; \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   200
            return JNI_TRUE; \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   201
        } \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   202
    } while (JNI_FALSE)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
 * Running Java code in primordial thread caused many problems. We will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
 * create a new thread to invoke JVM. See 6316197 for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
 */
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
   208
static jlong threadStackSize    = 0;  /* stack size of the new thread */
7810
d4730191e53c 7002386: (launcher) fix XshowSettings
ksrini
parents: 7297
diff changeset
   209
static jlong maxHeapSize        = 0;  /* max heap size */
54543
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   210
static jlong initialHeapSize    = 0;  /* initial heap size */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
/*
54543
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   213
 * A minimum initial-thread stack size suitable for most platforms.
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   214
 * This is the minimum amount of stack needed to load the JVM such
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   215
 * that it can reject a too small -Xss value. If this is too small
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   216
 * JVM initialization would cause a StackOverflowError.
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   217
  */
28102
0efebd8c99e2 6762191: Setting stack size to 16K causes segmentation fault
cjplummer
parents: 25859
diff changeset
   218
#ifndef STACK_SIZE_MINIMUM
46850
970a24772fe4 8177015: STACK_SIZE_MINIMUM of 32k is not always enough for Mac OS X
cjplummer
parents: 43498
diff changeset
   219
#define STACK_SIZE_MINIMUM (64 * KB)
28102
0efebd8c99e2 6762191: Setting stack size to 16K causes segmentation fault
cjplummer
parents: 25859
diff changeset
   220
#endif
0efebd8c99e2 6762191: Setting stack size to 16K causes segmentation fault
cjplummer
parents: 25859
diff changeset
   221
0efebd8c99e2 6762191: Setting stack size to 16K causes segmentation fault
cjplummer
parents: 25859
diff changeset
   222
/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 * Entry point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 */
49440
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 47251
diff changeset
   225
JNIEXPORT int JNICALL
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   226
JLI_Launch(int argc, char ** argv,              /* main argc, argv */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        int jargc, const char** jargv,          /* java args */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        int appclassc, const char** appclassv,  /* app classpath */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        const char* fullversion,                /* full version defined */
33987
24ecd3c83f33 8129601: [launcher] test VersionCheck.java fails with new version string
ksrini
parents: 29742
diff changeset
   230
        const char* dotversion,                 /* UNUSED dot version defined */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        const char* pname,                      /* program name */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        const char* lname,                      /* launcher name */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        jboolean javaargs,                      /* JAVA_ARGS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        jboolean cpwildcard,                    /* classpath wildcard*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        jboolean javaw,                         /* windows-only javaw */
41966
bac52fa6e617 8169001: Remove launcher's built-in ergonomics
ksrini
parents: 41814
diff changeset
   236
        jint ergo                               /* unused */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
{
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   239
    int mode = LM_UNKNOWN;
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   240
    char *what = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    char *main_class = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    int ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    InvocationFunctions ifn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    jlong start, end;
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   245
    char jvmpath[MAXPATHLEN];
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   246
    char jrepath[MAXPATHLEN];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
   247
    char jvmcfg[MAXPATHLEN];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    _fVersion = fullversion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    _launcher_name = lname;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    _program_name = pname;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    _is_java_args = javaargs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    _wc_enabled = cpwildcard;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
39
560da37936db 6596475: (launcher) javaw should call InitCommonControls
ksrini
parents: 2
diff changeset
   255
    InitLauncher(javaw);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    DumpState();
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
   257
    if (JLI_IsTraceLauncher()) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
   258
        int i;
45463
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 45067
diff changeset
   259
        printf("Java args:\n");
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 45067
diff changeset
   260
        for (i = 0; i < jargc ; i++) {
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 45067
diff changeset
   261
            printf("jargv[%d] = %s\n", i, jargv[i]);
d9325138bac6 8180334: Unable to build jaotc launcher on windows
ksrini
parents: 45067
diff changeset
   262
        }
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
   263
        printf("Command line args:\n");
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
   264
        for (i = 0; i < argc ; i++) {
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
   265
            printf("argv[%d] = %s\n", i, argv[i]);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
   266
        }
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
   267
        AddOption("-Dsun.java.launcher.diag=true", NULL);
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
   268
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /*
27938
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
   271
     * SelectVersion() has several responsibilities:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     *
27938
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
   273
     *  1) Disallow specification of another JRE.  With 1.9, another
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
   274
     *     version of the JRE cannot be invoked.
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
   275
     *  2) Allow for a JRE version to invoke JDK 1.9 or later.  Since
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
   276
     *     all mJRE directives have been stripped from the request but
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
   277
     *     the pre 1.9 JRE [ 1.6 thru 1.8 ], it is as if 1.9+ has been
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
   278
     *     invoked from the command line.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    SelectVersion(argc, argv, &main_class);
21606
1984e107a4b3 8027755: Anti-delta incorrect push for 8025198
dholmes
parents: 21605
diff changeset
   281
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    CreateExecutionEnvironment(&argc, &argv,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                               jrepath, sizeof(jrepath),
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
   284
                               jvmpath, sizeof(jvmpath),
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
   285
                               jvmcfg,  sizeof(jvmcfg));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
25816
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   287
    if (!IsJavaArgs()) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   288
        SetJvmEnvironment(argc,argv);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   289
    }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   290
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    ifn.CreateJavaVM = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    ifn.GetDefaultJavaVMInitArgs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    if (JLI_IsTraceLauncher()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        start = CounterGet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
21606
1984e107a4b3 8027755: Anti-delta incorrect push for 8025198
dholmes
parents: 21605
diff changeset
   297
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    if (!LoadJavaVM(jvmpath, &ifn)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        return(6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
21606
1984e107a4b3 8027755: Anti-delta incorrect push for 8025198
dholmes
parents: 21605
diff changeset
   301
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    if (JLI_IsTraceLauncher()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        end   = CounterGet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    JLI_TraceLauncher("%ld micro seconds to LoadJavaVM\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
             (long)(jint)Counter2Micros(end-start));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    ++argv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    --argc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    if (IsJavaArgs()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        /* Preprocess wrapper arguments */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        TranslateApplicationArgs(jargc, jargv, &argc, &argv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        if (!AddApplicationOptions(appclassc, appclassv)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            return(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        /* Set default CLASSPATH */
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   320
        char* cpath = getenv("CLASSPATH");
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   321
        if (cpath != NULL) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   322
            SetClassPath(cpath);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   326
    /* Parse command line options; if the return value of
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   327
     * ParseArguments is false, the program should exit.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     */
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   329
    if (!ParseArguments(&argc, &argv, &mode, &what, &ret, jrepath)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        return(ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    /* Override class path if -jar flag was specified */
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   334
    if (mode == LM_JAR) {
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   335
        SetClassPath(what);     /* Override class path */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    /* set the -Dsun.java.command pseudo property */
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   339
    SetJavaCommandLineProp(what, argc, argv);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    /* Set the -Dsun.java.launcher pseudo property */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    SetJavaLauncherProp();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
21606
1984e107a4b3 8027755: Anti-delta incorrect push for 8025198
dholmes
parents: 21605
diff changeset
   344
    return JVMInit(&ifn, threadStackSize, argc, argv, mode, what, ret);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
}
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   346
/*
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   347
 * Always detach the main thread so that it appears to have ended when
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   348
 * the application's main method exits.  This will invoke the
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   349
 * uncaught exception handler machinery if main threw an
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   350
 * exception.  An uncaught exception handler cannot change the
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   351
 * launcher's return code except by calling System.exit.
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   352
 *
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   353
 * Wait for all non-daemon threads to end, then destroy the VM.
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   354
 * This will actually create a trivial new Java waiter thread
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   355
 * named "DestroyJavaVM", but this will be seen as a different
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   356
 * thread from the one that executed main, even though they are
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   357
 * the same C thread.  This allows mainThread.join() and
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   358
 * mainThread.isAlive() to work as expected.
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   359
 */
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   360
#define LEAVE() \
17445
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   361
    do { \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   362
        if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   363
            JLI_ReportErrorMessage(JVM_ERROR2); \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   364
            ret = 1; \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   365
        } \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   366
        if (JNI_TRUE) { \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   367
            (*vm)->DestroyJavaVM(vm); \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   368
            return ret; \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   369
        } \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   370
    } while (JNI_FALSE)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
17445
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   372
#define CHECK_EXCEPTION_NULL_LEAVE(CENL_exception) \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   373
    do { \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   374
        if ((*env)->ExceptionOccurred(env)) { \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   375
            JLI_ReportExceptionDescription(env); \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   376
            LEAVE(); \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   377
        } \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   378
        if ((CENL_exception) == NULL) { \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   379
            JLI_ReportErrorMessage(JNI_ERROR); \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   380
            LEAVE(); \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   381
        } \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   382
    } while (JNI_FALSE)
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   383
17445
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   384
#define CHECK_EXCEPTION_LEAVE(CEL_return_value) \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   385
    do { \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   386
        if ((*env)->ExceptionOccurred(env)) { \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   387
            JLI_ReportExceptionDescription(env); \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   388
            ret = (CEL_return_value); \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   389
            LEAVE(); \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   390
        } \
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   391
    } while (JNI_FALSE)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
22279
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
   393
53941
f9302cf718c9 8215009: GCC 8 compilation error in libjli
dchuyko
parents: 51841
diff changeset
   394
int
f9302cf718c9 8215009: GCC 8 compilation error in libjli
dchuyko
parents: 51841
diff changeset
   395
JavaMain(void* _args)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    JavaMainArgs *args = (JavaMainArgs *)_args;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    int argc = args->argc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    char **argv = args->argv;
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   400
    int mode = args->mode;
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   401
    char *what = args->what;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    InvocationFunctions ifn = args->ifn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    JavaVM *vm = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    JNIEnv *env = 0;
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   406
    jclass mainClass = NULL;
14518
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   407
    jclass appClass = NULL; // actual application class being launched
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    jmethodID mainID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    jobjectArray mainArgs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    int ret = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    jlong start, end;
21606
1984e107a4b3 8027755: Anti-delta incorrect push for 8025198
dholmes
parents: 21605
diff changeset
   412
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
   413
    RegisterThread();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
   414
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    /* Initialize the virtual machine */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    start = CounterGet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    if (!InitializeJVM(&vm, &env, &ifn)) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
   418
        JLI_ReportErrorMessage(JVM_ERROR1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
11363
09b0c9731145 7123582: (launcher) display the -version and -XshowSettings
ksrini
parents: 9035
diff changeset
   422
    if (showSettings != NULL) {
09b0c9731145 7123582: (launcher) display the -version and -XshowSettings
ksrini
parents: 9035
diff changeset
   423
        ShowSettings(env, showSettings);
09b0c9731145 7123582: (launcher) display the -version and -XshowSettings
ksrini
parents: 9035
diff changeset
   424
        CHECK_EXCEPTION_LEAVE(1);
09b0c9731145 7123582: (launcher) display the -version and -XshowSettings
ksrini
parents: 9035
diff changeset
   425
    }
09b0c9731145 7123582: (launcher) display the -version and -XshowSettings
ksrini
parents: 9035
diff changeset
   426
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   427
    // show resolved modules and continue
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   428
    if (showResolvedModules) {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   429
        ShowResolvedModules(env);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   430
        CHECK_EXCEPTION_LEAVE(1);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   431
    }
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   432
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   433
    // list observable modules, then exit
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   434
    if (listModules) {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   435
        ListModules(env);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   436
        CHECK_EXCEPTION_LEAVE(1);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   437
        LEAVE();
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   438
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   439
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   440
    // describe a module, then exit
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   441
    if (describeModule != NULL) {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   442
        DescribeModule(env, describeModule);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   443
        CHECK_EXCEPTION_LEAVE(1);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   444
        LEAVE();
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   445
    }
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   446
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    if (printVersion || showVersion) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        PrintJavaVersion(env, showVersion);
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   449
        CHECK_EXCEPTION_LEAVE(0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        if (printVersion) {
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   451
            LEAVE();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
50700
97e9c4f58986 8194937: Inconsistent behavior of --validate-modules when combined with -m and other options
alanb
parents: 50453
diff changeset
   455
    // modules have been validated at startup so exit
97e9c4f58986 8194937: Inconsistent behavior of --validate-modules when combined with -m and other options
alanb
parents: 50453
diff changeset
   456
    if (validateModules) {
97e9c4f58986 8194937: Inconsistent behavior of --validate-modules when combined with -m and other options
alanb
parents: 50453
diff changeset
   457
        LEAVE();
97e9c4f58986 8194937: Inconsistent behavior of --validate-modules when combined with -m and other options
alanb
parents: 50453
diff changeset
   458
    }
97e9c4f58986 8194937: Inconsistent behavior of --validate-modules when combined with -m and other options
alanb
parents: 50453
diff changeset
   459
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    /* If the user specified neither a class name nor a JAR file */
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   461
    if (printXUsage || printUsage || what == 0 || mode == LM_UNKNOWN) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        PrintUsage(env, printXUsage);
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   463
        CHECK_EXCEPTION_LEAVE(1);
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   464
        LEAVE();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
41966
bac52fa6e617 8169001: Remove launcher's built-in ergonomics
ksrini
parents: 41814
diff changeset
   467
    FreeKnownVMs(); /* after last possible PrintUsage */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    if (JLI_IsTraceLauncher()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        end = CounterGet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        JLI_TraceLauncher("%ld micro seconds to InitializeJVM\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
               (long)(jint)Counter2Micros(end-start));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   475
    /* At this stage, argc/argv have the application's arguments */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    if (JLI_IsTraceLauncher()){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        int i;
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   478
        printf("%s is '%s'\n", launchModeNames[mode], what);
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   479
        printf("App's argc is %d\n", argc);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        for (i=0; i < argc; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            printf("    argv[%2d] = '%s'\n", i, argv[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    ret = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    /*
39345
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   488
     * Get the application's main class. It also checks if the main
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   489
     * method exists.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * See bugid 5030265.  The Main-Class name has already been parsed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * from the manifest, but not parsed properly for UTF-8 support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * Hence the code here ignores the value previously extracted and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * uses the pre-existing code to reextract the value.  This is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * possibly an end of release cycle expedient.  However, it has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * also been discovered that passing some character sets through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * the environment has "strange" behavior on some variants of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * Windows.  Hence, maybe the manifest parsing code local to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * launcher should never be enhanced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * Hence, future work should either:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     *     1)   Correct the local parsing code and verify that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     *          Main-Class attribute gets properly passed through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     *          all environments,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     *     2)   Remove the vestages of maintaining main_class through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     *          the environment (and remove these comments).
14518
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   507
     *
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   508
     * This method also correctly handles launching existing JavaFX
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   509
     * applications that may or may not have a Main-Class manifest entry.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     */
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   511
    mainClass = LoadMainClass(env, mode, what);
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   512
    CHECK_EXCEPTION_NULL_LEAVE(mainClass);
14518
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   513
    /*
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   514
     * In some cases when launching an application that needs a helper, e.g., a
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   515
     * JavaFX application with no main method, the mainClass will not be the
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   516
     * applications own main class but rather a helper class. To keep things
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   517
     * consistent in the UI we need to track and report the application main class.
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   518
     */
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   519
    appClass = GetApplicationClass(env);
17445
6c4e2d6b953b 8013736: [launcher] cleanup code for correctness
ksrini
parents: 14518
diff changeset
   520
    NULL_CHECK_RETURN_VALUE(appClass, -1);
39345
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   521
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   522
    /* Build platform specific argument array */
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   523
    mainArgs = CreateApplicationArgs(env, argv, argc);
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   524
    CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   525
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   526
    if (dryRun) {
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   527
        ret = 0;
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   528
        LEAVE();
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   529
    }
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   530
14518
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   531
    /*
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   532
     * PostJVMInit uses the class name as the application name for GUI purposes,
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   533
     * for example, on OSX this sets the application name in the menu bar for
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   534
     * both SWT and JavaFX. So we'll pass the actual application class here
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   535
     * instead of mainClass as that may be a launcher or helper class instead
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   536
     * of the application class.
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   537
     */
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
   538
    PostJVMInit(env, appClass, vm);
28771
2885fb2e1002 8068033: JNI exception pending in jdk/src/share/bin/java.c
ksrini
parents: 28107
diff changeset
   539
    CHECK_EXCEPTION_LEAVE(1);
39345
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   540
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   541
    /*
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   542
     * The LoadMainClass not only loads the main class, it will also ensure
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   543
     * that the main method's signature is correct, therefore further checking
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   544
     * is not required. The main method is invoked here so that extraneous java
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   545
     * stacks are not in the application stack trace.
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   546
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                                       "([Ljava/lang/String;)V");
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
   549
    CHECK_EXCEPTION_NULL_LEAVE(mainID);
21606
1984e107a4b3 8027755: Anti-delta incorrect push for 8025198
dholmes
parents: 21605
diff changeset
   550
39345
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   551
    /* Invoke main method. */
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   552
    (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
39345
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   554
    /*
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   555
     * The launcher's exit code (in the absence of calls to
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   556
     * System.exit) will be non-zero if main threw an exception.
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   557
     */
344e8211e184 8160698: java --dry-run should not cause main class be initialized
mchung
parents: 39303
diff changeset
   558
    ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
21606
1984e107a4b3 8027755: Anti-delta incorrect push for 8025198
dholmes
parents: 21605
diff changeset
   559
6005
f9e6c98d4ee3 6921472: RFE: java launcher code needs clean up
ksrini
parents: 5506
diff changeset
   560
    LEAVE();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
/*
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   564
 * Test if the given name is one of the class path options.
38753
9d4f778eda39 8152721: Java Web Start splash mechanism is not working in JDK9
mchung
parents: 36907
diff changeset
   565
 */
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   566
static jboolean
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   567
IsClassPathOption(const char* name) {
38753
9d4f778eda39 8152721: Java Web Start splash mechanism is not working in JDK9
mchung
parents: 36907
diff changeset
   568
    return JLI_StrCmp(name, "-classpath") == 0 ||
9d4f778eda39 8152721: Java Web Start splash mechanism is not working in JDK9
mchung
parents: 36907
diff changeset
   569
           JLI_StrCmp(name, "-cp") == 0 ||
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   570
           JLI_StrCmp(name, "--class-path") == 0;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   571
}
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   572
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   573
/*
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   574
 * Test if the given name is a launcher option taking the main entry point.
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   575
 */
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   576
static jboolean
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   577
IsLauncherMainOption(const char* name) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   578
    return JLI_StrCmp(name, "--module") == 0 ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   579
           JLI_StrCmp(name, "-m") == 0;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   580
}
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   581
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   582
/*
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   583
 * Test if the given name is a white-space launcher option.
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   584
 */
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   585
static jboolean
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   586
IsLauncherOption(const char* name) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   587
    return IsClassPathOption(name) ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   588
           IsLauncherMainOption(name) ||
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
   589
           JLI_StrCmp(name, "--describe-module") == 0 ||
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   590
           JLI_StrCmp(name, "-d") == 0 ||
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   591
           JLI_StrCmp(name, "--source") == 0;
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   592
}
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   593
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   594
/*
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   595
 * Test if the given name is a module-system white-space option that
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   596
 * will be passed to the VM with its corresponding long-form option
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   597
 * name and "=" delimiter.
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   598
 */
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   599
static jboolean
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   600
IsModuleOption(const char* name) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   601
    return JLI_StrCmp(name, "--module-path") == 0 ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   602
           JLI_StrCmp(name, "-p") == 0 ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   603
           JLI_StrCmp(name, "--upgrade-module-path") == 0 ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   604
           JLI_StrCmp(name, "--add-modules") == 0 ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   605
           JLI_StrCmp(name, "--limit-modules") == 0 ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   606
           JLI_StrCmp(name, "--add-exports") == 0 ||
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
   607
           JLI_StrCmp(name, "--add-opens") == 0 ||
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   608
           JLI_StrCmp(name, "--add-reads") == 0 ||
40680
01c426b7cb59 8160851: Remove old launcher module-related options
mchung
parents: 40261
diff changeset
   609
           JLI_StrCmp(name, "--patch-module") == 0;
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   610
}
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   611
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
   612
static jboolean
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
   613
IsLongFormModuleOption(const char* name) {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
   614
    return JLI_StrCCmp(name, "--module-path=") == 0 ||
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
   615
           JLI_StrCCmp(name, "--upgrade-module-path=") == 0 ||
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
   616
           JLI_StrCCmp(name, "--add-modules=") == 0 ||
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
   617
           JLI_StrCCmp(name, "--limit-modules=") == 0 ||
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
   618
           JLI_StrCCmp(name, "--add-exports=") == 0 ||
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
   619
           JLI_StrCCmp(name, "--add-reads=") == 0 ||
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
   620
           JLI_StrCCmp(name, "--patch-module=") == 0;
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
   621
}
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
   622
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   623
/*
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   624
 * Test if the given name has a white space option.
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   625
 */
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   626
jboolean
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   627
IsWhiteSpaceOption(const char* name) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   628
    return IsModuleOption(name) ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   629
           IsLauncherOption(name);
38753
9d4f778eda39 8152721: Java Web Start splash mechanism is not working in JDK9
mchung
parents: 36907
diff changeset
   630
}
9d4f778eda39 8152721: Java Web Start splash mechanism is not working in JDK9
mchung
parents: 36907
diff changeset
   631
9d4f778eda39 8152721: Java Web Start splash mechanism is not working in JDK9
mchung
parents: 36907
diff changeset
   632
/*
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   633
 * Check if it is OK to set the mode.
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   634
 * If the mode was previously set, and should not be changed,
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   635
 * a fatal error is reported.
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   636
 */
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   637
static int
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   638
checkMode(int mode, int newMode, const char *arg) {
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   639
    if (mode == LM_SOURCE) {
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   640
        JLI_ReportErrorMessage(ARG_ERROR14, arg);
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   641
        exit(1);
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   642
    }
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   643
    return newMode;
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   644
}
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   645
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   646
/*
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   647
 * Test if an arg identifies a source file.
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   648
 */
59323
ae2eb76c486d 8234821: remove unused functions from libjli
mbaesken
parents: 58280
diff changeset
   649
static jboolean IsSourceFile(const char *arg) {
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   650
    struct stat st;
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   651
    return (JLI_HasSuffix(arg, ".java") && stat(arg, &st) == 0);
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   652
}
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   653
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
   654
/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
 * Checks the command line options to find which JVM type was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
 * specified.  If no command line option was given for the JVM type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
 * the default type is used.  The environment variable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
 * JDK_ALTERNATE_VM and the command line option -XXaltjvm= are also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
 * checked as ways of specifying which JVM type to invoke.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
CheckJvmType(int *pargc, char ***argv, jboolean speculative) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    int i, argi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    int argc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    char **newArgv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    int newArgvIdx = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    int isVMType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    int jvmidx = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    char *jvmtype = getenv("JDK_ALTERNATE_VM");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    argc = *pargc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    /* To make things simpler we always copy the argv array */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    newArgv = JLI_MemAlloc((argc + 1) * sizeof(char *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    /* The program name is always present */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    newArgv[newArgvIdx++] = (*argv)[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    for (argi = 1; argi < argc; argi++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        char *arg = (*argv)[argi];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        isVMType = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        if (IsJavaArgs()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            if (arg[0] != '-') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                newArgv[newArgvIdx++] = arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        } else {
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   689
            if (IsWhiteSpaceOption(arg)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                newArgv[newArgvIdx++] = arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                argi++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                if (argi < argc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                    newArgv[newArgvIdx++] = (*argv)[argi];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            if (arg[0] != '-') break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        /* Did the user pass an explicit VM type? */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        i = KnownVMIndex(arg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        if (i >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            jvmtype = knownVMs[jvmidx = i].name + 1; /* skip the - */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            isVMType = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
            *pargc = *pargc - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        /* Did the user specify an "alternate" VM? */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        else if (JLI_StrCCmp(arg, "-XXaltjvm=") == 0 || JLI_StrCCmp(arg, "-J-XXaltjvm=") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            isVMType = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            jvmtype = arg+((arg[1]=='X')? 10 : 12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            jvmidx = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        if (!isVMType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
            newArgv[newArgvIdx++] = arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * Finish copying the arguments if we aborted the above loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * NOTE that if we aborted via "break" then we did NOT copy the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * last argument above, and in addition argi will be less than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * argc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    while (argi < argc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        newArgv[newArgvIdx++] = (*argv)[argi];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        argi++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    /* argv is null-terminated */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    newArgv[newArgvIdx] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    /* Copy back argv */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    *argv = newArgv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    *pargc = newArgvIdx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    /* use the default VM type if not specified (no alias processing) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    if (jvmtype == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
      char* result = knownVMs[0].name+1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
      JLI_TraceLauncher("Default VM: %s\n", result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
      return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    /* if using an alternate VM, no alias processing */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    if (jvmidx < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
      return jvmtype;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    /* Resolve aliases first */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
      int loopCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
      while (knownVMs[jvmidx].flag == VM_ALIASED_TO) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        int nextIdx = KnownVMIndex(knownVMs[jvmidx].alias);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        if (loopCount > knownVMsCount) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
          if (!speculative) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
   757
            JLI_ReportErrorMessage(CFG_ERROR1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
            exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
          } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
            return "ERROR";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
            /* break; */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        if (nextIdx < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
          if (!speculative) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
   767
            JLI_ReportErrorMessage(CFG_ERROR2, knownVMs[jvmidx].alias);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
          } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
            return "ERROR";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        jvmidx = nextIdx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        jvmtype = knownVMs[jvmidx].name+1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        loopCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    switch (knownVMs[jvmidx].flag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    case VM_WARN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        if (!speculative) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
   782
            JLI_ReportErrorMessage(CFG_WARN1, jvmtype, knownVMs[0].name + 1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        /* fall through */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    case VM_IGNORE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        jvmtype = knownVMs[jvmidx=0].name + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        /* fall through */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    case VM_KNOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    case VM_ERROR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        if (!speculative) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
   792
            JLI_ReportErrorMessage(CFG_ERROR3, jvmtype);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
            exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
            return "ERROR";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
    return jvmtype;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
25816
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   802
/*
45062
37ed4313c8c1 8169646: Remove launcher's -d32/-d64 option
ksrini
parents: 43498
diff changeset
   803
 * This method must be called before the VM is loaded, primarily
37ed4313c8c1 8169646: Remove launcher's -d32/-d64 option
ksrini
parents: 43498
diff changeset
   804
 * used to parse and set any VM related options or env variables.
37ed4313c8c1 8169646: Remove launcher's -d32/-d64 option
ksrini
parents: 43498
diff changeset
   805
 * This function is non-destructive leaving the argument list intact.
25816
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   806
 */
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   807
static void
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   808
SetJvmEnvironment(int argc, char **argv) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   809
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   810
    static const char*  NMT_Env_Name    = "NMT_LEVEL_";
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   811
    int i;
45062
37ed4313c8c1 8169646: Remove launcher's -d32/-d64 option
ksrini
parents: 43498
diff changeset
   812
    /* process only the launcher arguments */
25816
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   813
    for (i = 0; i < argc; i++) {
29114
a9b39a645e85 8066185: VM crashed with SIGSEGV VirtualMemoryTracker::add_reserved_region
ksrini
parents: 28771
diff changeset
   814
        char *arg = argv[i];
a9b39a645e85 8066185: VM crashed with SIGSEGV VirtualMemoryTracker::add_reserved_region
ksrini
parents: 28771
diff changeset
   815
        /*
a9b39a645e85 8066185: VM crashed with SIGSEGV VirtualMemoryTracker::add_reserved_region
ksrini
parents: 28771
diff changeset
   816
         * Since this must be a VM flag we stop processing once we see
a9b39a645e85 8066185: VM crashed with SIGSEGV VirtualMemoryTracker::add_reserved_region
ksrini
parents: 28771
diff changeset
   817
         * an argument the launcher would not have processed beyond (such
a9b39a645e85 8066185: VM crashed with SIGSEGV VirtualMemoryTracker::add_reserved_region
ksrini
parents: 28771
diff changeset
   818
         * as -version or -h), or an argument that indicates the following
a9b39a645e85 8066185: VM crashed with SIGSEGV VirtualMemoryTracker::add_reserved_region
ksrini
parents: 28771
diff changeset
   819
         * arguments are for the application (i.e. the main class name, or
a9b39a645e85 8066185: VM crashed with SIGSEGV VirtualMemoryTracker::add_reserved_region
ksrini
parents: 28771
diff changeset
   820
         * the -jar argument).
a9b39a645e85 8066185: VM crashed with SIGSEGV VirtualMemoryTracker::add_reserved_region
ksrini
parents: 28771
diff changeset
   821
         */
29373
8f41a04d1a02 8074373: NMT is not enabled if NMT option is specified after class path specifiers
ksrini
parents: 29114
diff changeset
   822
        if (i > 0) {
8f41a04d1a02 8074373: NMT is not enabled if NMT option is specified after class path specifiers
ksrini
parents: 29114
diff changeset
   823
            char *prev = argv[i - 1];
8f41a04d1a02 8074373: NMT is not enabled if NMT option is specified after class path specifiers
ksrini
parents: 29114
diff changeset
   824
            // skip non-dash arg preceded by class path specifiers
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   825
            if (*arg != '-' && IsWhiteSpaceOption(prev)) {
29373
8f41a04d1a02 8074373: NMT is not enabled if NMT option is specified after class path specifiers
ksrini
parents: 29114
diff changeset
   826
                continue;
8f41a04d1a02 8074373: NMT is not enabled if NMT option is specified after class path specifiers
ksrini
parents: 29114
diff changeset
   827
            }
8f41a04d1a02 8074373: NMT is not enabled if NMT option is specified after class path specifiers
ksrini
parents: 29114
diff changeset
   828
43325
033e4cced1dc 8170832: Add a new launcher environment variable JAVA_OPTIONS
henryjen
parents: 42993
diff changeset
   829
            if (*arg != '-' || isTerminalOpt(arg)) {
29373
8f41a04d1a02 8074373: NMT is not enabled if NMT option is specified after class path specifiers
ksrini
parents: 29114
diff changeset
   830
                return;
8f41a04d1a02 8074373: NMT is not enabled if NMT option is specified after class path specifiers
ksrini
parents: 29114
diff changeset
   831
            }
29114
a9b39a645e85 8066185: VM crashed with SIGSEGV VirtualMemoryTracker::add_reserved_region
ksrini
parents: 28771
diff changeset
   832
        }
25816
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   833
        /*
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   834
         * The following case checks for "-XX:NativeMemoryTracking=value".
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   835
         * If value is non null, an environmental variable set to this value
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   836
         * will be created to be used by the JVM.
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   837
         * The argument is passed to the JVM, which will check validity.
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   838
         * The JVM is responsible for removing the env variable.
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   839
         */
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   840
        if (JLI_StrCCmp(arg, "-XX:NativeMemoryTracking=") == 0) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   841
            int retval;
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   842
            // get what follows this parameter, include "="
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   843
            size_t pnlen = JLI_StrLen("-XX:NativeMemoryTracking=");
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   844
            if (JLI_StrLen(arg) > pnlen) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   845
                char* value = arg + pnlen;
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   846
                size_t pbuflen = pnlen + JLI_StrLen(value) + 10; // 10 max pid digits
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   847
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   848
                /*
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   849
                 * ensures that malloc successful
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   850
                 * DONT JLI_MemFree() pbuf.  JLI_PutEnv() uses system call
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   851
                 *   that could store the address.
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   852
                 */
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   853
                char * pbuf = (char*)JLI_MemAlloc(pbuflen);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   854
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   855
                JLI_Snprintf(pbuf, pbuflen, "%s%d=%s", NMT_Env_Name, JLI_GetPid(), value);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   856
                retval = JLI_PutEnv(pbuf);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   857
                if (JLI_IsTraceLauncher()) {
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   858
                    char* envName;
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   859
                    char* envBuf;
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   860
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   861
                    // ensures that malloc successful
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   862
                    envName = (char*)JLI_MemAlloc(pbuflen);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   863
                    JLI_Snprintf(envName, pbuflen, "%s%d", NMT_Env_Name, JLI_GetPid());
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   864
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   865
                    printf("TRACER_MARKER: NativeMemoryTracking: env var is %s\n",envName);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   866
                    printf("TRACER_MARKER: NativeMemoryTracking: putenv arg %s\n",pbuf);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   867
                    envBuf = getenv(envName);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   868
                    printf("TRACER_MARKER: NativeMemoryTracking: got value %s\n",envBuf);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   869
                    free(envName);
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   870
                }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   871
            }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   872
        }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   873
    }
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   874
}
2c05592cf0f2 8042469: Launcher changes for native memory tracking scalability enhancement
ksrini
parents: 25552
diff changeset
   875
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
/* copied from HotSpot function "atomll()" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
static int
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   878
parse_size(const char *s, jlong *result) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
  jlong n = 0;
29742
b73f38796859 8074840: Resolve disabled warnings for libjli and libjli_static
mikael
parents: 29373
diff changeset
   880
  int args_read = sscanf(s, JLONG_FORMAT_SPECIFIER, &n);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
  if (args_read != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
  while (*s != '\0' && *s >= '0' && *s <= '9') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    s++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
  // 4705540: illegal if more characters are found after the first non-digit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
  if (JLI_StrLen(s) > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
  switch (*s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    case 'T': case 't':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
      *result = n * GB * KB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
      return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
    case 'G': case 'g':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
      *result = n * GB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
      return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    case 'M': case 'm':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
      *result = n * MB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
      return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    case 'K': case 'k':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
      *result = n * KB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
      return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    case '\0':
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
      *result = n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
      return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
      /* Create JVM with default stack and let VM handle malformed -Xss string*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
      return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
/*
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 27938
diff changeset
   914
 * Adds a new VM option with the given name and value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
AddOption(char *str, void *info)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     * Expand options array if needed to accommodate at least one more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * VM option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    if (numOptions >= maxOptions) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        if (options == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
            maxOptions = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            options = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            JavaVMOption *tmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            maxOptions *= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
            tmp = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
            memcpy(tmp, options, numOptions * sizeof(JavaVMOption));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            JLI_MemFree(options);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            options = tmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    options[numOptions].optionString = str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
    options[numOptions++].extraInfo = info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
54543
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   939
    /*
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   940
     * -Xss is used both by the JVM and here to establish the stack size of the thread
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   941
     * created to launch the JVM. In the latter case we need to ensure we don't go
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   942
     * below the minimum stack size allowed. If -Xss is zero that tells the JVM to use
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   943
     * 'default' sizes (either from JVM or system configuration, e.g. 'ulimit -s' on linux),
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   944
     * and is not itself a small stack size that will be rejected. So we ignore -Xss0 here.
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   945
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    if (JLI_StrCCmp(str, "-Xss") == 0) {
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   947
        jlong tmp;
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   948
        if (parse_size(str + 4, &tmp)) {
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   949
            threadStackSize = tmp;
54543
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
   950
            if (threadStackSize > 0 && threadStackSize < (jlong)STACK_SIZE_MINIMUM) {
28102
0efebd8c99e2 6762191: Setting stack size to 16K causes segmentation fault
cjplummer
parents: 25859
diff changeset
   951
                threadStackSize = STACK_SIZE_MINIMUM;
0efebd8c99e2 6762191: Setting stack size to 16K causes segmentation fault
cjplummer
parents: 25859
diff changeset
   952
            }
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   953
        }
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   954
    }
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   955
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   956
    if (JLI_StrCCmp(str, "-Xmx") == 0) {
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   957
        jlong tmp;
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   958
        if (parse_size(str + 4, &tmp)) {
7810
d4730191e53c 7002386: (launcher) fix XshowSettings
ksrini
parents: 7297
diff changeset
   959
            maxHeapSize = tmp;
d4730191e53c 7002386: (launcher) fix XshowSettings
ksrini
parents: 7297
diff changeset
   960
        }
d4730191e53c 7002386: (launcher) fix XshowSettings
ksrini
parents: 7297
diff changeset
   961
    }
d4730191e53c 7002386: (launcher) fix XshowSettings
ksrini
parents: 7297
diff changeset
   962
d4730191e53c 7002386: (launcher) fix XshowSettings
ksrini
parents: 7297
diff changeset
   963
    if (JLI_StrCCmp(str, "-Xms") == 0) {
d4730191e53c 7002386: (launcher) fix XshowSettings
ksrini
parents: 7297
diff changeset
   964
        jlong tmp;
d4730191e53c 7002386: (launcher) fix XshowSettings
ksrini
parents: 7297
diff changeset
   965
        if (parse_size(str + 4, &tmp)) {
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
   966
           initialHeapSize = tmp;
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
   967
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
SetClassPath(const char *s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
    char *def;
3054
ddb6acba8b6f 6851653: (launcher) Make every java process 20 bytes smaller
martin
parents: 2624
diff changeset
   975
    const char *orig = s;
ddb6acba8b6f 6851653: (launcher) Make every java process 20 bytes smaller
martin
parents: 2624
diff changeset
   976
    static const char format[] = "-Djava.class.path=%s";
12550
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12047
diff changeset
   977
    /*
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12047
diff changeset
   978
     * usually we should not get a null pointer, but there are cases where
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12047
diff changeset
   979
     * we might just get one, in which case we simply ignore it, and let the
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12047
diff changeset
   980
     * caller deal with it
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12047
diff changeset
   981
     */
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12047
diff changeset
   982
    if (s == NULL)
482c64a6f825 7151434: java -jar -XX crashes java launcher
ksrini
parents: 12047
diff changeset
   983
        return;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
    s = JLI_WildcardExpandClasspath(s);
24504
25a78d39aaa9 8037398: integer overflow in jdk/src/share/bin/java.c
kizune
parents: 22962
diff changeset
   985
    if (sizeof(format) - 2 + JLI_StrLen(s) < JLI_StrLen(s))
25a78d39aaa9 8037398: integer overflow in jdk/src/share/bin/java.c
kizune
parents: 22962
diff changeset
   986
        // s is became corrupted after expanding wildcards
25a78d39aaa9 8037398: integer overflow in jdk/src/share/bin/java.c
kizune
parents: 22962
diff changeset
   987
        return;
3054
ddb6acba8b6f 6851653: (launcher) Make every java process 20 bytes smaller
martin
parents: 2624
diff changeset
   988
    def = JLI_MemAlloc(sizeof(format)
ddb6acba8b6f 6851653: (launcher) Make every java process 20 bytes smaller
martin
parents: 2624
diff changeset
   989
                       - 2 /* strlen("%s") */
ddb6acba8b6f 6851653: (launcher) Make every java process 20 bytes smaller
martin
parents: 2624
diff changeset
   990
                       + JLI_StrLen(s));
ddb6acba8b6f 6851653: (launcher) Make every java process 20 bytes smaller
martin
parents: 2624
diff changeset
   991
    sprintf(def, format, s);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    AddOption(def, NULL);
3054
ddb6acba8b6f 6851653: (launcher) Make every java process 20 bytes smaller
martin
parents: 2624
diff changeset
   993
    if (s != orig)
ddb6acba8b6f 6851653: (launcher) Make every java process 20 bytes smaller
martin
parents: 2624
diff changeset
   994
        JLI_MemFree((char *) s);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   995
    _have_classpath = JNI_TRUE;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   996
}
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   997
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
   998
static void
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
   999
AddLongFormOption(const char *option, const char *arg)
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1000
{
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1001
    static const char format[] = "%s=%s";
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1002
    char *def;
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1003
    size_t def_len;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1004
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1005
    def_len = JLI_StrLen(option) + 1 + JLI_StrLen(arg) + 1;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1006
    def = JLI_MemAlloc(def_len);
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1007
    JLI_Snprintf(def, def_len, format, option, arg);
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1008
    AddOption(def, NULL);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1009
}
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1010
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1011
static void
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1012
SetMainModule(const char *s)
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1013
{
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1014
    static const char format[] = "-Djdk.module.main=%s";
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1015
    char* slash = JLI_StrChr(s, '/');
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1016
    size_t s_len, def_len;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1017
    char *def;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1018
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1019
    /* value may be <module> or <module>/<mainclass> */
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1020
    if (slash == NULL) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1021
        s_len = JLI_StrLen(s);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1022
    } else {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1023
        s_len = (size_t) (slash - s);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1024
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1025
    def_len = sizeof(format)
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1026
               - 2 /* strlen("%s") */
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1027
               + s_len;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1028
    def = JLI_MemAlloc(def_len);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1029
    JLI_Snprintf(def, def_len, format, s);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1030
    AddOption(def, NULL);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1031
}
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1032
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
 * The SelectVersion() routine ensures that an appropriate version of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
 * the JRE is running.  The specification for the appropriate version
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
 * is obtained from either the manifest of a jar file (preferred) or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
 * from command line options.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
 * The routine also parses splash screen command line options and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
 * passes on their values in private environment variables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
SelectVersion(int argc, char **argv, char **main_class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
    char    *arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
    char    *operand;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
    char    *version = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
    char    *jre = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
    int     jarflag = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
    int     headlessflag = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
    int     restrict_search = -1;               /* -1 implies not known */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
    manifest_info info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    char    env_entry[MAXNAMELEN + 24] = ENV_ENTRY "=";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
    char    *splash_file_name = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
    char    *splash_jar_name = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
    char    *env_in;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    int     res;
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1057
    jboolean has_arg;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     * If the version has already been selected, set *main_class
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     * with the value passed through the environment (if any) and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     * simply return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     */
27938
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1064
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1065
    /*
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1066
     * This environmental variable can be set by mJRE capable JREs
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1067
     * [ 1.5 thru 1.8 ].  All other aspects of mJRE processing have been
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1068
     * stripped by those JREs.  This environmental variable allows 1.9+
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1069
     * JREs to be started by these mJRE capable JREs.
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1070
     * Note that mJRE directives in the jar manifest file would have been
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1071
     * ignored for a JRE started by another JRE...
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1072
     * .. skipped for JRE 1.5 and beyond.
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1073
     * .. not even checked for pre 1.5.
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1074
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
    if ((env_in = getenv(ENV_ENTRY)) != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
        if (*env_in != '\0')
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
            *main_class = JLI_StringDup(env_in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
     * Scan through the arguments for options relevant to multiple JRE
27938
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1083
     * support.  Multiple JRE support existed in JRE versions 1.5 thru 1.8.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
     *
27938
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1085
     * This capability is no longer available with JRE versions 1.9 and later.
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1086
     * These command line options are reported as errors.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
     */
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1088
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
    argc--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
    argv++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
    while ((arg = *argv) != 0 && *arg == '-') {
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1092
        has_arg = IsOptionWithArgument(argc, argv);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
        if (JLI_StrCCmp(arg, "-version:") == 0) {
27938
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1094
            JLI_ReportErrorMessage(SPC_ERROR1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
        } else if (JLI_StrCmp(arg, "-jre-restrict-search") == 0) {
27938
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1096
            JLI_ReportErrorMessage(SPC_ERROR2);
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1097
        } else if (JLI_StrCmp(arg, "-jre-no-restrict-search") == 0) {
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1098
            JLI_ReportErrorMessage(SPC_ERROR2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
            if (JLI_StrCmp(arg, "-jar") == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
                jarflag = 1;
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1102
            if (IsWhiteSpaceOption(arg)) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1103
                if (has_arg) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1104
                    argc--;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1105
                    argv++;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1106
                    arg = *argv;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1107
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
             * Checking for headless toolkit option in the some way as AWT does:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
             * "true" means true and any other value means false
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
            if (JLI_StrCmp(arg, "-Djava.awt.headless=true") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
                headlessflag = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
            } else if (JLI_StrCCmp(arg, "-Djava.awt.headless=") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
                headlessflag = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
            } else if (JLI_StrCCmp(arg, "-splash:") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
                splash_file_name = arg+8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
        argc--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
        argv++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
    if (argc <= 0) {    /* No operand? Possibly legit with -[full]version */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
        operand = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
        argc--;
27938
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1129
        operand = *argv++;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
     * If there is a jar file, read the manifest. If the jarfile can't be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
     * read, the manifest can't be read from the jar file, or the manifest
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
     * is corrupt, issue the appropriate error messages and exit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
     * Even if there isn't a jar file, construct a manifest_info structure
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
     * containing the command line information.  It's a convenient way to carry
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
     * this data around.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
    if (jarflag && operand) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
        if ((res = JLI_ParseManifest(operand, &info)) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
            if (res == -1)
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  1144
                JLI_ReportErrorMessage(JAR_ERROR2, operand);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
            else
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  1146
                JLI_ReportErrorMessage(JAR_ERROR3, operand);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
            exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
         * Command line splash screen option should have precedence
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
         * over the manifest, so the manifest data is used only if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
         * splash_file_name has not been initialized above during command
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
         * line parsing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        if (!headlessflag && !splash_file_name && info.splashscreen_image_file_name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
            splash_file_name = info.splashscreen_image_file_name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
            splash_jar_name = operand;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
        info.manifest_version = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
        info.main_class = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
        info.jre_version = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
        info.jre_restrict_search = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
     * Passing on splash screen info in environment variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
    if (splash_file_name && !headlessflag) {
55189
fdaf7287ea3a 8223271: SplashScreen is still shown if defaulting to headless on MacOS
prr
parents: 54543
diff changeset
  1171
        splash_file_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_FILE_ENV_ENTRY "=")+JLI_StrLen(splash_file_name)+1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
        JLI_StrCpy(splash_file_entry, SPLASH_FILE_ENV_ENTRY "=");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
        JLI_StrCat(splash_file_entry, splash_file_name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
        putenv(splash_file_entry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
    if (splash_jar_name && !headlessflag) {
55189
fdaf7287ea3a 8223271: SplashScreen is still shown if defaulting to headless on MacOS
prr
parents: 54543
diff changeset
  1177
        splash_jar_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_JAR_ENV_ENTRY "=")+JLI_StrLen(splash_jar_name)+1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
        JLI_StrCpy(splash_jar_entry, SPLASH_JAR_ENV_ENTRY "=");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
        JLI_StrCat(splash_jar_entry, splash_jar_name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
        putenv(splash_jar_entry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
     * "Valid" returns (other than unrecoverable errors) follow.  Set
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
     * main_class as a side-effect of this routine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
    if (info.main_class != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        *main_class = JLI_StringDup(info.main_class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
    if (info.jre_version == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
        JLI_FreeManifest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
/*
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1199
 * Test if the current argv is an option, i.e. with a leading `-`
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1200
 * and followed with an argument without a leading `-`.
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1201
 */
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1202
static jboolean
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1203
IsOptionWithArgument(int argc, char** argv) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1204
    char* option;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1205
    char* arg;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1206
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1207
    if (argc <= 1)
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1208
        return JNI_FALSE;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1209
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1210
    option = *argv;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1211
    arg = *(argv+1);
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1212
    return *option == '-' && *arg != '-';
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1213
}
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1214
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1215
/*
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1216
 * Gets the option, and its argument if the option has an argument.
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1217
 * It will update *pargc, **pargv to the next option.
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1218
 */
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1219
static int
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1220
GetOpt(int *pargc, char ***pargv, char **poption, char **pvalue) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1221
    int argc = *pargc;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1222
    char** argv = *pargv;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1223
    char* arg = *argv;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1224
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1225
    char* option = arg;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1226
    char* value = NULL;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1227
    char* equals = NULL;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1228
    int kind = LAUNCHER_OPTION;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1229
    jboolean has_arg = JNI_FALSE;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1230
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1231
    // check if this option may be a white-space option with an argument
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1232
    has_arg = IsOptionWithArgument(argc, argv);
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1233
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1234
    argv++; --argc;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1235
    if (IsLauncherOption(arg)) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1236
        if (has_arg) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1237
            value = *argv;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1238
            argv++; --argc;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1239
        }
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1240
        kind = IsLauncherMainOption(arg) ? LAUNCHER_MAIN_OPTION
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1241
                                         : LAUNCHER_OPTION_WITH_ARGUMENT;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1242
    } else if (IsModuleOption(arg)) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1243
        kind = VM_LONG_OPTION_WITH_ARGUMENT;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1244
        if (has_arg) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1245
            value = *argv;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1246
            argv++; --argc;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1247
        }
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1248
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1249
        /*
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1250
         * Support short form alias
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1251
         */
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1252
        if (JLI_StrCmp(arg, "-p") == 0) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1253
            option = "--module-path";
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1254
        }
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1255
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1256
    } else if (JLI_StrCCmp(arg, "--") == 0 && (equals = JLI_StrChr(arg, '=')) != NULL) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1257
        value = equals+1;
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1258
        if (JLI_StrCCmp(arg, "--describe-module=") == 0 ||
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1259
            JLI_StrCCmp(arg, "--module=") == 0 ||
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1260
            JLI_StrCCmp(arg, "--class-path=") == 0||
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1261
            JLI_StrCCmp(arg, "--source=") == 0) {
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1262
            kind = LAUNCHER_OPTION_WITH_ARGUMENT;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1263
        } else {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1264
            kind = VM_LONG_OPTION;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1265
        }
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1266
    }
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1267
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1268
    *pargc = argc;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1269
    *pargv = argv;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1270
    *poption = option;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1271
    *pvalue = value;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1272
    return kind;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1273
}
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1274
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1275
/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
 * Parses command line arguments.  Returns JNI_FALSE if launcher
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
 * should exit without starting vm, returns JNI_TRUE if vm needs
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1278
 * to be started to process given options.  *pret (the launcher
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
 * process return value) is set to 0 for a normal exit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
static jboolean
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1282
ParseArguments(int *pargc, char ***pargv,
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1283
               int *pmode, char **pwhat,
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1284
               int *pret, const char *jrepath)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
    int argc = *pargc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
    char **argv = *pargv;
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1288
    int mode = LM_UNKNOWN;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
    char *arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
    *pret = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
    while ((arg = *argv) != 0 && *arg == '-') {
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1294
        char *option = NULL;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1295
        char *value = NULL;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1296
        int kind = GetOpt(&argc, &argv, &option, &value);
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
  1297
        jboolean has_arg = value != NULL && JLI_StrLen(value) > 0;
42993
d761de69e27f 8172215: java launcher no longer accepts -cp "" empty string
mchung
parents: 42774
diff changeset
  1298
        jboolean has_arg_any_len = value != NULL;
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1299
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1300
/*
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1301
 * Option to set main entry point
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1302
 */
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1303
        if (JLI_StrCmp(arg, "-jar") == 0) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1304
            ARG_CHECK(argc, ARG_ERROR2, arg);
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1305
            mode = checkMode(mode, LM_JAR, arg);
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1306
        } else if (JLI_StrCmp(arg, "--module") == 0 ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1307
                   JLI_StrCCmp(arg, "--module=") == 0 ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1308
                   JLI_StrCmp(arg, "-m") == 0) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1309
            REPORT_ERROR (has_arg, ARG_ERROR5, arg);
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1310
            SetMainModule(value);
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1311
            mode = checkMode(mode, LM_MODULE, arg);
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1312
            if (has_arg) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1313
               *pwhat = value;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1314
                break;
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1315
            }
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1316
        } else if (JLI_StrCmp(arg, "--source") == 0 ||
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1317
                   JLI_StrCCmp(arg, "--source=") == 0) {
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1318
            REPORT_ERROR (has_arg, ARG_ERROR13, arg);
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1319
            mode = LM_SOURCE;
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1320
            if (has_arg) {
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1321
                const char *prop = "-Djdk.internal.javac.source=";
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1322
                size_t size = JLI_StrLen(prop) + JLI_StrLen(value) + 1;
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1323
                char *propValue = (char *)JLI_MemAlloc(size);
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1324
                JLI_Snprintf(propValue, size, "%s%s", prop, value);
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1325
                AddOption(propValue, NULL);
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1326
            }
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1327
        } else if (JLI_StrCmp(arg, "--class-path") == 0 ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1328
                   JLI_StrCCmp(arg, "--class-path=") == 0 ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1329
                   JLI_StrCmp(arg, "-classpath") == 0 ||
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1330
                   JLI_StrCmp(arg, "-cp") == 0) {
42993
d761de69e27f 8172215: java launcher no longer accepts -cp "" empty string
mchung
parents: 42774
diff changeset
  1331
            REPORT_ERROR (has_arg_any_len, ARG_ERROR1, arg);
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1332
            SetClassPath(value);
51841
f191aca8f96d 8210275: Source Launcher should fail if --source is used without a source file
jjg
parents: 50700
diff changeset
  1333
            if (mode != LM_SOURCE) {
f191aca8f96d 8210275: Source Launcher should fail if --source is used without a source file
jjg
parents: 50700
diff changeset
  1334
                mode = LM_CLASS;
f191aca8f96d 8210275: Source Launcher should fail if --source is used without a source file
jjg
parents: 50700
diff changeset
  1335
            }
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1336
        } else if (JLI_StrCmp(arg, "--list-modules") == 0) {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1337
            listModules = JNI_TRUE;
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1338
        } else if (JLI_StrCmp(arg, "--show-resolved-modules") == 0) {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1339
            showResolvedModules = JNI_TRUE;
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1340
        } else if (JLI_StrCmp(arg, "--validate-modules") == 0) {
47010
d8dd5c878ce5 8186145: tools/launcher/modules/validate/ValidateModulesTest.java fails when launched with -XX:+EnableJVMCI
mchung
parents: 46872
diff changeset
  1341
            AddOption("-Djdk.module.validation=true", NULL);
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1342
            validateModules = JNI_TRUE;
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1343
        } else if (JLI_StrCmp(arg, "--describe-module") == 0 ||
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1344
                   JLI_StrCCmp(arg, "--describe-module=") == 0 ||
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1345
                   JLI_StrCmp(arg, "-d") == 0) {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1346
            REPORT_ERROR (has_arg_any_len, ARG_ERROR12, arg);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1347
            describeModule = value;
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1348
/*
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1349
 * Parse white-space options
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1350
 */
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1351
        } else if (has_arg) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1352
            if (kind == VM_LONG_OPTION) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1353
                AddOption(option, NULL);
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1354
            } else if (kind == VM_LONG_OPTION_WITH_ARGUMENT) {
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1355
                AddLongFormOption(option, value);
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1356
            }
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1357
/*
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1358
 * Error missing argument
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1359
 */
42774
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
  1360
        } else if (!has_arg && (JLI_StrCmp(arg, "--module-path") == 0 ||
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
  1361
                                JLI_StrCmp(arg, "-p") == 0 ||
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
  1362
                                JLI_StrCmp(arg, "--upgrade-module-path") == 0)) {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
  1363
            REPORT_ERROR (has_arg, ARG_ERROR4, arg);
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
  1364
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
  1365
        } else if (!has_arg && (IsModuleOption(arg) || IsLongFormModuleOption(arg))) {
74bcf37d15d8 8168836: Minor clean up on warning/error messages on --add-exports and --add-reads
mchung
parents: 42338
diff changeset
  1366
            REPORT_ERROR (has_arg, ARG_ERROR6, arg);
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1367
/*
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1368
 * The following cases will cause the argument parsing to stop
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1369
 */
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1370
        } else if (JLI_StrCmp(arg, "-help") == 0 ||
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
                   JLI_StrCmp(arg, "-h") == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
                   JLI_StrCmp(arg, "-?") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
            printUsage = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
            return JNI_TRUE;
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1375
        } else if (JLI_StrCmp(arg, "--help") == 0) {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1376
            printUsage = JNI_TRUE;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1377
            printTo = USE_STDOUT;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1378
            return JNI_TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
        } else if (JLI_StrCmp(arg, "-version") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
            printVersion = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
            return JNI_TRUE;
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1382
        } else if (JLI_StrCmp(arg, "--version") == 0) {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1383
            printVersion = JNI_TRUE;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1384
            printTo = USE_STDOUT;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1385
            return JNI_TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
        } else if (JLI_StrCmp(arg, "-showversion") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
            showVersion = JNI_TRUE;
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1388
        } else if (JLI_StrCmp(arg, "--show-version") == 0) {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1389
            showVersion = JNI_TRUE;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1390
            printTo = USE_STDOUT;
39303
5aefc354587e 8159596: Add java --dry-run
mchung
parents: 38753
diff changeset
  1391
        } else if (JLI_StrCmp(arg, "--dry-run") == 0) {
5aefc354587e 8159596: Add java --dry-run
mchung
parents: 38753
diff changeset
  1392
            dryRun = JNI_TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
        } else if (JLI_StrCmp(arg, "-X") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
            printXUsage = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
            return JNI_TRUE;
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1396
        } else if (JLI_StrCmp(arg, "--help-extra") == 0) {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1397
            printXUsage = JNI_TRUE;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1398
            printTo = USE_STDOUT;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1399
            return JNI_TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
/*
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1401
 * The following case checks for -XshowSettings OR -XshowSetting:SUBOPT.
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1402
 * In the latter case, any SUBOPT value not recognized will default to "all"
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1403
 */
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1404
        } else if (JLI_StrCmp(arg, "-XshowSettings") == 0 ||
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1405
                   JLI_StrCCmp(arg, "-XshowSettings:") == 0) {
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1406
            showSettings = arg;
8174
89e3a22d4cd7 6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents: 7997
diff changeset
  1407
        } else if (JLI_StrCmp(arg, "-Xdiag") == 0) {
89e3a22d4cd7 6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents: 7997
diff changeset
  1408
            AddOption("-Dsun.java.launcher.diag=true", NULL);
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1409
        } else if (JLI_StrCmp(arg, "--show-module-resolution") == 0) {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1410
            AddOption("-Djdk.module.showModuleResolution=true", NULL);
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1411
/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
 * The following case provide backward compatibility with old-style
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
 * command line options.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
        } else if (JLI_StrCmp(arg, "-fullversion") == 0) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  1416
            JLI_ReportMessage("%s full version \"%s\"", _launcher_name, GetFullVersion());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
            return JNI_FALSE;
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1418
        } else if (JLI_StrCmp(arg, "--full-version") == 0) {
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1419
            JLI_ShowMessage("%s %s", _launcher_name, GetFullVersion());
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1420
            return JNI_FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
        } else if (JLI_StrCmp(arg, "-verbosegc") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
            AddOption("-verbose:gc", NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
        } else if (JLI_StrCmp(arg, "-t") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
            AddOption("-Xt", NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
        } else if (JLI_StrCmp(arg, "-tm") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
            AddOption("-Xtm", NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
        } else if (JLI_StrCmp(arg, "-debug") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
            AddOption("-Xdebug", NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
        } else if (JLI_StrCmp(arg, "-noclassgc") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
            AddOption("-Xnoclassgc", NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
        } else if (JLI_StrCmp(arg, "-Xfuture") == 0) {
55000
f11f2a4210b5 8215156: Deprecate the -Xfuture option
henryjen
parents: 54543
diff changeset
  1432
            JLI_ReportErrorMessage(ARG_DEPRECATED, "-Xfuture");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
            AddOption("-Xverify:all", NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
        } else if (JLI_StrCmp(arg, "-verify") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
            AddOption("-Xverify:all", NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
        } else if (JLI_StrCmp(arg, "-verifyremote") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
            AddOption("-Xverify:remote", NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
        } else if (JLI_StrCmp(arg, "-noverify") == 0) {
55080
ef713640430e 8224763: Update man pages to show deprecation of -Xverify:none
hseigel
parents: 55000
diff changeset
  1439
            /*
ef713640430e 8224763: Update man pages to show deprecation of -Xverify:none
hseigel
parents: 55000
diff changeset
  1440
             * Note that no 'deprecated' message is needed here because the VM
ef713640430e 8224763: Update man pages to show deprecation of -Xverify:none
hseigel
parents: 55000
diff changeset
  1441
             * issues 'deprecated' messages for -noverify and -Xverify:none.
ef713640430e 8224763: Update man pages to show deprecation of -Xverify:none
hseigel
parents: 55000
diff changeset
  1442
             */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
            AddOption("-Xverify:none", NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
        } else if (JLI_StrCCmp(arg, "-ss") == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
                   JLI_StrCCmp(arg, "-oss") == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
                   JLI_StrCCmp(arg, "-ms") == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
                   JLI_StrCCmp(arg, "-mx") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
            char *tmp = JLI_MemAlloc(JLI_StrLen(arg) + 6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
            sprintf(tmp, "-X%s", arg + 1); /* skip '-' */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
            AddOption(tmp, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
        } else if (JLI_StrCmp(arg, "-checksource") == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
                   JLI_StrCmp(arg, "-cs") == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
                   JLI_StrCmp(arg, "-noasyncgc") == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
            /* No longer supported */
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  1455
            JLI_ReportErrorMessage(ARG_WARN, arg);
27938
7f7f8bf64dd7 8058407: Remove Multiple JRE support in the Java launcher
ksrini
parents: 25859
diff changeset
  1456
        } else if (JLI_StrCCmp(arg, "-splash:") == 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
            ; /* Ignore machine independent options already handled */
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
  1458
        } else if (ProcessPlatformOption(arg)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
  1459
            ; /* Processing of platform dependent options */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
        } else {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1461
            /* java.class.path set on the command line */
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1462
            if (JLI_StrCCmp(arg, "-Djava.class.path=") == 0) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1463
                _have_classpath = JNI_TRUE;
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1464
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
            AddOption(arg, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1469
    if (*pwhat == NULL && --argc >= 0) {
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1470
        *pwhat = *argv++;
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1471
    }
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1472
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1473
    if (*pwhat == NULL) {
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1474
        /* LM_UNKNOWN okay for options that exit */
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1475
        if (!listModules && !describeModule && !validateModules) {
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1476
            *pret = 1;
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1477
        }
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1478
    } else if (mode == LM_UNKNOWN) {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1479
        /* default to LM_CLASS if -m, -jar and -cp options are
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1480
         * not specified */
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1481
        if (!_have_classpath) {
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1482
            SetClassPath(".");
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1483
        }
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1484
        mode = IsSourceFile(arg) ? LM_SOURCE : LM_CLASS;
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1485
    } else if (mode == LM_CLASS && IsSourceFile(arg)) {
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1486
        /* override LM_CLASS mode if given a source file */
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1487
        mode = LM_SOURCE;
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1488
    }
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1489
50453
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1490
    if (mode == LM_SOURCE) {
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1491
        AddOption("--add-modules=ALL-DEFAULT", NULL);
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1492
        *pwhat = SOURCE_LAUNCHER_MAIN_ENTRY;
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1493
        // adjust (argc, argv) so that the name of the source file
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1494
        // is included in the args passed to the source launcher
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1495
        // main entry class
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1496
        *pargc = argc + 1;
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1497
        *pargv = argv - 1;
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1498
    } else {
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1499
        if (argc >= 0) {
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1500
            *pargc = argc;
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1501
            *pargv = argv;
f91927a2c8d3 8201274: Launch Single-File Source-Code Programs
jjg
parents: 49440
diff changeset
  1502
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
    }
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1504
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1505
    *pmode = mode;
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1506
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
 * Initializes the Java Virtual Machine. Also frees options array when
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
 * finished.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
InitializeJVM(JavaVM **pvm, JNIEnv **penv, InvocationFunctions *ifn)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
    JavaVMInitArgs args;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
    jint r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
    memset(&args, 0, sizeof(args));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
    args.version  = JNI_VERSION_1_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
    args.nOptions = numOptions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
    args.options  = options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
    args.ignoreUnrecognized = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
    if (JLI_IsTraceLauncher()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
        int i = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
        printf("JavaVM args:\n    ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
        printf("version 0x%08lx, ", (long)args.version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
        printf("ignoreUnrecognized is %s, ",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
               args.ignoreUnrecognized ? "JNI_TRUE" : "JNI_FALSE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
        printf("nOptions is %ld\n", (long)args.nOptions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
        for (i = 0; i < numOptions; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
            printf("    option[%2d] = '%s'\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
                   i, args.options[i].optionString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
    r = ifn->CreateJavaVM(pvm, (void **)penv, &args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
    JLI_MemFree(options);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
    return r == JNI_OK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1543
static jclass helperClass = NULL;
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1544
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
  1545
jclass
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
  1546
GetLauncherHelperClass(JNIEnv *env)
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
  1547
{
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1548
    if (helperClass == NULL) {
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1549
        NULL_CHECK0(helperClass = FindBootStrapClass(env,
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1550
                "sun/launcher/LauncherHelper"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
    }
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1552
    return helperClass;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1555
static jmethodID makePlatformStringMID = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
 * Returns a new Java string object for the specified platform string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
static jstring
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
NewPlatformString(JNIEnv *env, char *s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
    int len = (int)JLI_StrLen(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
    jbyteArray ary;
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1564
    jclass cls = GetLauncherHelperClass(env);
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1565
    NULL_CHECK0(cls);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
    if (s == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
    ary = (*env)->NewByteArray(env, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
    if (ary != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
        jstring str = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
        (*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
        if (!(*env)->ExceptionOccurred(env)) {
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1574
            if (makePlatformStringMID == NULL) {
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1575
                NULL_CHECK0(makePlatformStringMID = (*env)->GetStaticMethodID(env,
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1576
                        cls, "makePlatformString", "(Z[B)Ljava/lang/String;"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
            }
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1578
            str = (*env)->CallStaticObjectMethod(env, cls,
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1579
                    makePlatformStringMID, USE_STDERR, ary);
47251
4fe50ead4783 8187442: Xcheck:jni produces various "WARNING in native method" in launcher
serb
parents: 47216
diff changeset
  1580
            CHECK_EXCEPTION_RETURN_VALUE(0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
            (*env)->DeleteLocalRef(env, ary);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
            return str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
 * Returns a new array of Java string objects for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
 * array of platform strings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
 */
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
  1592
jobjectArray
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
    jarray cls;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
    jarray ary;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
  1599
    NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
    NULL_CHECK0(ary = (*env)->NewObjectArray(env, strc, cls, 0));
40695
7996b10bce66 8081388: JNI exception pending in jdk/src/windows/bin/java_md.c
henryjen
parents: 40680
diff changeset
  1601
    CHECK_EXCEPTION_RETURN_VALUE(0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
    for (i = 0; i < strc; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
        jstring str = NewPlatformString(env, *strv++);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
        NULL_CHECK0(str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
        (*env)->SetObjectArrayElement(env, ary, i, str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
        (*env)->DeleteLocalRef(env, str);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
    return ary;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
/*
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
  1612
 * Loads a class and verifies that the main class is present and it is ok to
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
  1613
 * call it for more details refer to the java implementation.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
static jclass
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1616
LoadMainClass(JNIEnv *env, int mode, char *name)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
{
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
  1618
    jmethodID mid;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
  1619
    jstring str;
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
  1620
    jobject result;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
    jlong start, end;
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1622
    jclass cls = GetLauncherHelperClass(env);
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1623
    NULL_CHECK0(cls);
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
  1624
    if (JLI_IsTraceLauncher()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
        start = CounterGet();
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
  1626
    }
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1627
    NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls,
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1628
                "checkAndLoadMain",
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1629
                "(ZILjava/lang/String;)Ljava/lang/Class;"));
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1630
22279
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  1631
    NULL_CHECK0(str = NewPlatformString(env, name));
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  1632
    NULL_CHECK0(result = (*env)->CallStaticObjectMethod(env, cls, mid,
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  1633
                                                        USE_STDERR, mode, str));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
    if (JLI_IsTraceLauncher()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
        end   = CounterGet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
        printf("%ld micro seconds to load main class\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
               (long)(jint)Counter2Micros(end-start));
13411
224a28370893 7146424: Wildcard expansion for single entry classpath
ksrini
parents: 12550
diff changeset
  1639
        printf("----%s----\n", JLDEBUG_ENV_ENTRY);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
  1642
    return (jclass)result;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
14518
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1645
static jclass
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1646
GetApplicationClass(JNIEnv *env)
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1647
{
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1648
    jmethodID mid;
47251
4fe50ead4783 8187442: Xcheck:jni produces various "WARNING in native method" in launcher
serb
parents: 47216
diff changeset
  1649
    jclass appClass;
14518
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1650
    jclass cls = GetLauncherHelperClass(env);
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1651
    NULL_CHECK0(cls);
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1652
    NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls,
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1653
                "getApplicationClass",
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1654
                "()Ljava/lang/Class;"));
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1655
47251
4fe50ead4783 8187442: Xcheck:jni produces various "WARNING in native method" in launcher
serb
parents: 47216
diff changeset
  1656
    appClass = (*env)->CallStaticObjectMethod(env, cls, mid);
4fe50ead4783 8187442: Xcheck:jni produces various "WARNING in native method" in launcher
serb
parents: 47216
diff changeset
  1657
    CHECK_EXCEPTION_RETURN_VALUE(0);
4fe50ead4783 8187442: Xcheck:jni produces various "WARNING in native method" in launcher
serb
parents: 47216
diff changeset
  1658
    return appClass;
14518
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1659
}
f4b1adde53b3 8001533: java launcher must launch javafx applications
ksrini
parents: 13411
diff changeset
  1660
43330
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1661
static char* expandWildcardOnLongOpt(char* arg) {
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1662
    char *p, *value;
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1663
    size_t optLen, valueLen;
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1664
    p = JLI_StrChr(arg, '=');
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1665
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1666
    if (p == NULL || p[1] == '\0') {
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1667
        JLI_ReportErrorMessage(ARG_ERROR1, arg);
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1668
        exit(1);
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1669
    }
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1670
    p++;
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1671
    value = (char *) JLI_WildcardExpandClasspath(p);
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1672
    if (p == value) {
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1673
        // no wildcard
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1674
        return arg;
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1675
    }
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1676
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1677
    optLen = p - arg;
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1678
    valueLen = JLI_StrLen(value);
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1679
    p = JLI_MemAlloc(optLen + valueLen + 1);
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1680
    memcpy(p, arg, optLen);
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1681
    memcpy(p + optLen, value, valueLen);
43498
fd3e0590219e 8173758: tools/javac/Paths/wcMineField.sh failing with java.lang.ClassNotFoundException
henryjen
parents: 43330
diff changeset
  1682
    p[optLen + valueLen] = '\0';
43330
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1683
    return p;
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1684
}
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1685
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
 * For tools, convert command line args thus:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
 *   javac -cp foo:foo/"*" -J-ms32m ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
 *   java -ms32m -cp JLI_WildcardExpandClasspath(foo:foo/"*") ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
 * Takes 4 parameters, and returns the populated arguments
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***pargv)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
    int argc = *pargc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
    char **argv = *pargv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
    int nargc = argc + jargc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
    char **nargv = JLI_MemAlloc((nargc + 1) * sizeof(char *));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
    *pargc = nargc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
    *pargv = nargv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
    /* Copy the VM arguments (i.e. prefixed with -J) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
    for (i = 0; i < jargc; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
        const char *arg = jargv[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
        if (arg[0] == '-' && arg[1] == 'J') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
            *nargv++ = ((arg + 2) == NULL) ? NULL : JLI_StringDup(arg + 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
    for (i = 0; i < argc; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
        char *arg = argv[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
        if (arg[0] == '-' && arg[1] == 'J') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
            if (arg[2] == '\0') {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  1717
                JLI_ReportErrorMessage(ARG_ERROR3);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
                exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
            *nargv++ = arg + 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
    /* Copy the rest of the arguments */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
    for (i = 0; i < jargc ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
        const char *arg = jargv[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
        if (arg[0] != '-' || arg[1] != 'J') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
            *nargv++ = (arg == NULL) ? NULL : JLI_StringDup(arg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
    for (i = 0; i < argc; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
        char *arg = argv[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
        if (arg[0] == '-') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
            if (arg[1] == 'J')
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
                continue;
43330
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1736
            if (IsWildCardEnabled()) {
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1737
                if (IsClassPathOption(arg) && i < argc - 1) {
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1738
                    *nargv++ = arg;
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1739
                    *nargv++ = (char *) JLI_WildcardExpandClasspath(argv[i+1]);
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1740
                    i++;
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1741
                    continue;
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1742
                }
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1743
                if (JLI_StrCCmp(arg, "--class-path=") == 0) {
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1744
                    *nargv++ = expandWildcardOnLongOpt(arg);
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1745
                    continue;
6aa5f2938b75 8172309: classpath wildcards code does not support --class-path
henryjen
parents: 43325
diff changeset
  1746
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
        *nargv++ = arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
    *nargv = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
 * For our tools, we try to add 3 VM options:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
 *      -Denv.class.path=<envcp>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
 *      -Dapplication.home=<apphome>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
 *      -Djava.class.path=<appcp>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
 * <envcp>   is the user's setting of CLASSPATH -- for instance the user
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
 *           tells javac where to find binary classes through this environment
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
 *           variable.  Notice that users will be able to compile against our
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
 *           tools classes (sun.tools.javac.Main) only if they explicitly add
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
 *           tools.jar to CLASSPATH.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
 * <apphome> is the directory where the application is installed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
 * <appcp>   is the classpath to where our apps' classfiles are.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
AddApplicationOptions(int cpathc, const char **cpathv)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
    char *envcp, *appcp, *apphome;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
    char home[MAXPATHLEN]; /* application home */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
    char separator[] = { PATH_SEPARATOR, '\0' };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
    int size, i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
        const char *s = getenv("CLASSPATH");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
        if (s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
            s = (char *) JLI_WildcardExpandClasspath(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
            /* 40 for -Denv.class.path= */
24504
25a78d39aaa9 8037398: integer overflow in jdk/src/share/bin/java.c
kizune
parents: 22962
diff changeset
  1780
            if (JLI_StrLen(s) + 40 > JLI_StrLen(s)) { // Safeguard from overflow
25a78d39aaa9 8037398: integer overflow in jdk/src/share/bin/java.c
kizune
parents: 22962
diff changeset
  1781
                envcp = (char *)JLI_MemAlloc(JLI_StrLen(s) + 40);
25a78d39aaa9 8037398: integer overflow in jdk/src/share/bin/java.c
kizune
parents: 22962
diff changeset
  1782
                sprintf(envcp, "-Denv.class.path=%s", s);
25a78d39aaa9 8037398: integer overflow in jdk/src/share/bin/java.c
kizune
parents: 22962
diff changeset
  1783
                AddOption(envcp, NULL);
25a78d39aaa9 8037398: integer overflow in jdk/src/share/bin/java.c
kizune
parents: 22962
diff changeset
  1784
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
    if (!GetApplicationHome(home, sizeof(home))) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  1789
        JLI_ReportErrorMessage(CFG_ERROR5);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
    /* 40 for '-Dapplication.home=' */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
    apphome = (char *)JLI_MemAlloc(JLI_StrLen(home) + 40);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
    sprintf(apphome, "-Dapplication.home=%s", home);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
    AddOption(apphome, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
    /* How big is the application's classpath? */
41814
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1799
    if (cpathc > 0) {
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1800
        size = 40;                                 /* 40: "-Djava.class.path=" */
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1801
        for (i = 0; i < cpathc; i++) {
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1802
            size += (int)JLI_StrLen(home) + (int)JLI_StrLen(cpathv[i]) + 1; /* 1: separator */
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1803
        }
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1804
        appcp = (char *)JLI_MemAlloc(size + 1);
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1805
        JLI_StrCpy(appcp, "-Djava.class.path=");
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1806
        for (i = 0; i < cpathc; i++) {
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1807
            JLI_StrCat(appcp, home);                        /* c:\program files\myapp */
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1808
            JLI_StrCat(appcp, cpathv[i]);           /* \lib\myapp.jar         */
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1809
            JLI_StrCat(appcp, separator);           /* ;                      */
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1810
        }
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1811
        appcp[JLI_StrLen(appcp)-1] = '\0';  /* remove trailing path separator */
a0333150713e 8168205: Should not default class path to CWD if -cp is not specified but -m is specified
mchung
parents: 40695
diff changeset
  1812
        AddOption(appcp, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
 * inject the -Dsun.java.command pseudo property into the args structure
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
 * this pseudo property is used in the HotSpot VM to expose the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
 * Java class name and arguments to the main method to the VM. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
 * HotSpot VM uses this pseudo property to store the Java class name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
 * (or jar file name) and the arguments to the class's main method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
 * to the instrumentation memory region. The sun.java.command pseudo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
 * property is not exported by HotSpot to the Java layer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
void
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1827
SetJavaCommandLineProp(char *what, int argc, char **argv)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
    int i = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
    size_t len = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
    char* javaCommand = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
    char* dashDstr = "-Dsun.java.command=";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1835
    if (what == NULL) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
        /* unexpected, one of these should be set. just return without
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
         * setting the property
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
    /* determine the amount of memory to allocate assuming
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
     * the individual components will be space separated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
     */
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1845
    len = JLI_StrLen(what);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
    for (i = 0; i < argc; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
        len += JLI_StrLen(argv[i]) + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
    /* allocate the memory */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
    javaCommand = (char*) JLI_MemAlloc(len + JLI_StrLen(dashDstr) + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
    /* build the -D string */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
    *javaCommand = '\0';
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
    JLI_StrCat(javaCommand, dashDstr);
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  1856
    JLI_StrCat(javaCommand, what);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
    for (i = 0; i < argc; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
        /* the components of the string are space separated. In
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
         * the case of embedded white space, the relationship of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
         * the white space separated components to their true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
         * positional arguments will be ambiguous. This issue may
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
         * be addressed in a future release.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
        JLI_StrCat(javaCommand, " ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
        JLI_StrCat(javaCommand, argv[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
    AddOption(javaCommand, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
 * JVM would like to know if it's created by a standard Sun launcher, or by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1874
 * user native application, the following property indicates the former.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
 */
59323
ae2eb76c486d 8234821: remove unused functions from libjli
mbaesken
parents: 58280
diff changeset
  1876
static void SetJavaLauncherProp() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
  AddOption("-Dsun.java.launcher=SUN_STANDARD", NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1881
 * Prints the version information from the java.version and other properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1882
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
PrintJavaVersion(JNIEnv *env, jboolean extraLF)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
    jclass ver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
    jmethodID print;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
36225
6ae0eebc46e9 8150162: Move sun.misc.Version to a truly internal package
chegar
parents: 34000
diff changeset
  1889
    NULL_CHECK(ver = FindBootStrapClass(env, "java/lang/VersionProps"));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
    NULL_CHECK(print = (*env)->GetStaticMethodID(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
                                                 ver,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
                                                 (extraLF == JNI_TRUE) ? "println" : "print",
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1893
                                                 "(Z)V"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
                                                 )
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
              );
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1897
    (*env)->CallStaticVoidMethod(env, ver, print, printTo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
/*
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1901
 * Prints all the Java settings, see the java implementation for more details.
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1902
 */
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1903
static void
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1904
ShowSettings(JNIEnv *env, char *optString)
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1905
{
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1906
    jmethodID showSettingsID;
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1907
    jstring joptString;
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1908
    jclass cls = GetLauncherHelperClass(env);
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1909
    NULL_CHECK(cls);
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1910
    NULL_CHECK(showSettingsID = (*env)->GetStaticMethodID(env, cls,
41966
bac52fa6e617 8169001: Remove launcher's built-in ergonomics
ksrini
parents: 41814
diff changeset
  1911
            "showSettings", "(ZLjava/lang/String;JJJ)V"));
22279
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  1912
    NULL_CHECK(joptString = (*env)->NewStringUTF(env, optString));
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1913
    (*env)->CallStaticVoidMethod(env, cls, showSettingsID,
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1914
                                 USE_STDERR,
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1915
                                 joptString,
7810
d4730191e53c 7002386: (launcher) fix XshowSettings
ksrini
parents: 7297
diff changeset
  1916
                                 (jlong)initialHeapSize,
d4730191e53c 7002386: (launcher) fix XshowSettings
ksrini
parents: 7297
diff changeset
  1917
                                 (jlong)maxHeapSize,
41966
bac52fa6e617 8169001: Remove launcher's built-in ergonomics
ksrini
parents: 41814
diff changeset
  1918
                                 (jlong)threadStackSize);
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1919
}
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1920
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1921
/**
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1922
 * Show resolved modules
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1923
 */
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1924
static void
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1925
ShowResolvedModules(JNIEnv *env)
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1926
{
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1927
    jmethodID showResolvedModulesID;
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1928
    jclass cls = GetLauncherHelperClass(env);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1929
    NULL_CHECK(cls);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1930
    NULL_CHECK(showResolvedModulesID = (*env)->GetStaticMethodID(env, cls,
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1931
            "showResolvedModules", "()V"));
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1932
    (*env)->CallStaticVoidMethod(env, cls, showResolvedModulesID);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1933
}
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1934
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1935
/**
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1936
 * List observable modules
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1937
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1938
static void
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1939
ListModules(JNIEnv *env)
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1940
{
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1941
    jmethodID listModulesID;
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1942
    jclass cls = GetLauncherHelperClass(env);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1943
    NULL_CHECK(cls);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1944
    NULL_CHECK(listModulesID = (*env)->GetStaticMethodID(env, cls,
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1945
            "listModules", "()V"));
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1946
    (*env)->CallStaticVoidMethod(env, cls, listModulesID);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1947
}
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1948
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1949
/**
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1950
 * Describe a module
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1951
 */
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1952
static void
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1953
DescribeModule(JNIEnv *env, char *optString)
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1954
{
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1955
    jmethodID describeModuleID;
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39345
diff changeset
  1956
    jstring joptString = NULL;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1957
    jclass cls = GetLauncherHelperClass(env);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1958
    NULL_CHECK(cls);
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1959
    NULL_CHECK(describeModuleID = (*env)->GetStaticMethodID(env, cls,
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1960
            "describeModule", "(Ljava/lang/String;)V"));
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 36225
diff changeset
  1961
    NULL_CHECK(joptString = (*env)->NewStringUTF(env, optString));
45004
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1962
    (*env)->CallStaticVoidMethod(env, cls, describeModuleID, joptString);
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1963
}
ea3137042a61 8178380: Module system implementation refresh (5/2017)
alanb
parents: 43498
diff changeset
  1964
7297
906c58a8b849 6452854: Provide a flag to print the java configuration
ksrini
parents: 7028
diff changeset
  1965
/*
1323
e14a3b3536cd 6742159: (launcher) improve the java launching mechanism
ksrini
parents: 1145
diff changeset
  1966
 * Prints default usage or the Xusage message, see sun.launcher.LauncherHelper.java
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1968
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
PrintUsage(JNIEnv* env, jboolean doXUsage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
{
41966
bac52fa6e617 8169001: Remove launcher's built-in ergonomics
ksrini
parents: 41814
diff changeset
  1971
  jmethodID initHelp, vmSelect, vmSynonym, printHelp, printXUsageMessage;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
  jstring jprogname, vm1, vm2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
  int i;
8806
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1974
  jclass cls = GetLauncherHelperClass(env);
c81d4e10ffb7 7026184: (launcher) Regression: class with unicode name can't be launched by java.
ksrini
parents: 8174
diff changeset
  1975
  NULL_CHECK(cls);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
  if (doXUsage) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
    NULL_CHECK(printXUsageMessage = (*env)->GetStaticMethodID(env, cls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
                                        "printXUsageMessage", "(Z)V"));
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  1979
    (*env)->CallStaticVoidMethod(env, cls, printXUsageMessage, printTo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
  } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
    NULL_CHECK(initHelp = (*env)->GetStaticMethodID(env, cls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
                                        "initHelpMessage", "(Ljava/lang/String;)V"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
    NULL_CHECK(vmSelect = (*env)->GetStaticMethodID(env, cls, "appendVmSelectMessage",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
                                        "(Ljava/lang/String;Ljava/lang/String;)V"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
    NULL_CHECK(vmSynonym = (*env)->GetStaticMethodID(env, cls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
                                        "appendVmSynonymMessage",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
                                        "(Ljava/lang/String;Ljava/lang/String;)V"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
    NULL_CHECK(printHelp = (*env)->GetStaticMethodID(env, cls,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
                                        "printHelpMessage", "(Z)V"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
22279
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  1994
    NULL_CHECK(jprogname = (*env)->NewStringUTF(env, _program_name));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
    /* Initialize the usage message with the usual preamble */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
    (*env)->CallStaticVoidMethod(env, cls, initHelp, jprogname);
22279
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  1998
    CHECK_EXCEPTION_RETURN();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2000
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
    /* Assemble the other variant part of the usage */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
    for (i=1; i<knownVMsCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
      if (knownVMs[i].flag == VM_KNOWN) {
22279
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  2004
        NULL_CHECK(vm1 =  (*env)->NewStringUTF(env, knownVMs[i].name));
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  2005
        NULL_CHECK(vm2 =  (*env)->NewStringUTF(env, knownVMs[i].name+1));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
        (*env)->CallStaticVoidMethod(env, cls, vmSelect, vm1, vm2);
22279
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  2007
        CHECK_EXCEPTION_RETURN();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
    for (i=1; i<knownVMsCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
      if (knownVMs[i].flag == VM_ALIASED_TO) {
22279
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  2012
        NULL_CHECK(vm1 =  (*env)->NewStringUTF(env, knownVMs[i].name));
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  2013
        NULL_CHECK(vm2 =  (*env)->NewStringUTF(env, knownVMs[i].alias+1));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
        (*env)->CallStaticVoidMethod(env, cls, vmSynonym, vm1, vm2);
22279
877c94f9476b 8031494: [launcher] java launcher should check for JNI Pending exceptions.
ksrini
parents: 21606
diff changeset
  2015
        CHECK_EXCEPTION_RETURN();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2018
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2019
    /* Complete the usage message and print to stderr*/
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2020
    (*env)->CallStaticVoidMethod(env, cls, printHelp, printTo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
  return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2023
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2026
 * Read the jvm.cfg file and fill the knownJVMs[] array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2027
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
 * The functionality of the jvm.cfg file is subject to change without
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
 * notice and the mechanism will be removed in the future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2031
 * The lexical structure of the jvm.cfg file is as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2032
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
 *     jvmcfg         :=  { vmLine }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
 *     vmLine         :=  knownLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2035
 *                    |   aliasLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2036
 *                    |   warnLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
 *                    |   ignoreLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
 *                    |   errorLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
 *                    |   predicateLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2040
 *                    |   commentLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2041
 *     knownLine      :=  flag  "KNOWN"                  EOL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
 *     warnLine       :=  flag  "WARN"                   EOL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
 *     ignoreLine     :=  flag  "IGNORE"                 EOL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
 *     errorLine      :=  flag  "ERROR"                  EOL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
 *     aliasLine      :=  flag  "ALIASED_TO"       flag  EOL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
 *     predicateLine  :=  flag  "IF_SERVER_CLASS"  flag  EOL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
 *     commentLine    :=  "#" text                       EOL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
 *     flag           :=  "-" identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
 * The semantics are that when someone specifies a flag on the command line:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
 * - if the flag appears on a knownLine, then the identifier is used as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2052
 *   the name of the directory holding the JVM library (the name of the JVM).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
 * - if the flag appears as the first flag on an aliasLine, the identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2054
 *   of the second flag is used as the name of the JVM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2055
 * - if the flag appears on a warnLine, the identifier is used as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2056
 *   name of the JVM, but a warning is generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
 * - if the flag appears on an ignoreLine, the identifier is recognized as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2058
 *   name of a JVM, but the identifier is ignored and the default vm used
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
 * - if the flag appears on an errorLine, an error is generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
 * - if the flag appears as the first flag on a predicateLine, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
 *   the machine on which you are running passes the predicate indicated,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
 *   then the identifier of the second flag is used as the name of the JVM,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
 *   otherwise the identifier of the first flag is used as the name of the JVM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
 * If no flag is given on the command line, the first vmLine of the jvm.cfg
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
 * file determines the name of the JVM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
 * PredicateLines are only interpreted on first vmLine of a jvm.cfg file,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
 * since they only make sense if someone hasn't specified the name of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
 * JVM on the command line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
 * The intent of the jvm.cfg file is to allow several JVM libraries to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
 * be installed in different subdirectories of a single JRE installation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
 * for space-savings and convenience in testing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
 * The intent is explicitly not to provide a full aliasing or predicate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
 * mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
jint
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
  2077
ReadKnownVMs(const char *jvmCfgName, jboolean speculative)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2079
    FILE *jvmCfg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2080
    char line[MAXPATHLEN+20];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2081
    int cnt = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2082
    int lineno = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2083
    jlong start, end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
    int vmType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
    char *tmpPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2086
    char *altVMName = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
    char *serverClassVMName = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2088
    static char *whiteSpace = " \t";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
    if (JLI_IsTraceLauncher()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
        start = CounterGet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2093
    jvmCfg = fopen(jvmCfgName, "r");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
    if (jvmCfg == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
      if (!speculative) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  2096
        JLI_ReportErrorMessage(CFG_ERROR6, jvmCfgName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
        exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2098
      } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
    while (fgets(line, sizeof(line), jvmCfg) != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2103
        vmType = VM_UNKNOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
        lineno++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
        if (line[0] == '#')
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2106
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2107
        if (line[0] != '-') {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  2108
            JLI_ReportErrorMessage(CFG_WARN2, lineno, jvmCfgName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
        if (cnt >= knownVMsLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
            GrowKnownVMs(cnt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2113
        line[JLI_StrLen(line)-1] = '\0'; /* remove trailing newline */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2114
        tmpPtr = line + JLI_StrCSpn(line, whiteSpace);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2115
        if (*tmpPtr == 0) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  2116
            JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2117
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2118
            /* Null-terminate this string for JLI_StringDup below */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2119
            *tmpPtr++ = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
            tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
            if (*tmpPtr == 0) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  2122
                JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2123
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2124
                if (!JLI_StrCCmp(tmpPtr, "KNOWN")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2125
                    vmType = VM_KNOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2126
                } else if (!JLI_StrCCmp(tmpPtr, "ALIASED_TO")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2127
                    tmpPtr += JLI_StrCSpn(tmpPtr, whiteSpace);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
                    if (*tmpPtr != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
                        tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
                    if (*tmpPtr == 0) {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  2132
                        JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
                        /* Null terminate altVMName */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
                        altVMName = tmpPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
                        tmpPtr += JLI_StrCSpn(tmpPtr, whiteSpace);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
                        *tmpPtr = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2138
                        vmType = VM_ALIASED_TO;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2139
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2140
                } else if (!JLI_StrCCmp(tmpPtr, "WARN")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
                    vmType = VM_WARN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
                } else if (!JLI_StrCCmp(tmpPtr, "IGNORE")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
                    vmType = VM_IGNORE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
                } else if (!JLI_StrCCmp(tmpPtr, "ERROR")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
                    vmType = VM_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
                } else if (!JLI_StrCCmp(tmpPtr, "IF_SERVER_CLASS")) {
41966
bac52fa6e617 8169001: Remove launcher's built-in ergonomics
ksrini
parents: 41814
diff changeset
  2147
                    /* ignored */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
                } else {
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  2149
                    JLI_ReportErrorMessage(CFG_WARN5, lineno, &jvmCfgName[0]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
                    vmType = VM_KNOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2151
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2152
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2154
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2155
        JLI_TraceLauncher("jvm.cfg[%d] = ->%s<-\n", cnt, line);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2156
        if (vmType != VM_UNKNOWN) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2157
            knownVMs[cnt].name = JLI_StringDup(line);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2158
            knownVMs[cnt].flag = vmType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2159
            switch (vmType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2160
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2162
            case VM_ALIASED_TO:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2163
                knownVMs[cnt].alias = JLI_StringDup(altVMName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2164
                JLI_TraceLauncher("    name: %s  vmType: %s  alias: %s\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2165
                   knownVMs[cnt].name, "VM_ALIASED_TO", knownVMs[cnt].alias);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2166
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2167
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2168
            cnt++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2171
    fclose(jvmCfg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2172
    knownVMsCount = cnt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2173
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
    if (JLI_IsTraceLauncher()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
        end   = CounterGet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2176
        printf("%ld micro seconds to parse jvm.cfg\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2177
               (long)(jint)Counter2Micros(end-start));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2179
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2180
    return cnt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2181
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2182
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2183
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2184
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
GrowKnownVMs(int minimum)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2187
    struct vmdesc* newKnownVMs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2188
    int newMax;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2189
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2190
    newMax = (knownVMsLimit == 0 ? INIT_MAX_KNOWN_VMS : (2 * knownVMsLimit));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2191
    if (newMax <= minimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2192
        newMax = minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2194
    newKnownVMs = (struct vmdesc*) JLI_MemAlloc(newMax * sizeof(struct vmdesc));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2195
    if (knownVMs != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2196
        memcpy(newKnownVMs, knownVMs, knownVMsLimit * sizeof(struct vmdesc));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2198
    JLI_MemFree(knownVMs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2199
    knownVMs = newKnownVMs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2200
    knownVMsLimit = newMax;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2201
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2202
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2203
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2204
/* Returns index of VM or -1 if not found */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2205
static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2206
KnownVMIndex(const char* name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2207
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2208
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2209
    if (JLI_StrCCmp(name, "-J") == 0) name += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2210
    for (i = 0; i < knownVMsCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2211
        if (!JLI_StrCmp(name, knownVMs[i].name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2212
            return i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2215
    return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2216
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2217
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2218
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2219
FreeKnownVMs()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2220
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2221
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2222
    for (i = 0; i < knownVMsCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2223
        JLI_MemFree(knownVMs[i].name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2224
        knownVMs[i].name = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2226
    JLI_MemFree(knownVMs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2227
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2228
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2229
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2230
 * Displays the splash screen according to the jar file name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2231
 * and image file names stored in environment variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2232
 */
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
  2233
void
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2234
ShowSplashScreen()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2235
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2236
    const char *jar_name = getenv(SPLASH_JAR_ENV_ENTRY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2237
    const char *file_name = getenv(SPLASH_FILE_ENV_ENTRY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2238
    int data_size;
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2239
    void *image_data = NULL;
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2240
    float scale_factor = 1;
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2241
    char *scaled_splash_name = NULL;
36907
c3d8383e3efb 8145173: HiDPI splash screen support on Windows
rchamyal
parents: 36511
diff changeset
  2242
    jboolean isImageScaled = JNI_FALSE;
c3d8383e3efb 8145173: HiDPI splash screen support on Windows
rchamyal
parents: 36511
diff changeset
  2243
    size_t maxScaledImgNameLength = 0;
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2244
    if (file_name == NULL){
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2245
        return;
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2246
    }
55189
fdaf7287ea3a 8223271: SplashScreen is still shown if defaulting to headless on MacOS
prr
parents: 54543
diff changeset
  2247
fdaf7287ea3a 8223271: SplashScreen is still shown if defaulting to headless on MacOS
prr
parents: 54543
diff changeset
  2248
    if (!DoSplashInit()) {
fdaf7287ea3a 8223271: SplashScreen is still shown if defaulting to headless on MacOS
prr
parents: 54543
diff changeset
  2249
        goto exit;
fdaf7287ea3a 8223271: SplashScreen is still shown if defaulting to headless on MacOS
prr
parents: 54543
diff changeset
  2250
    }
fdaf7287ea3a 8223271: SplashScreen is still shown if defaulting to headless on MacOS
prr
parents: 54543
diff changeset
  2251
36907
c3d8383e3efb 8145173: HiDPI splash screen support on Windows
rchamyal
parents: 36511
diff changeset
  2252
    maxScaledImgNameLength = DoSplashGetScaledImgNameMaxPstfixLen(file_name);
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2253
36907
c3d8383e3efb 8145173: HiDPI splash screen support on Windows
rchamyal
parents: 36511
diff changeset
  2254
    scaled_splash_name = JLI_MemAlloc(
c3d8383e3efb 8145173: HiDPI splash screen support on Windows
rchamyal
parents: 36511
diff changeset
  2255
                            maxScaledImgNameLength * sizeof(char));
c3d8383e3efb 8145173: HiDPI splash screen support on Windows
rchamyal
parents: 36511
diff changeset
  2256
    isImageScaled = DoSplashGetScaledImageName(jar_name, file_name,
c3d8383e3efb 8145173: HiDPI splash screen support on Windows
rchamyal
parents: 36511
diff changeset
  2257
                            &scale_factor,
c3d8383e3efb 8145173: HiDPI splash screen support on Windows
rchamyal
parents: 36511
diff changeset
  2258
                            scaled_splash_name, maxScaledImgNameLength);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2259
    if (jar_name) {
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2260
36907
c3d8383e3efb 8145173: HiDPI splash screen support on Windows
rchamyal
parents: 36511
diff changeset
  2261
        if (isImageScaled) {
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2262
            image_data = JLI_JarUnpackFile(
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2263
                    jar_name, scaled_splash_name, &data_size);
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2264
        }
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2265
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2266
        if (!image_data) {
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2267
            scale_factor = 1;
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2268
            image_data = JLI_JarUnpackFile(
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2269
                            jar_name, file_name, &data_size);
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2270
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2271
        if (image_data) {
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2272
            DoSplashSetScaleFactor(scale_factor);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2273
            DoSplashLoadMemory(image_data, data_size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2274
            JLI_MemFree(image_data);
55189
fdaf7287ea3a 8223271: SplashScreen is still shown if defaulting to headless on MacOS
prr
parents: 54543
diff changeset
  2275
        } else {
fdaf7287ea3a 8223271: SplashScreen is still shown if defaulting to headless on MacOS
prr
parents: 54543
diff changeset
  2276
            DoSplashClose();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2277
        }
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2278
    } else {
36907
c3d8383e3efb 8145173: HiDPI splash screen support on Windows
rchamyal
parents: 36511
diff changeset
  2279
        if (isImageScaled) {
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2280
            DoSplashSetScaleFactor(scale_factor);
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2281
            DoSplashLoadFile(scaled_splash_name);
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2282
        } else {
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2283
            DoSplashLoadFile(file_name);
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2284
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2285
    }
36907
c3d8383e3efb 8145173: HiDPI splash screen support on Windows
rchamyal
parents: 36511
diff changeset
  2286
    JLI_MemFree(scaled_splash_name);
25552
96abb01815f6 8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents: 24504
diff changeset
  2287
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2288
    DoSplashSetFileJarName(file_name, jar_name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2289
55189
fdaf7287ea3a 8223271: SplashScreen is still shown if defaulting to headless on MacOS
prr
parents: 54543
diff changeset
  2290
    exit:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2291
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2292
     * Done with all command line processing and potential re-execs so
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2293
     * clean up the environment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2294
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2295
    (void)UnsetEnv(ENV_ENTRY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2296
    (void)UnsetEnv(SPLASH_FILE_ENV_ENTRY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2297
    (void)UnsetEnv(SPLASH_JAR_ENV_ENTRY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2298
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2299
    JLI_MemFree(splash_jar_entry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2300
    JLI_MemFree(splash_file_entry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2301
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2302
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2303
59323
ae2eb76c486d 8234821: remove unused functions from libjli
mbaesken
parents: 58280
diff changeset
  2304
static const char* GetFullVersion()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2305
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2306
    return _fVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2307
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2308
59323
ae2eb76c486d 8234821: remove unused functions from libjli
mbaesken
parents: 58280
diff changeset
  2309
static const char* GetProgramName()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2310
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2311
    return _program_name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2312
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2313
59323
ae2eb76c486d 8234821: remove unused functions from libjli
mbaesken
parents: 58280
diff changeset
  2314
static const char* GetLauncherName()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2315
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2316
    return _launcher_name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2317
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2318
59323
ae2eb76c486d 8234821: remove unused functions from libjli
mbaesken
parents: 58280
diff changeset
  2319
static jboolean IsJavaArgs()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2320
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2321
    return _is_java_args;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2322
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2323
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2324
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2325
IsWildCardEnabled()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2326
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2327
    return _wc_enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2328
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2329
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
  2330
int
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
  2331
ContinueInNewThread(InvocationFunctions* ifn, jlong threadStackSize,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11520
diff changeset
  2332
                    int argc, char **argv,
7997
78536cac0841 6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents: 7810
diff changeset
  2333
                    int mode, char *what, int ret)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2334
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2335
    if (threadStackSize == 0) {
54543
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2336
        /*
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2337
         * If the user hasn't specified a non-zero stack size ask the JVM for its default.
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2338
         * A returned 0 means 'use the system default' for a platform, e.g., Windows.
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2339
         * Note that HotSpot no longer supports JNI_VERSION_1_1 but it will
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2340
         * return its default stack size through the init args structure.
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2341
         */
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2342
        struct JDK1_1InitArgs args1_1;
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2343
        memset((void*)&args1_1, 0, sizeof(args1_1));
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2344
        args1_1.version = JNI_VERSION_1_1;
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2345
        ifn->GetDefaultJavaVMInitArgs(&args1_1);  /* ignore return value */
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2346
        if (args1_1.javaStackSize > 0) {
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2347
            threadStackSize = args1_1.javaStackSize;
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2348
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2349
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2350
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2351
    { /* Create a new thread to create JVM and invoke main method */
54543
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2352
        JavaMainArgs args;
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2353
        int rslt;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2354
54543
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2355
        args.argc = argc;
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2356
        args.argv = argv;
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2357
        args.mode = mode;
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2358
        args.what = what;
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2359
        args.ifn = *ifn;
21606
1984e107a4b3 8027755: Anti-delta incorrect push for 8025198
dholmes
parents: 21605
diff changeset
  2360
54543
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2361
        rslt = CallJavaMainInNewThread(threadStackSize, (void*)&args);
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2362
        /* If the caller has deemed there is an error we
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2363
         * simply return that, otherwise we return the value of
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2364
         * the callee
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2365
         */
4fc566b7a9c0 8222334: java -Xss0 triggers StackOverflowError
qpzhang
parents: 53941
diff changeset
  2366
        return (ret != 0) ? ret : rslt;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2368
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2369
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2370
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2371
DumpState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2372
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2373
    if (!JLI_IsTraceLauncher()) return ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2374
    printf("Launcher state:\n");
32267
4e96a9ee01b1 8027634: Support @argfiles for java command-line tool
henryjen
parents: 32222
diff changeset
  2375
    printf("\tFirst application arg index: %d\n", JLI_GetAppArgIndex());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2376
    printf("\tdebug:%s\n", (JLI_IsTraceLauncher() == JNI_TRUE) ? "on" : "off");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2377
    printf("\tjavargs:%s\n", (_is_java_args == JNI_TRUE) ? "on" : "off");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2378
    printf("\tprogram name:%s\n", GetProgramName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2379
    printf("\tlauncher name:%s\n", GetLauncherName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2380
    printf("\tjavaw:%s\n", (IsJavaw() == JNI_TRUE) ? "on" : "off");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2381
    printf("\tfullversion:%s\n", GetFullVersion());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2382
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2383
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2384
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2385
 * A utility procedure to always print to stderr
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2386
 */
49440
396ea30afbd5 8200178: Remove mapfiles for JDK native libraries
ihse
parents: 47251
diff changeset
  2387
JNIEXPORT void JNICALL
1145
404b11752c57 6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents: 399
diff changeset
  2388
JLI_ReportMessage(const char* fmt, ...)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2389
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2390
    va_list vl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2391
    va_start(vl, fmt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2392
    vfprintf(stderr, fmt, vl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2393
    fprintf(stderr, "\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2394
    va_end(vl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2395
}
42338
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2396
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2397
/*
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2398
 * A utility procedure to always print to stdout
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2399
 */
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2400
void
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2401
JLI_ShowMessage(const char* fmt, ...)
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2402
{
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2403
    va_list vl;
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2404
    va_start(vl, fmt);
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2405
    vfprintf(stdout, fmt, vl);
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2406
    fprintf(stdout, "\n");
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2407
    va_end(vl);
a60f280f803c 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41966
diff changeset
  2408
}