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