author | ksrini |
Thu, 03 Feb 2011 15:41:23 -0800 | |
changeset 8174 | 89e3a22d4cd7 |
parent 7997 | 78536cac0841 |
child 8806 | c81d4e10ffb7 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
6005 | 2 |
* Copyright (c) 1995, 2010, 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" |
|
55 |
||
56 |
/* |
|
57 |
* A NOTE TO DEVELOPERS: For performance reasons it is important that |
|
58 |
* the program image remain relatively small until after SelectVersion |
|
59 |
* CreateExecutionEnvironment have finished their possibly recursive |
|
60 |
* processing. Watch everything, but resist all temptations to use Java |
|
61 |
* interfaces. |
|
62 |
*/ |
|
63 |
||
64 |
static jboolean printVersion = JNI_FALSE; /* print and exit */ |
|
65 |
static jboolean showVersion = JNI_FALSE; /* print but continue */ |
|
66 |
static jboolean printUsage = JNI_FALSE; /* print and exit*/ |
|
67 |
static jboolean printXUsage = JNI_FALSE; /* print and exit*/ |
|
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
68 |
static char *showSettings = NULL; /* print but continue */ |
2 | 69 |
|
70 |
static const char *_program_name; |
|
71 |
static const char *_launcher_name; |
|
72 |
static jboolean _is_java_args = JNI_FALSE; |
|
73 |
static const char *_fVersion; |
|
74 |
static const char *_dVersion; |
|
75 |
static jboolean _wc_enabled = JNI_FALSE; |
|
76 |
static jint _ergo_policy = DEFAULT_POLICY; |
|
77 |
||
78 |
/* |
|
79 |
* Entries for splash screen environment variables. |
|
80 |
* putenv is performed in SelectVersion. We need |
|
81 |
* them in memory until UnsetEnv, so they are made static |
|
82 |
* global instead of auto local. |
|
83 |
*/ |
|
84 |
static char* splash_file_entry = NULL; |
|
85 |
static char* splash_jar_entry = NULL; |
|
86 |
||
87 |
/* |
|
88 |
* List of VM options to be specified when the VM is created. |
|
89 |
*/ |
|
90 |
static JavaVMOption *options; |
|
91 |
static int numOptions, maxOptions; |
|
92 |
||
93 |
/* |
|
94 |
* Prototypes for functions internal to launcher. |
|
95 |
*/ |
|
96 |
static void SetClassPath(const char *s); |
|
97 |
static void SelectVersion(int argc, char **argv, char **main_class); |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
98 |
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
|
99 |
int *pmode, char **pwhat, |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
100 |
int *pret, const char *jrepath); |
2 | 101 |
static jboolean InitializeJVM(JavaVM **pvm, JNIEnv **penv, |
102 |
InvocationFunctions *ifn); |
|
103 |
static jstring NewPlatformString(JNIEnv *env, char *s); |
|
104 |
static jobjectArray NewPlatformStringArray(JNIEnv *env, char **strv, int strc); |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
105 |
static jclass LoadMainClass(JNIEnv *env, int mode, char *name); |
2 | 106 |
|
107 |
static void TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***pargv); |
|
108 |
static jboolean AddApplicationOptions(int cpathc, const char **cpathv); |
|
109 |
static void SetApplicationClassPath(const char**); |
|
110 |
||
111 |
static void PrintJavaVersion(JNIEnv *env, jboolean extraLF); |
|
112 |
static void PrintUsage(JNIEnv* env, jboolean doXUsage); |
|
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
113 |
static void ShowSettings(JNIEnv* env, char *optString); |
2 | 114 |
|
115 |
static void SetPaths(int argc, char **argv); |
|
116 |
||
117 |
static void DumpState(); |
|
118 |
static jboolean RemovableOption(char *option); |
|
119 |
||
120 |
/* Maximum supported entries from jvm.cfg. */ |
|
121 |
#define INIT_MAX_KNOWN_VMS 10 |
|
122 |
||
123 |
/* Values for vmdesc.flag */ |
|
124 |
enum vmdesc_flag { |
|
125 |
VM_UNKNOWN = -1, |
|
126 |
VM_KNOWN, |
|
127 |
VM_ALIASED_TO, |
|
128 |
VM_WARN, |
|
129 |
VM_ERROR, |
|
130 |
VM_IF_SERVER_CLASS, |
|
131 |
VM_IGNORE |
|
132 |
}; |
|
133 |
||
134 |
struct vmdesc { |
|
135 |
char *name; |
|
136 |
int flag; |
|
137 |
char *alias; |
|
138 |
char *server_class; |
|
139 |
}; |
|
140 |
static struct vmdesc *knownVMs = NULL; |
|
141 |
static int knownVMsCount = 0; |
|
142 |
static int knownVMsLimit = 0; |
|
143 |
||
144 |
static void GrowKnownVMs(); |
|
145 |
static int KnownVMIndex(const char* name); |
|
146 |
static void FreeKnownVMs(); |
|
147 |
static void ShowSplashScreen(); |
|
148 |
static jboolean IsWildCardEnabled(); |
|
149 |
||
150 |
#define ARG_CHECK(n, f, a) if (n < 1) { \ |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
151 |
JLI_ReportErrorMessage(f, a); \ |
2 | 152 |
printUsage = JNI_TRUE; \ |
153 |
*pret = 1; \ |
|
154 |
return JNI_TRUE; \ |
|
155 |
} |
|
156 |
||
157 |
/* |
|
158 |
* Running Java code in primordial thread caused many problems. We will |
|
159 |
* create a new thread to invoke JVM. See 6316197 for more information. |
|
160 |
*/ |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
161 |
static jlong threadStackSize = 0; /* stack size of the new thread */ |
7810 | 162 |
static jlong maxHeapSize = 0; /* max heap size */ |
163 |
static jlong initialHeapSize = 0; /* inital heap size */ |
|
2 | 164 |
|
165 |
int JNICALL JavaMain(void * args); /* entry point */ |
|
166 |
||
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
167 |
enum LaunchMode { // cf. sun.launcher.LauncherHelper |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
168 |
LM_UNKNOWN = 0, |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
169 |
LM_CLASS, |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
170 |
LM_JAR |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
171 |
}; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
172 |
|
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
173 |
static const char *launchModeNames[] |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
174 |
= { "Unknown", "Main class", "JAR file" }; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
175 |
|
2 | 176 |
typedef struct { |
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
177 |
int argc; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
178 |
char **argv; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
179 |
int mode; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
180 |
char *what; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
181 |
InvocationFunctions ifn; |
2 | 182 |
} JavaMainArgs; |
183 |
||
184 |
/* |
|
185 |
* Entry point. |
|
186 |
*/ |
|
187 |
int |
|
188 |
JLI_Launch(int argc, char ** argv, /* main argc, argc */ |
|
189 |
int jargc, const char** jargv, /* java args */ |
|
190 |
int appclassc, const char** appclassv, /* app classpath */ |
|
191 |
const char* fullversion, /* full version defined */ |
|
192 |
const char* dotversion, /* dot version defined */ |
|
193 |
const char* pname, /* program name */ |
|
194 |
const char* lname, /* launcher name */ |
|
195 |
jboolean javaargs, /* JAVA_ARGS */ |
|
196 |
jboolean cpwildcard, /* classpath wildcard*/ |
|
197 |
jboolean javaw, /* windows-only javaw */ |
|
198 |
jint ergo /* ergonomics class policy */ |
|
199 |
) |
|
200 |
{ |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
201 |
int mode = LM_UNKNOWN; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
202 |
char *what = NULL; |
2 | 203 |
char *cpath = 0; |
204 |
char *main_class = NULL; |
|
205 |
int ret; |
|
206 |
InvocationFunctions ifn; |
|
207 |
jlong start, end; |
|
6005 | 208 |
char jvmpath[MAXPATHLEN]; |
209 |
char jrepath[MAXPATHLEN]; |
|
2 | 210 |
|
211 |
_fVersion = fullversion; |
|
212 |
_dVersion = dotversion; |
|
213 |
_launcher_name = lname; |
|
214 |
_program_name = pname; |
|
215 |
_is_java_args = javaargs; |
|
216 |
_wc_enabled = cpwildcard; |
|
217 |
_ergo_policy = ergo; |
|
218 |
||
39
560da37936db
6596475: (launcher) javaw should call InitCommonControls
ksrini
parents:
2
diff
changeset
|
219 |
InitLauncher(javaw); |
2 | 220 |
DumpState(); |
221 |
||
222 |
/* |
|
223 |
* Make sure the specified version of the JRE is running. |
|
224 |
* |
|
225 |
* There are three things to note about the SelectVersion() routine: |
|
226 |
* 1) If the version running isn't correct, this routine doesn't |
|
227 |
* return (either the correct version has been exec'd or an error |
|
228 |
* was issued). |
|
229 |
* 2) Argc and Argv in this scope are *not* altered by this routine. |
|
230 |
* It is the responsibility of subsequent code to ignore the |
|
231 |
* arguments handled by this routine. |
|
232 |
* 3) As a side-effect, the variable "main_class" is guaranteed to |
|
233 |
* be set (if it should ever be set). This isn't exactly the |
|
234 |
* poster child for structured programming, but it is a small |
|
235 |
* price to pay for not processing a jar file operand twice. |
|
236 |
* (Note: This side effect has been disabled. See comment on |
|
237 |
* bugid 5030265 below.) |
|
238 |
*/ |
|
239 |
SelectVersion(argc, argv, &main_class); |
|
240 |
||
6005 | 241 |
if (JLI_IsTraceLauncher()) { |
242 |
int i; |
|
243 |
printf("Command line args:\n"); |
|
244 |
for (i = 0; i < argc ; i++) { |
|
245 |
printf("argv[%d] = %s\n", i, argv[i]); |
|
246 |
} |
|
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7997
diff
changeset
|
247 |
AddOption("-Dsun.java.launcher.diag=true", NULL); |
6005 | 248 |
} |
2 | 249 |
|
250 |
CreateExecutionEnvironment(&argc, &argv, |
|
251 |
jrepath, sizeof(jrepath), |
|
6005 | 252 |
jvmpath, sizeof(jvmpath)); |
2 | 253 |
|
254 |
ifn.CreateJavaVM = 0; |
|
255 |
ifn.GetDefaultJavaVMInitArgs = 0; |
|
256 |
||
257 |
if (JLI_IsTraceLauncher()) { |
|
258 |
start = CounterGet(); |
|
259 |
} |
|
260 |
||
261 |
if (!LoadJavaVM(jvmpath, &ifn)) { |
|
262 |
return(6); |
|
263 |
} |
|
264 |
||
265 |
if (JLI_IsTraceLauncher()) { |
|
266 |
end = CounterGet(); |
|
267 |
} |
|
268 |
||
269 |
JLI_TraceLauncher("%ld micro seconds to LoadJavaVM\n", |
|
270 |
(long)(jint)Counter2Micros(end-start)); |
|
271 |
||
272 |
++argv; |
|
273 |
--argc; |
|
274 |
||
275 |
if (IsJavaArgs()) { |
|
276 |
/* Preprocess wrapper arguments */ |
|
277 |
TranslateApplicationArgs(jargc, jargv, &argc, &argv); |
|
278 |
if (!AddApplicationOptions(appclassc, appclassv)) { |
|
279 |
return(1); |
|
280 |
} |
|
281 |
} else { |
|
282 |
/* Set default CLASSPATH */ |
|
283 |
cpath = getenv("CLASSPATH"); |
|
284 |
if (cpath == NULL) { |
|
285 |
cpath = "."; |
|
286 |
} |
|
287 |
SetClassPath(cpath); |
|
288 |
} |
|
289 |
||
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
290 |
/* 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
|
291 |
* ParseArguments is false, the program should exit. |
2 | 292 |
*/ |
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
293 |
if (!ParseArguments(&argc, &argv, &mode, &what, &ret, jrepath)) |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
294 |
{ |
2 | 295 |
return(ret); |
296 |
} |
|
297 |
||
298 |
/* 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
|
299 |
if (mode == LM_JAR) { |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
300 |
SetClassPath(what); /* Override class path */ |
2 | 301 |
} |
302 |
||
303 |
/* 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
|
304 |
SetJavaCommandLineProp(what, argc, argv); |
2 | 305 |
|
306 |
/* Set the -Dsun.java.launcher pseudo property */ |
|
307 |
SetJavaLauncherProp(); |
|
308 |
||
309 |
/* set the -Dsun.java.launcher.* platform properties */ |
|
310 |
SetJavaLauncherPlatformProps(); |
|
311 |
||
312 |
/* Show the splash screen if needed */ |
|
313 |
ShowSplashScreen(); |
|
314 |
||
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
315 |
return ContinueInNewThread(&ifn, argc, argv, mode, what, ret); |
2 | 316 |
|
317 |
} |
|
6005 | 318 |
/* |
319 |
* Always detach the main thread so that it appears to have ended when |
|
320 |
* the application's main method exits. This will invoke the |
|
321 |
* uncaught exception handler machinery if main threw an |
|
322 |
* exception. An uncaught exception handler cannot change the |
|
323 |
* launcher's return code except by calling System.exit. |
|
324 |
* |
|
325 |
* Wait for all non-daemon threads to end, then destroy the VM. |
|
326 |
* This will actually create a trivial new Java waiter thread |
|
327 |
* named "DestroyJavaVM", but this will be seen as a different |
|
328 |
* thread from the one that executed main, even though they are |
|
329 |
* the same C thread. This allows mainThread.join() and |
|
330 |
* mainThread.isAlive() to work as expected. |
|
331 |
*/ |
|
332 |
#define LEAVE() \ |
|
333 |
if ((*vm)->DetachCurrentThread(vm) != 0) { \ |
|
334 |
JLI_ReportErrorMessage(JVM_ERROR2); \ |
|
335 |
ret = 1; \ |
|
336 |
} \ |
|
337 |
(*vm)->DestroyJavaVM(vm); \ |
|
338 |
return ret \ |
|
2 | 339 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
340 |
#define CHECK_EXCEPTION_NULL_LEAVE(e) \ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
341 |
if ((*env)->ExceptionOccurred(env)) { \ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
342 |
JLI_ReportExceptionDescription(env); \ |
6005 | 343 |
LEAVE(); \ |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
344 |
} \ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
345 |
if ((e) == NULL) { \ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
346 |
JLI_ReportErrorMessage(JNI_ERROR); \ |
6005 | 347 |
LEAVE(); \ |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
348 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
349 |
|
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
350 |
#define CHECK_EXCEPTION_LEAVE(rv) \ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
351 |
if ((*env)->ExceptionOccurred(env)) { \ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
352 |
JLI_ReportExceptionDescription(env); \ |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
353 |
ret = (rv); \ |
6005 | 354 |
LEAVE(); \ |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
355 |
} |
2 | 356 |
|
357 |
int JNICALL |
|
358 |
JavaMain(void * _args) |
|
359 |
{ |
|
360 |
JavaMainArgs *args = (JavaMainArgs *)_args; |
|
361 |
int argc = args->argc; |
|
362 |
char **argv = args->argv; |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
363 |
int mode = args->mode; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
364 |
char *what = args->what; |
2 | 365 |
InvocationFunctions ifn = args->ifn; |
366 |
||
367 |
JavaVM *vm = 0; |
|
368 |
JNIEnv *env = 0; |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
369 |
jclass mainClass = NULL; |
2 | 370 |
jmethodID mainID; |
371 |
jobjectArray mainArgs; |
|
372 |
int ret = 0; |
|
373 |
jlong start, end; |
|
374 |
||
375 |
/* Initialize the virtual machine */ |
|
376 |
start = CounterGet(); |
|
377 |
if (!InitializeJVM(&vm, &env, &ifn)) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
378 |
JLI_ReportErrorMessage(JVM_ERROR1); |
2 | 379 |
exit(1); |
380 |
} |
|
381 |
||
382 |
if (printVersion || showVersion) { |
|
383 |
PrintJavaVersion(env, showVersion); |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
384 |
CHECK_EXCEPTION_LEAVE(0); |
2 | 385 |
if (printVersion) { |
6005 | 386 |
LEAVE(); |
2 | 387 |
} |
388 |
} |
|
389 |
||
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
390 |
if (showSettings != NULL) { |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
391 |
ShowSettings(env, showSettings); |
7810 | 392 |
CHECK_EXCEPTION_LEAVE(1); |
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
393 |
} |
2 | 394 |
/* 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
|
395 |
if (printXUsage || printUsage || what == 0 || mode == LM_UNKNOWN) { |
2 | 396 |
PrintUsage(env, printXUsage); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
397 |
CHECK_EXCEPTION_LEAVE(1); |
6005 | 398 |
LEAVE(); |
2 | 399 |
} |
400 |
||
401 |
FreeKnownVMs(); /* after last possible PrintUsage() */ |
|
402 |
||
403 |
if (JLI_IsTraceLauncher()) { |
|
404 |
end = CounterGet(); |
|
405 |
JLI_TraceLauncher("%ld micro seconds to InitializeJVM\n", |
|
406 |
(long)(jint)Counter2Micros(end-start)); |
|
407 |
} |
|
408 |
||
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
409 |
/* At this stage, argc/argv have the application's arguments */ |
2 | 410 |
if (JLI_IsTraceLauncher()){ |
411 |
int i; |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
412 |
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
|
413 |
printf("App's argc is %d\n", argc); |
2 | 414 |
for (i=0; i < argc; i++) { |
415 |
printf(" argv[%2d] = '%s'\n", i, argv[i]); |
|
416 |
} |
|
417 |
} |
|
418 |
||
419 |
ret = 1; |
|
420 |
||
421 |
/* |
|
422 |
* Get the application's main class. |
|
423 |
* |
|
424 |
* See bugid 5030265. The Main-Class name has already been parsed |
|
425 |
* from the manifest, but not parsed properly for UTF-8 support. |
|
426 |
* Hence the code here ignores the value previously extracted and |
|
427 |
* uses the pre-existing code to reextract the value. This is |
|
428 |
* possibly an end of release cycle expedient. However, it has |
|
429 |
* also been discovered that passing some character sets through |
|
430 |
* the environment has "strange" behavior on some variants of |
|
431 |
* Windows. Hence, maybe the manifest parsing code local to the |
|
432 |
* launcher should never be enhanced. |
|
433 |
* |
|
434 |
* Hence, future work should either: |
|
435 |
* 1) Correct the local parsing code and verify that the |
|
436 |
* Main-Class attribute gets properly passed through |
|
437 |
* all environments, |
|
438 |
* 2) Remove the vestages of maintaining main_class through |
|
439 |
* the environment (and remove these comments). |
|
440 |
*/ |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
441 |
mainClass = LoadMainClass(env, mode, what); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
442 |
CHECK_EXCEPTION_NULL_LEAVE(mainClass); |
2 | 443 |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
444 |
/* |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
445 |
* 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
|
446 |
* that the main method's signature is correct, therefore further checking |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
447 |
* 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
|
448 |
* stacks are not in the application stack trace. |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
449 |
*/ |
2 | 450 |
mainID = (*env)->GetStaticMethodID(env, mainClass, "main", |
451 |
"([Ljava/lang/String;)V"); |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
452 |
CHECK_EXCEPTION_NULL_LEAVE(mainID); |
2 | 453 |
|
454 |
/* Build argument array */ |
|
455 |
mainArgs = NewPlatformStringArray(env, argv, argc); |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
456 |
CHECK_EXCEPTION_NULL_LEAVE(mainArgs); |
2 | 457 |
|
458 |
/* Invoke main method. */ |
|
459 |
(*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs); |
|
460 |
||
461 |
/* |
|
462 |
* The launcher's exit code (in the absence of calls to |
|
463 |
* System.exit) will be non-zero if main threw an exception. |
|
464 |
*/ |
|
465 |
ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1; |
|
6005 | 466 |
LEAVE(); |
2 | 467 |
} |
468 |
||
469 |
/* |
|
470 |
* Checks the command line options to find which JVM type was |
|
471 |
* specified. If no command line option was given for the JVM type, |
|
472 |
* the default type is used. The environment variable |
|
473 |
* JDK_ALTERNATE_VM and the command line option -XXaltjvm= are also |
|
474 |
* checked as ways of specifying which JVM type to invoke. |
|
475 |
*/ |
|
476 |
char * |
|
477 |
CheckJvmType(int *pargc, char ***argv, jboolean speculative) { |
|
478 |
int i, argi; |
|
479 |
int argc; |
|
480 |
char **newArgv; |
|
481 |
int newArgvIdx = 0; |
|
482 |
int isVMType; |
|
483 |
int jvmidx = -1; |
|
484 |
char *jvmtype = getenv("JDK_ALTERNATE_VM"); |
|
485 |
||
486 |
argc = *pargc; |
|
487 |
||
488 |
/* To make things simpler we always copy the argv array */ |
|
489 |
newArgv = JLI_MemAlloc((argc + 1) * sizeof(char *)); |
|
490 |
||
491 |
/* The program name is always present */ |
|
492 |
newArgv[newArgvIdx++] = (*argv)[0]; |
|
493 |
||
494 |
for (argi = 1; argi < argc; argi++) { |
|
495 |
char *arg = (*argv)[argi]; |
|
496 |
isVMType = 0; |
|
497 |
||
498 |
if (IsJavaArgs()) { |
|
499 |
if (arg[0] != '-') { |
|
500 |
newArgv[newArgvIdx++] = arg; |
|
501 |
continue; |
|
502 |
} |
|
503 |
} else { |
|
504 |
if (JLI_StrCmp(arg, "-classpath") == 0 || |
|
505 |
JLI_StrCmp(arg, "-cp") == 0) { |
|
506 |
newArgv[newArgvIdx++] = arg; |
|
507 |
argi++; |
|
508 |
if (argi < argc) { |
|
509 |
newArgv[newArgvIdx++] = (*argv)[argi]; |
|
510 |
} |
|
511 |
continue; |
|
512 |
} |
|
513 |
if (arg[0] != '-') break; |
|
514 |
} |
|
515 |
||
516 |
/* Did the user pass an explicit VM type? */ |
|
517 |
i = KnownVMIndex(arg); |
|
518 |
if (i >= 0) { |
|
519 |
jvmtype = knownVMs[jvmidx = i].name + 1; /* skip the - */ |
|
520 |
isVMType = 1; |
|
521 |
*pargc = *pargc - 1; |
|
522 |
} |
|
523 |
||
524 |
/* Did the user specify an "alternate" VM? */ |
|
525 |
else if (JLI_StrCCmp(arg, "-XXaltjvm=") == 0 || JLI_StrCCmp(arg, "-J-XXaltjvm=") == 0) { |
|
526 |
isVMType = 1; |
|
527 |
jvmtype = arg+((arg[1]=='X')? 10 : 12); |
|
528 |
jvmidx = -1; |
|
529 |
} |
|
530 |
||
531 |
if (!isVMType) { |
|
532 |
newArgv[newArgvIdx++] = arg; |
|
533 |
} |
|
534 |
} |
|
535 |
||
536 |
/* |
|
537 |
* Finish copying the arguments if we aborted the above loop. |
|
538 |
* NOTE that if we aborted via "break" then we did NOT copy the |
|
539 |
* last argument above, and in addition argi will be less than |
|
540 |
* argc. |
|
541 |
*/ |
|
542 |
while (argi < argc) { |
|
543 |
newArgv[newArgvIdx++] = (*argv)[argi]; |
|
544 |
argi++; |
|
545 |
} |
|
546 |
||
547 |
/* argv is null-terminated */ |
|
548 |
newArgv[newArgvIdx] = 0; |
|
549 |
||
550 |
/* Copy back argv */ |
|
551 |
*argv = newArgv; |
|
552 |
*pargc = newArgvIdx; |
|
553 |
||
554 |
/* use the default VM type if not specified (no alias processing) */ |
|
555 |
if (jvmtype == NULL) { |
|
556 |
char* result = knownVMs[0].name+1; |
|
557 |
/* Use a different VM type if we are on a server class machine? */ |
|
558 |
if ((knownVMs[0].flag == VM_IF_SERVER_CLASS) && |
|
559 |
(ServerClassMachine() == JNI_TRUE)) { |
|
560 |
result = knownVMs[0].server_class+1; |
|
561 |
} |
|
562 |
JLI_TraceLauncher("Default VM: %s\n", result); |
|
563 |
return result; |
|
564 |
} |
|
565 |
||
566 |
/* if using an alternate VM, no alias processing */ |
|
567 |
if (jvmidx < 0) |
|
568 |
return jvmtype; |
|
569 |
||
570 |
/* Resolve aliases first */ |
|
571 |
{ |
|
572 |
int loopCount = 0; |
|
573 |
while (knownVMs[jvmidx].flag == VM_ALIASED_TO) { |
|
574 |
int nextIdx = KnownVMIndex(knownVMs[jvmidx].alias); |
|
575 |
||
576 |
if (loopCount > knownVMsCount) { |
|
577 |
if (!speculative) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
578 |
JLI_ReportErrorMessage(CFG_ERROR1); |
2 | 579 |
exit(1); |
580 |
} else { |
|
581 |
return "ERROR"; |
|
582 |
/* break; */ |
|
583 |
} |
|
584 |
} |
|
585 |
||
586 |
if (nextIdx < 0) { |
|
587 |
if (!speculative) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
588 |
JLI_ReportErrorMessage(CFG_ERROR2, knownVMs[jvmidx].alias); |
2 | 589 |
exit(1); |
590 |
} else { |
|
591 |
return "ERROR"; |
|
592 |
} |
|
593 |
} |
|
594 |
jvmidx = nextIdx; |
|
595 |
jvmtype = knownVMs[jvmidx].name+1; |
|
596 |
loopCount++; |
|
597 |
} |
|
598 |
} |
|
599 |
||
600 |
switch (knownVMs[jvmidx].flag) { |
|
601 |
case VM_WARN: |
|
602 |
if (!speculative) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
603 |
JLI_ReportErrorMessage(CFG_WARN1, jvmtype, knownVMs[0].name + 1); |
2 | 604 |
} |
605 |
/* fall through */ |
|
606 |
case VM_IGNORE: |
|
607 |
jvmtype = knownVMs[jvmidx=0].name + 1; |
|
608 |
/* fall through */ |
|
609 |
case VM_KNOWN: |
|
610 |
break; |
|
611 |
case VM_ERROR: |
|
612 |
if (!speculative) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
613 |
JLI_ReportErrorMessage(CFG_ERROR3, jvmtype); |
2 | 614 |
exit(1); |
615 |
} else { |
|
616 |
return "ERROR"; |
|
617 |
} |
|
618 |
} |
|
619 |
||
620 |
return jvmtype; |
|
621 |
} |
|
622 |
||
623 |
/* copied from HotSpot function "atomll()" */ |
|
624 |
static int |
|
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
625 |
parse_size(const char *s, jlong *result) { |
2 | 626 |
jlong n = 0; |
627 |
int args_read = sscanf(s, jlong_format_specifier(), &n); |
|
628 |
if (args_read != 1) { |
|
629 |
return 0; |
|
630 |
} |
|
631 |
while (*s != '\0' && *s >= '0' && *s <= '9') { |
|
632 |
s++; |
|
633 |
} |
|
634 |
// 4705540: illegal if more characters are found after the first non-digit |
|
635 |
if (JLI_StrLen(s) > 1) { |
|
636 |
return 0; |
|
637 |
} |
|
638 |
switch (*s) { |
|
639 |
case 'T': case 't': |
|
640 |
*result = n * GB * KB; |
|
641 |
return 1; |
|
642 |
case 'G': case 'g': |
|
643 |
*result = n * GB; |
|
644 |
return 1; |
|
645 |
case 'M': case 'm': |
|
646 |
*result = n * MB; |
|
647 |
return 1; |
|
648 |
case 'K': case 'k': |
|
649 |
*result = n * KB; |
|
650 |
return 1; |
|
651 |
case '\0': |
|
652 |
*result = n; |
|
653 |
return 1; |
|
654 |
default: |
|
655 |
/* Create JVM with default stack and let VM handle malformed -Xss string*/ |
|
656 |
return 0; |
|
657 |
} |
|
658 |
} |
|
659 |
||
660 |
/* |
|
661 |
* Adds a new VM option with the given given name and value. |
|
662 |
*/ |
|
663 |
void |
|
664 |
AddOption(char *str, void *info) |
|
665 |
{ |
|
666 |
/* |
|
667 |
* Expand options array if needed to accommodate at least one more |
|
668 |
* VM option. |
|
669 |
*/ |
|
670 |
if (numOptions >= maxOptions) { |
|
671 |
if (options == 0) { |
|
672 |
maxOptions = 4; |
|
673 |
options = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption)); |
|
674 |
} else { |
|
675 |
JavaVMOption *tmp; |
|
676 |
maxOptions *= 2; |
|
677 |
tmp = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption)); |
|
678 |
memcpy(tmp, options, numOptions * sizeof(JavaVMOption)); |
|
679 |
JLI_MemFree(options); |
|
680 |
options = tmp; |
|
681 |
} |
|
682 |
} |
|
683 |
options[numOptions].optionString = str; |
|
684 |
options[numOptions++].extraInfo = info; |
|
685 |
||
686 |
if (JLI_StrCCmp(str, "-Xss") == 0) { |
|
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
687 |
jlong tmp; |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
688 |
if (parse_size(str + 4, &tmp)) { |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
689 |
threadStackSize = tmp; |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
690 |
} |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
691 |
} |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
692 |
|
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
693 |
if (JLI_StrCCmp(str, "-Xmx") == 0) { |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
694 |
jlong tmp; |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
695 |
if (parse_size(str + 4, &tmp)) { |
7810 | 696 |
maxHeapSize = tmp; |
697 |
} |
|
698 |
} |
|
699 |
||
700 |
if (JLI_StrCCmp(str, "-Xms") == 0) { |
|
701 |
jlong tmp; |
|
702 |
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
|
703 |
initialHeapSize = tmp; |
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
704 |
} |
2 | 705 |
} |
706 |
} |
|
707 |
||
708 |
static void |
|
709 |
SetClassPath(const char *s) |
|
710 |
{ |
|
711 |
char *def; |
|
3054
ddb6acba8b6f
6851653: (launcher) Make every java process 20 bytes smaller
martin
parents:
2624
diff
changeset
|
712 |
const char *orig = s; |
ddb6acba8b6f
6851653: (launcher) Make every java process 20 bytes smaller
martin
parents:
2624
diff
changeset
|
713 |
static const char format[] = "-Djava.class.path=%s"; |
2 | 714 |
s = JLI_WildcardExpandClasspath(s); |
3054
ddb6acba8b6f
6851653: (launcher) Make every java process 20 bytes smaller
martin
parents:
2624
diff
changeset
|
715 |
def = JLI_MemAlloc(sizeof(format) |
ddb6acba8b6f
6851653: (launcher) Make every java process 20 bytes smaller
martin
parents:
2624
diff
changeset
|
716 |
- 2 /* strlen("%s") */ |
ddb6acba8b6f
6851653: (launcher) Make every java process 20 bytes smaller
martin
parents:
2624
diff
changeset
|
717 |
+ JLI_StrLen(s)); |
ddb6acba8b6f
6851653: (launcher) Make every java process 20 bytes smaller
martin
parents:
2624
diff
changeset
|
718 |
sprintf(def, format, s); |
2 | 719 |
AddOption(def, NULL); |
3054
ddb6acba8b6f
6851653: (launcher) Make every java process 20 bytes smaller
martin
parents:
2624
diff
changeset
|
720 |
if (s != orig) |
ddb6acba8b6f
6851653: (launcher) Make every java process 20 bytes smaller
martin
parents:
2624
diff
changeset
|
721 |
JLI_MemFree((char *) s); |
2 | 722 |
} |
723 |
||
724 |
/* |
|
725 |
* The SelectVersion() routine ensures that an appropriate version of |
|
726 |
* the JRE is running. The specification for the appropriate version |
|
727 |
* is obtained from either the manifest of a jar file (preferred) or |
|
728 |
* from command line options. |
|
729 |
* The routine also parses splash screen command line options and |
|
730 |
* passes on their values in private environment variables. |
|
731 |
*/ |
|
732 |
static void |
|
733 |
SelectVersion(int argc, char **argv, char **main_class) |
|
734 |
{ |
|
735 |
char *arg; |
|
736 |
char **new_argv; |
|
737 |
char **new_argp; |
|
738 |
char *operand; |
|
739 |
char *version = NULL; |
|
740 |
char *jre = NULL; |
|
741 |
int jarflag = 0; |
|
742 |
int headlessflag = 0; |
|
743 |
int restrict_search = -1; /* -1 implies not known */ |
|
744 |
manifest_info info; |
|
745 |
char env_entry[MAXNAMELEN + 24] = ENV_ENTRY "="; |
|
746 |
char *splash_file_name = NULL; |
|
747 |
char *splash_jar_name = NULL; |
|
748 |
char *env_in; |
|
749 |
int res; |
|
750 |
||
751 |
/* |
|
752 |
* If the version has already been selected, set *main_class |
|
753 |
* with the value passed through the environment (if any) and |
|
754 |
* simply return. |
|
755 |
*/ |
|
756 |
if ((env_in = getenv(ENV_ENTRY)) != NULL) { |
|
757 |
if (*env_in != '\0') |
|
758 |
*main_class = JLI_StringDup(env_in); |
|
759 |
return; |
|
760 |
} |
|
761 |
||
762 |
/* |
|
763 |
* Scan through the arguments for options relevant to multiple JRE |
|
764 |
* support. For reference, the command line syntax is defined as: |
|
765 |
* |
|
766 |
* SYNOPSIS |
|
767 |
* java [options] class [argument...] |
|
768 |
* |
|
769 |
* java [options] -jar file.jar [argument...] |
|
770 |
* |
|
771 |
* As the scan is performed, make a copy of the argument list with |
|
772 |
* the version specification options (new to 1.5) removed, so that |
|
773 |
* a version less than 1.5 can be exec'd. |
|
774 |
* |
|
775 |
* Note that due to the syntax of the native Windows interface |
|
776 |
* CreateProcess(), processing similar to the following exists in |
|
777 |
* the Windows platform specific routine ExecJRE (in java_md.c). |
|
778 |
* Changes here should be reproduced there. |
|
779 |
*/ |
|
780 |
new_argv = JLI_MemAlloc((argc + 1) * sizeof(char*)); |
|
781 |
new_argv[0] = argv[0]; |
|
782 |
new_argp = &new_argv[1]; |
|
783 |
argc--; |
|
784 |
argv++; |
|
785 |
while ((arg = *argv) != 0 && *arg == '-') { |
|
786 |
if (JLI_StrCCmp(arg, "-version:") == 0) { |
|
787 |
version = arg + 9; |
|
788 |
} else if (JLI_StrCmp(arg, "-jre-restrict-search") == 0) { |
|
789 |
restrict_search = 1; |
|
790 |
} else if (JLI_StrCmp(arg, "-no-jre-restrict-search") == 0) { |
|
791 |
restrict_search = 0; |
|
792 |
} else { |
|
793 |
if (JLI_StrCmp(arg, "-jar") == 0) |
|
794 |
jarflag = 1; |
|
795 |
/* deal with "unfortunate" classpath syntax */ |
|
796 |
if ((JLI_StrCmp(arg, "-classpath") == 0 || JLI_StrCmp(arg, "-cp") == 0) && |
|
797 |
(argc >= 2)) { |
|
798 |
*new_argp++ = arg; |
|
799 |
argc--; |
|
800 |
argv++; |
|
801 |
arg = *argv; |
|
802 |
} |
|
803 |
||
804 |
/* |
|
805 |
* Checking for headless toolkit option in the some way as AWT does: |
|
806 |
* "true" means true and any other value means false |
|
807 |
*/ |
|
808 |
if (JLI_StrCmp(arg, "-Djava.awt.headless=true") == 0) { |
|
809 |
headlessflag = 1; |
|
810 |
} else if (JLI_StrCCmp(arg, "-Djava.awt.headless=") == 0) { |
|
811 |
headlessflag = 0; |
|
812 |
} else if (JLI_StrCCmp(arg, "-splash:") == 0) { |
|
813 |
splash_file_name = arg+8; |
|
814 |
} |
|
815 |
*new_argp++ = arg; |
|
816 |
} |
|
817 |
argc--; |
|
818 |
argv++; |
|
819 |
} |
|
820 |
if (argc <= 0) { /* No operand? Possibly legit with -[full]version */ |
|
821 |
operand = NULL; |
|
822 |
} else { |
|
823 |
argc--; |
|
824 |
*new_argp++ = operand = *argv++; |
|
825 |
} |
|
826 |
while (argc-- > 0) /* Copy over [argument...] */ |
|
827 |
*new_argp++ = *argv++; |
|
828 |
*new_argp = NULL; |
|
829 |
||
830 |
/* |
|
831 |
* If there is a jar file, read the manifest. If the jarfile can't be |
|
832 |
* read, the manifest can't be read from the jar file, or the manifest |
|
833 |
* is corrupt, issue the appropriate error messages and exit. |
|
834 |
* |
|
835 |
* Even if there isn't a jar file, construct a manifest_info structure |
|
836 |
* containing the command line information. It's a convenient way to carry |
|
837 |
* this data around. |
|
838 |
*/ |
|
839 |
if (jarflag && operand) { |
|
840 |
if ((res = JLI_ParseManifest(operand, &info)) != 0) { |
|
841 |
if (res == -1) |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
842 |
JLI_ReportErrorMessage(JAR_ERROR2, operand); |
2 | 843 |
else |
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
844 |
JLI_ReportErrorMessage(JAR_ERROR3, operand); |
2 | 845 |
exit(1); |
846 |
} |
|
847 |
||
848 |
/* |
|
849 |
* Command line splash screen option should have precedence |
|
850 |
* over the manifest, so the manifest data is used only if |
|
851 |
* splash_file_name has not been initialized above during command |
|
852 |
* line parsing |
|
853 |
*/ |
|
854 |
if (!headlessflag && !splash_file_name && info.splashscreen_image_file_name) { |
|
855 |
splash_file_name = info.splashscreen_image_file_name; |
|
856 |
splash_jar_name = operand; |
|
857 |
} |
|
858 |
} else { |
|
859 |
info.manifest_version = NULL; |
|
860 |
info.main_class = NULL; |
|
861 |
info.jre_version = NULL; |
|
862 |
info.jre_restrict_search = 0; |
|
863 |
} |
|
864 |
||
865 |
/* |
|
866 |
* Passing on splash screen info in environment variables |
|
867 |
*/ |
|
868 |
if (splash_file_name && !headlessflag) { |
|
869 |
char* splash_file_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_FILE_ENV_ENTRY "=")+JLI_StrLen(splash_file_name)+1); |
|
870 |
JLI_StrCpy(splash_file_entry, SPLASH_FILE_ENV_ENTRY "="); |
|
871 |
JLI_StrCat(splash_file_entry, splash_file_name); |
|
872 |
putenv(splash_file_entry); |
|
873 |
} |
|
874 |
if (splash_jar_name && !headlessflag) { |
|
875 |
char* splash_jar_entry = JLI_MemAlloc(JLI_StrLen(SPLASH_JAR_ENV_ENTRY "=")+JLI_StrLen(splash_jar_name)+1); |
|
876 |
JLI_StrCpy(splash_jar_entry, SPLASH_JAR_ENV_ENTRY "="); |
|
877 |
JLI_StrCat(splash_jar_entry, splash_jar_name); |
|
878 |
putenv(splash_jar_entry); |
|
879 |
} |
|
880 |
||
881 |
/* |
|
882 |
* The JRE-Version and JRE-Restrict-Search values (if any) from the |
|
883 |
* manifest are overwritten by any specified on the command line. |
|
884 |
*/ |
|
885 |
if (version != NULL) |
|
886 |
info.jre_version = version; |
|
887 |
if (restrict_search != -1) |
|
888 |
info.jre_restrict_search = restrict_search; |
|
889 |
||
890 |
/* |
|
891 |
* "Valid" returns (other than unrecoverable errors) follow. Set |
|
892 |
* main_class as a side-effect of this routine. |
|
893 |
*/ |
|
894 |
if (info.main_class != NULL) |
|
895 |
*main_class = JLI_StringDup(info.main_class); |
|
896 |
||
897 |
/* |
|
898 |
* If no version selection information is found either on the command |
|
899 |
* line or in the manifest, simply return. |
|
900 |
*/ |
|
901 |
if (info.jre_version == NULL) { |
|
902 |
JLI_FreeManifest(); |
|
903 |
JLI_MemFree(new_argv); |
|
904 |
return; |
|
905 |
} |
|
906 |
||
907 |
/* |
|
908 |
* Check for correct syntax of the version specification (JSR 56). |
|
909 |
*/ |
|
910 |
if (!JLI_ValidVersionString(info.jre_version)) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
911 |
JLI_ReportErrorMessage(SPC_ERROR1, info.jre_version); |
2 | 912 |
exit(1); |
913 |
} |
|
914 |
||
915 |
/* |
|
916 |
* Find the appropriate JVM on the system. Just to be as forgiving as |
|
917 |
* possible, if the standard algorithms don't locate an appropriate |
|
918 |
* jre, check to see if the one running will satisfy the requirements. |
|
919 |
* This can happen on systems which haven't been set-up for multiple |
|
920 |
* JRE support. |
|
921 |
*/ |
|
922 |
jre = LocateJRE(&info); |
|
923 |
JLI_TraceLauncher("JRE-Version = %s, JRE-Restrict-Search = %s Selected = %s\n", |
|
924 |
(info.jre_version?info.jre_version:"null"), |
|
925 |
(info.jre_restrict_search?"true":"false"), (jre?jre:"null")); |
|
926 |
||
927 |
if (jre == NULL) { |
|
928 |
if (JLI_AcceptableRelease(GetFullVersion(), info.jre_version)) { |
|
929 |
JLI_FreeManifest(); |
|
930 |
JLI_MemFree(new_argv); |
|
931 |
return; |
|
932 |
} else { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
933 |
JLI_ReportErrorMessage(CFG_ERROR4, info.jre_version); |
2 | 934 |
exit(1); |
935 |
} |
|
936 |
} |
|
937 |
||
938 |
/* |
|
939 |
* If I'm not the chosen one, exec the chosen one. Returning from |
|
940 |
* ExecJRE indicates that I am indeed the chosen one. |
|
941 |
* |
|
942 |
* The private environment variable _JAVA_VERSION_SET is used to |
|
943 |
* prevent the chosen one from re-reading the manifest file and |
|
944 |
* using the values found within to override the (potential) command |
|
945 |
* line flags stripped from argv (because the target may not |
|
946 |
* understand them). Passing the MainClass value is an optimization |
|
947 |
* to avoid locating, expanding and parsing the manifest extra |
|
948 |
* times. |
|
949 |
*/ |
|
2598
6f980e1d6e31
6733959: Insufficient checks for "Main-Class" manifest entry in JAR files
ksrini
parents:
399
diff
changeset
|
950 |
if (info.main_class != NULL) { |
6f980e1d6e31
6733959: Insufficient checks for "Main-Class" manifest entry in JAR files
ksrini
parents:
399
diff
changeset
|
951 |
if (JLI_StrLen(info.main_class) <= MAXNAMELEN) { |
6f980e1d6e31
6733959: Insufficient checks for "Main-Class" manifest entry in JAR files
ksrini
parents:
399
diff
changeset
|
952 |
(void)JLI_StrCat(env_entry, info.main_class); |
6f980e1d6e31
6733959: Insufficient checks for "Main-Class" manifest entry in JAR files
ksrini
parents:
399
diff
changeset
|
953 |
} else { |
2624 | 954 |
JLI_ReportErrorMessage(CLS_ERROR5, MAXNAMELEN); |
2598
6f980e1d6e31
6733959: Insufficient checks for "Main-Class" manifest entry in JAR files
ksrini
parents:
399
diff
changeset
|
955 |
exit(1); |
6f980e1d6e31
6733959: Insufficient checks for "Main-Class" manifest entry in JAR files
ksrini
parents:
399
diff
changeset
|
956 |
} |
6f980e1d6e31
6733959: Insufficient checks for "Main-Class" manifest entry in JAR files
ksrini
parents:
399
diff
changeset
|
957 |
} |
2 | 958 |
(void)putenv(env_entry); |
959 |
ExecJRE(jre, new_argv); |
|
960 |
JLI_FreeManifest(); |
|
961 |
JLI_MemFree(new_argv); |
|
962 |
return; |
|
963 |
} |
|
964 |
||
965 |
/* |
|
966 |
* Parses command line arguments. Returns JNI_FALSE if launcher |
|
967 |
* 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
|
968 |
* to be started to process given options. *pret (the launcher |
2 | 969 |
* process return value) is set to 0 for a normal exit. |
970 |
*/ |
|
971 |
static jboolean |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
972 |
ParseArguments(int *pargc, char ***pargv, |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
973 |
int *pmode, char **pwhat, |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
974 |
int *pret, const char *jrepath) |
2 | 975 |
{ |
976 |
int argc = *pargc; |
|
977 |
char **argv = *pargv; |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
978 |
int mode = LM_UNKNOWN; |
2 | 979 |
char *arg; |
980 |
||
981 |
*pret = 0; |
|
982 |
||
983 |
while ((arg = *argv) != 0 && *arg == '-') { |
|
984 |
argv++; --argc; |
|
985 |
if (JLI_StrCmp(arg, "-classpath") == 0 || JLI_StrCmp(arg, "-cp") == 0) { |
|
986 |
ARG_CHECK (argc, ARG_ERROR1, arg); |
|
987 |
SetClassPath(*argv); |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
988 |
mode = LM_CLASS; |
2 | 989 |
argv++; --argc; |
990 |
} else if (JLI_StrCmp(arg, "-jar") == 0) { |
|
991 |
ARG_CHECK (argc, ARG_ERROR2, arg); |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
992 |
mode = LM_JAR; |
2 | 993 |
} else if (JLI_StrCmp(arg, "-help") == 0 || |
994 |
JLI_StrCmp(arg, "-h") == 0 || |
|
995 |
JLI_StrCmp(arg, "-?") == 0) { |
|
996 |
printUsage = JNI_TRUE; |
|
997 |
return JNI_TRUE; |
|
998 |
} else if (JLI_StrCmp(arg, "-version") == 0) { |
|
999 |
printVersion = JNI_TRUE; |
|
1000 |
return JNI_TRUE; |
|
1001 |
} else if (JLI_StrCmp(arg, "-showversion") == 0) { |
|
1002 |
showVersion = JNI_TRUE; |
|
1003 |
} else if (JLI_StrCmp(arg, "-X") == 0) { |
|
1004 |
printXUsage = JNI_TRUE; |
|
1005 |
return JNI_TRUE; |
|
1006 |
/* |
|
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1007 |
* The following case checks for -XshowSettings OR -XshowSetting:SUBOPT. |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1008 |
* 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
|
1009 |
*/ |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1010 |
} else if (JLI_StrCmp(arg, "-XshowSettings") == 0 || |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1011 |
JLI_StrCCmp(arg, "-XshowSettings:") == 0) { |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1012 |
showSettings = arg; |
8174
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7997
diff
changeset
|
1013 |
} else if (JLI_StrCmp(arg, "-Xdiag") == 0) { |
89e3a22d4cd7
6968053: (launcher) hide exceptions under certain launcher failures
ksrini
parents:
7997
diff
changeset
|
1014 |
AddOption("-Dsun.java.launcher.diag=true", NULL); |
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1015 |
/* |
2 | 1016 |
* The following case provide backward compatibility with old-style |
1017 |
* command line options. |
|
1018 |
*/ |
|
1019 |
} else if (JLI_StrCmp(arg, "-fullversion") == 0) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1020 |
JLI_ReportMessage("%s full version \"%s\"", _launcher_name, GetFullVersion()); |
2 | 1021 |
return JNI_FALSE; |
1022 |
} else if (JLI_StrCmp(arg, "-verbosegc") == 0) { |
|
1023 |
AddOption("-verbose:gc", NULL); |
|
1024 |
} else if (JLI_StrCmp(arg, "-t") == 0) { |
|
1025 |
AddOption("-Xt", NULL); |
|
1026 |
} else if (JLI_StrCmp(arg, "-tm") == 0) { |
|
1027 |
AddOption("-Xtm", NULL); |
|
1028 |
} else if (JLI_StrCmp(arg, "-debug") == 0) { |
|
1029 |
AddOption("-Xdebug", NULL); |
|
1030 |
} else if (JLI_StrCmp(arg, "-noclassgc") == 0) { |
|
1031 |
AddOption("-Xnoclassgc", NULL); |
|
1032 |
} else if (JLI_StrCmp(arg, "-Xfuture") == 0) { |
|
1033 |
AddOption("-Xverify:all", NULL); |
|
1034 |
} else if (JLI_StrCmp(arg, "-verify") == 0) { |
|
1035 |
AddOption("-Xverify:all", NULL); |
|
1036 |
} else if (JLI_StrCmp(arg, "-verifyremote") == 0) { |
|
1037 |
AddOption("-Xverify:remote", NULL); |
|
1038 |
} else if (JLI_StrCmp(arg, "-noverify") == 0) { |
|
1039 |
AddOption("-Xverify:none", NULL); |
|
1040 |
} else if (JLI_StrCCmp(arg, "-prof") == 0) { |
|
1041 |
char *p = arg + 5; |
|
1042 |
char *tmp = JLI_MemAlloc(JLI_StrLen(arg) + 50); |
|
1043 |
if (*p) { |
|
1044 |
sprintf(tmp, "-Xrunhprof:cpu=old,file=%s", p + 1); |
|
1045 |
} else { |
|
1046 |
sprintf(tmp, "-Xrunhprof:cpu=old,file=java.prof"); |
|
1047 |
} |
|
1048 |
AddOption(tmp, NULL); |
|
1049 |
} else if (JLI_StrCCmp(arg, "-ss") == 0 || |
|
1050 |
JLI_StrCCmp(arg, "-oss") == 0 || |
|
1051 |
JLI_StrCCmp(arg, "-ms") == 0 || |
|
1052 |
JLI_StrCCmp(arg, "-mx") == 0) { |
|
1053 |
char *tmp = JLI_MemAlloc(JLI_StrLen(arg) + 6); |
|
1054 |
sprintf(tmp, "-X%s", arg + 1); /* skip '-' */ |
|
1055 |
AddOption(tmp, NULL); |
|
1056 |
} else if (JLI_StrCmp(arg, "-checksource") == 0 || |
|
1057 |
JLI_StrCmp(arg, "-cs") == 0 || |
|
1058 |
JLI_StrCmp(arg, "-noasyncgc") == 0) { |
|
1059 |
/* No longer supported */ |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1060 |
JLI_ReportErrorMessage(ARG_WARN, arg); |
2 | 1061 |
} else if (JLI_StrCCmp(arg, "-version:") == 0 || |
1062 |
JLI_StrCmp(arg, "-no-jre-restrict-search") == 0 || |
|
1063 |
JLI_StrCmp(arg, "-jre-restrict-search") == 0 || |
|
1064 |
JLI_StrCCmp(arg, "-splash:") == 0) { |
|
1065 |
; /* Ignore machine independent options already handled */ |
|
1066 |
} else if (RemovableOption(arg) ) { |
|
1067 |
; /* Do not pass option to vm. */ |
|
1068 |
} else { |
|
1069 |
AddOption(arg, NULL); |
|
1070 |
} |
|
1071 |
} |
|
1072 |
||
1073 |
if (--argc >= 0) { |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1074 |
*pwhat = *argv++; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1075 |
} |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1076 |
|
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1077 |
if (*pwhat == NULL) { |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1078 |
*pret = 1; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1079 |
} else if (mode == LM_UNKNOWN) { |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1080 |
/* default to LM_CLASS if -jar and -cp option are |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1081 |
* not specified */ |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1082 |
mode = LM_CLASS; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1083 |
} |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1084 |
|
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1085 |
if (argc >= 0) { |
2 | 1086 |
*pargc = argc; |
1087 |
*pargv = argv; |
|
1088 |
} |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1089 |
|
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1090 |
*pmode = mode; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1091 |
|
2 | 1092 |
return JNI_TRUE; |
1093 |
} |
|
1094 |
||
1095 |
/* |
|
1096 |
* Initializes the Java Virtual Machine. Also frees options array when |
|
1097 |
* finished. |
|
1098 |
*/ |
|
1099 |
static jboolean |
|
1100 |
InitializeJVM(JavaVM **pvm, JNIEnv **penv, InvocationFunctions *ifn) |
|
1101 |
{ |
|
1102 |
JavaVMInitArgs args; |
|
1103 |
jint r; |
|
1104 |
||
1105 |
memset(&args, 0, sizeof(args)); |
|
1106 |
args.version = JNI_VERSION_1_2; |
|
1107 |
args.nOptions = numOptions; |
|
1108 |
args.options = options; |
|
1109 |
args.ignoreUnrecognized = JNI_FALSE; |
|
1110 |
||
1111 |
if (JLI_IsTraceLauncher()) { |
|
1112 |
int i = 0; |
|
1113 |
printf("JavaVM args:\n "); |
|
1114 |
printf("version 0x%08lx, ", (long)args.version); |
|
1115 |
printf("ignoreUnrecognized is %s, ", |
|
1116 |
args.ignoreUnrecognized ? "JNI_TRUE" : "JNI_FALSE"); |
|
1117 |
printf("nOptions is %ld\n", (long)args.nOptions); |
|
1118 |
for (i = 0; i < numOptions; i++) |
|
1119 |
printf(" option[%2d] = '%s'\n", |
|
1120 |
i, args.options[i].optionString); |
|
1121 |
} |
|
1122 |
||
1123 |
r = ifn->CreateJavaVM(pvm, (void **)penv, &args); |
|
1124 |
JLI_MemFree(options); |
|
1125 |
return r == JNI_OK; |
|
1126 |
} |
|
1127 |
||
1128 |
||
1129 |
#define NULL_CHECK0(e) if ((e) == 0) { \ |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1130 |
JLI_ReportErrorMessage(JNI_ERROR); \ |
2 | 1131 |
return 0; \ |
1132 |
} |
|
1133 |
||
1134 |
#define NULL_CHECK(e) if ((e) == 0) { \ |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1135 |
JLI_ReportErrorMessage(JNI_ERROR); \ |
2 | 1136 |
return; \ |
1137 |
} |
|
1138 |
||
1139 |
static jstring platformEncoding = NULL; |
|
1140 |
static jstring getPlatformEncoding(JNIEnv *env) { |
|
1141 |
if (platformEncoding == NULL) { |
|
1142 |
jstring propname = (*env)->NewStringUTF(env, "sun.jnu.encoding"); |
|
1143 |
if (propname) { |
|
1144 |
jclass cls; |
|
1145 |
jmethodID mid; |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1146 |
NULL_CHECK0 (cls = FindBootStrapClass(env, "java/lang/System")); |
2 | 1147 |
NULL_CHECK0 (mid = (*env)->GetStaticMethodID( |
1148 |
env, cls, |
|
1149 |
"getProperty", |
|
1150 |
"(Ljava/lang/String;)Ljava/lang/String;")); |
|
1151 |
platformEncoding = (*env)->CallStaticObjectMethod ( |
|
1152 |
env, cls, mid, propname); |
|
1153 |
} |
|
1154 |
} |
|
1155 |
return platformEncoding; |
|
1156 |
} |
|
1157 |
||
1158 |
static jboolean isEncodingSupported(JNIEnv *env, jstring enc) { |
|
1159 |
jclass cls; |
|
1160 |
jmethodID mid; |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1161 |
NULL_CHECK0 (cls = FindBootStrapClass(env, "java/nio/charset/Charset")); |
2 | 1162 |
NULL_CHECK0 (mid = (*env)->GetStaticMethodID( |
1163 |
env, cls, |
|
1164 |
"isSupported", |
|
1165 |
"(Ljava/lang/String;)Z")); |
|
1166 |
return (*env)->CallStaticBooleanMethod(env, cls, mid, enc); |
|
1167 |
} |
|
1168 |
||
1169 |
/* |
|
1170 |
* Returns a new Java string object for the specified platform string. |
|
1171 |
*/ |
|
1172 |
static jstring |
|
1173 |
NewPlatformString(JNIEnv *env, char *s) |
|
1174 |
{ |
|
1175 |
int len = (int)JLI_StrLen(s); |
|
1176 |
jclass cls; |
|
1177 |
jmethodID mid; |
|
1178 |
jbyteArray ary; |
|
1179 |
jstring enc; |
|
1180 |
||
1181 |
if (s == NULL) |
|
1182 |
return 0; |
|
1183 |
enc = getPlatformEncoding(env); |
|
1184 |
||
1185 |
ary = (*env)->NewByteArray(env, len); |
|
1186 |
if (ary != 0) { |
|
1187 |
jstring str = 0; |
|
1188 |
(*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s); |
|
1189 |
if (!(*env)->ExceptionOccurred(env)) { |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1190 |
NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String")); |
2 | 1191 |
if (isEncodingSupported(env, enc) == JNI_TRUE) { |
1192 |
NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>", |
|
1193 |
"([BLjava/lang/String;)V")); |
|
1194 |
str = (*env)->NewObject(env, cls, mid, ary, enc); |
|
1195 |
} else { |
|
1196 |
/*If the encoding specified in sun.jnu.encoding is not |
|
1197 |
endorsed by "Charset.isSupported" we have to fall back |
|
1198 |
to use String(byte[]) explicitly here without specifying |
|
1199 |
the encoding name, in which the StringCoding class will |
|
1200 |
pickup the iso-8859-1 as the fallback converter for us. |
|
1201 |
*/ |
|
1202 |
NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>", |
|
1203 |
"([B)V")); |
|
1204 |
str = (*env)->NewObject(env, cls, mid, ary); |
|
1205 |
} |
|
1206 |
(*env)->DeleteLocalRef(env, ary); |
|
1207 |
return str; |
|
1208 |
} |
|
1209 |
} |
|
1210 |
return 0; |
|
1211 |
} |
|
1212 |
||
1213 |
/* |
|
1214 |
* Returns a new array of Java string objects for the specified |
|
1215 |
* array of platform strings. |
|
1216 |
*/ |
|
1217 |
static jobjectArray |
|
1218 |
NewPlatformStringArray(JNIEnv *env, char **strv, int strc) |
|
1219 |
{ |
|
1220 |
jarray cls; |
|
1221 |
jarray ary; |
|
1222 |
int i; |
|
1223 |
||
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1224 |
NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String")); |
2 | 1225 |
NULL_CHECK0(ary = (*env)->NewObjectArray(env, strc, cls, 0)); |
1226 |
for (i = 0; i < strc; i++) { |
|
1227 |
jstring str = NewPlatformString(env, *strv++); |
|
1228 |
NULL_CHECK0(str); |
|
1229 |
(*env)->SetObjectArrayElement(env, ary, i, str); |
|
1230 |
(*env)->DeleteLocalRef(env, str); |
|
1231 |
} |
|
1232 |
return ary; |
|
1233 |
} |
|
1234 |
||
1235 |
/* |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1236 |
* 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
|
1237 |
* call it for more details refer to the java implementation. |
2 | 1238 |
*/ |
1239 |
static jclass |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1240 |
LoadMainClass(JNIEnv *env, int mode, char *name) |
2 | 1241 |
{ |
1242 |
jclass cls; |
|
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1243 |
jmethodID mid; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1244 |
jstring str; |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1245 |
jobject result; |
2 | 1246 |
jlong start, end; |
1247 |
||
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1248 |
if (JLI_IsTraceLauncher()) { |
2 | 1249 |
start = CounterGet(); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1250 |
} |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1251 |
NULL_CHECK0(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper")); |
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1252 |
NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, "checkAndLoadMain", |
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1253 |
"(ZILjava/lang/String;)Ljava/lang/Class;")); |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1254 |
str = (*env)->NewStringUTF(env, name); |
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1255 |
result = (*env)->CallStaticObjectMethod(env, cls, mid, JNI_TRUE, mode, str); |
2 | 1256 |
|
1257 |
if (JLI_IsTraceLauncher()) { |
|
1258 |
end = CounterGet(); |
|
1259 |
printf("%ld micro seconds to load main class\n", |
|
1260 |
(long)(jint)Counter2Micros(end-start)); |
|
1261 |
printf("----_JAVA_LAUNCHER_DEBUG----\n"); |
|
1262 |
} |
|
1263 |
||
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1264 |
return (jclass)result; |
2 | 1265 |
} |
1266 |
||
1267 |
/* |
|
1268 |
* For tools, convert command line args thus: |
|
1269 |
* javac -cp foo:foo/"*" -J-ms32m ... |
|
1270 |
* java -ms32m -cp JLI_WildcardExpandClasspath(foo:foo/"*") ... |
|
1271 |
* |
|
1272 |
* Takes 4 parameters, and returns the populated arguments |
|
1273 |
*/ |
|
1274 |
static void |
|
1275 |
TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***pargv) |
|
1276 |
{ |
|
1277 |
int argc = *pargc; |
|
1278 |
char **argv = *pargv; |
|
1279 |
int nargc = argc + jargc; |
|
1280 |
char **nargv = JLI_MemAlloc((nargc + 1) * sizeof(char *)); |
|
1281 |
int i; |
|
1282 |
||
1283 |
*pargc = nargc; |
|
1284 |
*pargv = nargv; |
|
1285 |
||
1286 |
/* Copy the VM arguments (i.e. prefixed with -J) */ |
|
1287 |
for (i = 0; i < jargc; i++) { |
|
1288 |
const char *arg = jargv[i]; |
|
1289 |
if (arg[0] == '-' && arg[1] == 'J') { |
|
1290 |
*nargv++ = ((arg + 2) == NULL) ? NULL : JLI_StringDup(arg + 2); |
|
1291 |
} |
|
1292 |
} |
|
1293 |
||
1294 |
for (i = 0; i < argc; i++) { |
|
1295 |
char *arg = argv[i]; |
|
1296 |
if (arg[0] == '-' && arg[1] == 'J') { |
|
1297 |
if (arg[2] == '\0') { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1298 |
JLI_ReportErrorMessage(ARG_ERROR3); |
2 | 1299 |
exit(1); |
1300 |
} |
|
1301 |
*nargv++ = arg + 2; |
|
1302 |
} |
|
1303 |
} |
|
1304 |
||
1305 |
/* Copy the rest of the arguments */ |
|
1306 |
for (i = 0; i < jargc ; i++) { |
|
1307 |
const char *arg = jargv[i]; |
|
1308 |
if (arg[0] != '-' || arg[1] != 'J') { |
|
1309 |
*nargv++ = (arg == NULL) ? NULL : JLI_StringDup(arg); |
|
1310 |
} |
|
1311 |
} |
|
1312 |
for (i = 0; i < argc; i++) { |
|
1313 |
char *arg = argv[i]; |
|
1314 |
if (arg[0] == '-') { |
|
1315 |
if (arg[1] == 'J') |
|
1316 |
continue; |
|
1317 |
if (IsWildCardEnabled() && arg[1] == 'c' |
|
1318 |
&& (JLI_StrCmp(arg, "-cp") == 0 || |
|
1319 |
JLI_StrCmp(arg, "-classpath") == 0) |
|
1320 |
&& i < argc - 1) { |
|
1321 |
*nargv++ = arg; |
|
1322 |
*nargv++ = (char *) JLI_WildcardExpandClasspath(argv[i+1]); |
|
1323 |
i++; |
|
1324 |
continue; |
|
1325 |
} |
|
1326 |
} |
|
1327 |
*nargv++ = arg; |
|
1328 |
} |
|
1329 |
*nargv = 0; |
|
1330 |
} |
|
1331 |
||
1332 |
/* |
|
1333 |
* For our tools, we try to add 3 VM options: |
|
1334 |
* -Denv.class.path=<envcp> |
|
1335 |
* -Dapplication.home=<apphome> |
|
1336 |
* -Djava.class.path=<appcp> |
|
1337 |
* <envcp> is the user's setting of CLASSPATH -- for instance the user |
|
1338 |
* tells javac where to find binary classes through this environment |
|
1339 |
* variable. Notice that users will be able to compile against our |
|
1340 |
* tools classes (sun.tools.javac.Main) only if they explicitly add |
|
1341 |
* tools.jar to CLASSPATH. |
|
1342 |
* <apphome> is the directory where the application is installed. |
|
1343 |
* <appcp> is the classpath to where our apps' classfiles are. |
|
1344 |
*/ |
|
1345 |
static jboolean |
|
1346 |
AddApplicationOptions(int cpathc, const char **cpathv) |
|
1347 |
{ |
|
1348 |
char *envcp, *appcp, *apphome; |
|
1349 |
char home[MAXPATHLEN]; /* application home */ |
|
1350 |
char separator[] = { PATH_SEPARATOR, '\0' }; |
|
1351 |
int size, i; |
|
1352 |
||
1353 |
{ |
|
1354 |
const char *s = getenv("CLASSPATH"); |
|
1355 |
if (s) { |
|
1356 |
s = (char *) JLI_WildcardExpandClasspath(s); |
|
1357 |
/* 40 for -Denv.class.path= */ |
|
1358 |
envcp = (char *)JLI_MemAlloc(JLI_StrLen(s) + 40); |
|
1359 |
sprintf(envcp, "-Denv.class.path=%s", s); |
|
1360 |
AddOption(envcp, NULL); |
|
1361 |
} |
|
1362 |
} |
|
1363 |
||
1364 |
if (!GetApplicationHome(home, sizeof(home))) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1365 |
JLI_ReportErrorMessage(CFG_ERROR5); |
2 | 1366 |
return JNI_FALSE; |
1367 |
} |
|
1368 |
||
1369 |
/* 40 for '-Dapplication.home=' */ |
|
1370 |
apphome = (char *)JLI_MemAlloc(JLI_StrLen(home) + 40); |
|
1371 |
sprintf(apphome, "-Dapplication.home=%s", home); |
|
1372 |
AddOption(apphome, NULL); |
|
1373 |
||
1374 |
/* How big is the application's classpath? */ |
|
1375 |
size = 40; /* 40: "-Djava.class.path=" */ |
|
1376 |
for (i = 0; i < cpathc; i++) { |
|
1377 |
size += (int)JLI_StrLen(home) + (int)JLI_StrLen(cpathv[i]) + 1; /* 1: separator */ |
|
1378 |
} |
|
1379 |
appcp = (char *)JLI_MemAlloc(size + 1); |
|
1380 |
JLI_StrCpy(appcp, "-Djava.class.path="); |
|
1381 |
for (i = 0; i < cpathc; i++) { |
|
1382 |
JLI_StrCat(appcp, home); /* c:\program files\myapp */ |
|
1383 |
JLI_StrCat(appcp, cpathv[i]); /* \lib\myapp.jar */ |
|
1384 |
JLI_StrCat(appcp, separator); /* ; */ |
|
1385 |
} |
|
1386 |
appcp[JLI_StrLen(appcp)-1] = '\0'; /* remove trailing path separator */ |
|
1387 |
AddOption(appcp, NULL); |
|
1388 |
return JNI_TRUE; |
|
1389 |
} |
|
1390 |
||
1391 |
/* |
|
1392 |
* inject the -Dsun.java.command pseudo property into the args structure |
|
1393 |
* this pseudo property is used in the HotSpot VM to expose the |
|
1394 |
* Java class name and arguments to the main method to the VM. The |
|
1395 |
* HotSpot VM uses this pseudo property to store the Java class name |
|
1396 |
* (or jar file name) and the arguments to the class's main method |
|
1397 |
* to the instrumentation memory region. The sun.java.command pseudo |
|
1398 |
* property is not exported by HotSpot to the Java layer. |
|
1399 |
*/ |
|
1400 |
void |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1401 |
SetJavaCommandLineProp(char *what, int argc, char **argv) |
2 | 1402 |
{ |
1403 |
||
1404 |
int i = 0; |
|
1405 |
size_t len = 0; |
|
1406 |
char* javaCommand = NULL; |
|
1407 |
char* dashDstr = "-Dsun.java.command="; |
|
1408 |
||
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1409 |
if (what == NULL) { |
2 | 1410 |
/* unexpected, one of these should be set. just return without |
1411 |
* setting the property |
|
1412 |
*/ |
|
1413 |
return; |
|
1414 |
} |
|
1415 |
||
1416 |
/* determine the amount of memory to allocate assuming |
|
1417 |
* the individual components will be space separated |
|
1418 |
*/ |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1419 |
len = JLI_StrLen(what); |
2 | 1420 |
for (i = 0; i < argc; i++) { |
1421 |
len += JLI_StrLen(argv[i]) + 1; |
|
1422 |
} |
|
1423 |
||
1424 |
/* allocate the memory */ |
|
1425 |
javaCommand = (char*) JLI_MemAlloc(len + JLI_StrLen(dashDstr) + 1); |
|
1426 |
||
1427 |
/* build the -D string */ |
|
1428 |
*javaCommand = '\0'; |
|
1429 |
JLI_StrCat(javaCommand, dashDstr); |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1430 |
JLI_StrCat(javaCommand, what); |
2 | 1431 |
|
1432 |
for (i = 0; i < argc; i++) { |
|
1433 |
/* the components of the string are space separated. In |
|
1434 |
* the case of embedded white space, the relationship of |
|
1435 |
* the white space separated components to their true |
|
1436 |
* positional arguments will be ambiguous. This issue may |
|
1437 |
* be addressed in a future release. |
|
1438 |
*/ |
|
1439 |
JLI_StrCat(javaCommand, " "); |
|
1440 |
JLI_StrCat(javaCommand, argv[i]); |
|
1441 |
} |
|
1442 |
||
1443 |
AddOption(javaCommand, NULL); |
|
1444 |
} |
|
1445 |
||
1446 |
/* |
|
1447 |
* JVM would like to know if it's created by a standard Sun launcher, or by |
|
1448 |
* user native application, the following property indicates the former. |
|
1449 |
*/ |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1450 |
void |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1451 |
SetJavaLauncherProp() { |
2 | 1452 |
AddOption("-Dsun.java.launcher=SUN_STANDARD", NULL); |
1453 |
} |
|
1454 |
||
1455 |
/* |
|
1456 |
* Prints the version information from the java.version and other properties. |
|
1457 |
*/ |
|
1458 |
static void |
|
1459 |
PrintJavaVersion(JNIEnv *env, jboolean extraLF) |
|
1460 |
{ |
|
1461 |
jclass ver; |
|
1462 |
jmethodID print; |
|
1463 |
||
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1464 |
NULL_CHECK(ver = FindBootStrapClass(env, "sun/misc/Version")); |
2 | 1465 |
NULL_CHECK(print = (*env)->GetStaticMethodID(env, |
1466 |
ver, |
|
1467 |
(extraLF == JNI_TRUE) ? "println" : "print", |
|
1468 |
"()V" |
|
1469 |
) |
|
1470 |
); |
|
1471 |
||
1472 |
(*env)->CallStaticVoidMethod(env, ver, print); |
|
1473 |
} |
|
1474 |
||
1475 |
/* |
|
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1476 |
* 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
|
1477 |
*/ |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1478 |
static void |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1479 |
ShowSettings(JNIEnv *env, char *optString) |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1480 |
{ |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1481 |
jclass cls; |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1482 |
jmethodID showSettingsID; |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1483 |
jstring joptString; |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1484 |
NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper")); |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1485 |
NULL_CHECK(showSettingsID = (*env)->GetStaticMethodID(env, cls, |
7810 | 1486 |
"showSettings", "(ZLjava/lang/String;JJJZ)V")); |
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1487 |
joptString = (*env)->NewStringUTF(env, optString); |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1488 |
(*env)->CallStaticVoidMethod(env, cls, showSettingsID, |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1489 |
JNI_TRUE, |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1490 |
joptString, |
7810 | 1491 |
(jlong)initialHeapSize, |
1492 |
(jlong)maxHeapSize, |
|
7297
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1493 |
(jlong)threadStackSize, |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1494 |
ServerClassMachine()); |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1495 |
} |
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1496 |
|
906c58a8b849
6452854: Provide a flag to print the java configuration
ksrini
parents:
7028
diff
changeset
|
1497 |
/* |
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1498 |
* Prints default usage or the Xusage message, see sun.launcher.LauncherHelper.java |
2 | 1499 |
*/ |
1500 |
static void |
|
1501 |
PrintUsage(JNIEnv* env, jboolean doXUsage) |
|
1502 |
{ |
|
1503 |
jclass cls; |
|
1504 |
jmethodID initHelp, vmSelect, vmSynonym, vmErgo, printHelp, printXUsageMessage; |
|
1505 |
jstring jprogname, vm1, vm2; |
|
1506 |
int i; |
|
1507 |
||
1323
e14a3b3536cd
6742159: (launcher) improve the java launching mechanism
ksrini
parents:
1145
diff
changeset
|
1508 |
NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper")); |
2 | 1509 |
|
1510 |
||
1511 |
if (doXUsage) { |
|
1512 |
NULL_CHECK(printXUsageMessage = (*env)->GetStaticMethodID(env, cls, |
|
1513 |
"printXUsageMessage", "(Z)V")); |
|
1514 |
(*env)->CallStaticVoidMethod(env, cls, printXUsageMessage, JNI_TRUE); |
|
1515 |
} else { |
|
1516 |
NULL_CHECK(initHelp = (*env)->GetStaticMethodID(env, cls, |
|
1517 |
"initHelpMessage", "(Ljava/lang/String;)V")); |
|
1518 |
||
1519 |
NULL_CHECK(vmSelect = (*env)->GetStaticMethodID(env, cls, "appendVmSelectMessage", |
|
1520 |
"(Ljava/lang/String;Ljava/lang/String;)V")); |
|
1521 |
||
1522 |
NULL_CHECK(vmSynonym = (*env)->GetStaticMethodID(env, cls, |
|
1523 |
"appendVmSynonymMessage", |
|
1524 |
"(Ljava/lang/String;Ljava/lang/String;)V")); |
|
1525 |
NULL_CHECK(vmErgo = (*env)->GetStaticMethodID(env, cls, |
|
1526 |
"appendVmErgoMessage", "(ZLjava/lang/String;)V")); |
|
1527 |
||
1528 |
NULL_CHECK(printHelp = (*env)->GetStaticMethodID(env, cls, |
|
1529 |
"printHelpMessage", "(Z)V")); |
|
1530 |
||
1531 |
jprogname = (*env)->NewStringUTF(env, _program_name); |
|
1532 |
||
1533 |
/* Initialize the usage message with the usual preamble */ |
|
1534 |
(*env)->CallStaticVoidMethod(env, cls, initHelp, jprogname); |
|
1535 |
||
1536 |
||
1537 |
/* Assemble the other variant part of the usage */ |
|
1538 |
if ((knownVMs[0].flag == VM_KNOWN) || |
|
1539 |
(knownVMs[0].flag == VM_IF_SERVER_CLASS)) { |
|
1540 |
vm1 = (*env)->NewStringUTF(env, knownVMs[0].name); |
|
1541 |
vm2 = (*env)->NewStringUTF(env, knownVMs[0].name+1); |
|
1542 |
(*env)->CallStaticVoidMethod(env, cls, vmSelect, vm1, vm2); |
|
1543 |
} |
|
1544 |
for (i=1; i<knownVMsCount; i++) { |
|
1545 |
if (knownVMs[i].flag == VM_KNOWN) { |
|
1546 |
vm1 = (*env)->NewStringUTF(env, knownVMs[i].name); |
|
1547 |
vm2 = (*env)->NewStringUTF(env, knownVMs[i].name+1); |
|
1548 |
(*env)->CallStaticVoidMethod(env, cls, vmSelect, vm1, vm2); |
|
1549 |
} |
|
1550 |
} |
|
1551 |
for (i=1; i<knownVMsCount; i++) { |
|
1552 |
if (knownVMs[i].flag == VM_ALIASED_TO) { |
|
1553 |
vm1 = (*env)->NewStringUTF(env, knownVMs[i].name); |
|
1554 |
vm2 = (*env)->NewStringUTF(env, knownVMs[i].alias+1); |
|
1555 |
(*env)->CallStaticVoidMethod(env, cls, vmSynonym, vm1, vm2); |
|
1556 |
} |
|
1557 |
} |
|
1558 |
||
1559 |
/* The first known VM is the default */ |
|
1560 |
{ |
|
1561 |
jboolean isServerClassMachine = ServerClassMachine(); |
|
1562 |
||
1563 |
const char* defaultVM = knownVMs[0].name+1; |
|
1564 |
if ((knownVMs[0].flag == VM_IF_SERVER_CLASS) && isServerClassMachine) { |
|
1565 |
defaultVM = knownVMs[0].server_class+1; |
|
1566 |
} |
|
1567 |
||
1568 |
vm1 = (*env)->NewStringUTF(env, defaultVM); |
|
1569 |
(*env)->CallStaticVoidMethod(env, cls, vmErgo, isServerClassMachine, vm1); |
|
1570 |
} |
|
1571 |
||
1572 |
/* Complete the usage message and print to stderr*/ |
|
1573 |
(*env)->CallStaticVoidMethod(env, cls, printHelp, JNI_TRUE); |
|
1574 |
} |
|
1575 |
return; |
|
1576 |
} |
|
1577 |
||
1578 |
/* |
|
1579 |
* Read the jvm.cfg file and fill the knownJVMs[] array. |
|
1580 |
* |
|
1581 |
* The functionality of the jvm.cfg file is subject to change without |
|
1582 |
* notice and the mechanism will be removed in the future. |
|
1583 |
* |
|
1584 |
* The lexical structure of the jvm.cfg file is as follows: |
|
1585 |
* |
|
1586 |
* jvmcfg := { vmLine } |
|
1587 |
* vmLine := knownLine |
|
1588 |
* | aliasLine |
|
1589 |
* | warnLine |
|
1590 |
* | ignoreLine |
|
1591 |
* | errorLine |
|
1592 |
* | predicateLine |
|
1593 |
* | commentLine |
|
1594 |
* knownLine := flag "KNOWN" EOL |
|
1595 |
* warnLine := flag "WARN" EOL |
|
1596 |
* ignoreLine := flag "IGNORE" EOL |
|
1597 |
* errorLine := flag "ERROR" EOL |
|
1598 |
* aliasLine := flag "ALIASED_TO" flag EOL |
|
1599 |
* predicateLine := flag "IF_SERVER_CLASS" flag EOL |
|
1600 |
* commentLine := "#" text EOL |
|
1601 |
* flag := "-" identifier |
|
1602 |
* |
|
1603 |
* The semantics are that when someone specifies a flag on the command line: |
|
1604 |
* - if the flag appears on a knownLine, then the identifier is used as |
|
1605 |
* the name of the directory holding the JVM library (the name of the JVM). |
|
1606 |
* - if the flag appears as the first flag on an aliasLine, the identifier |
|
1607 |
* of the second flag is used as the name of the JVM. |
|
1608 |
* - if the flag appears on a warnLine, the identifier is used as the |
|
1609 |
* name of the JVM, but a warning is generated. |
|
1610 |
* - if the flag appears on an ignoreLine, the identifier is recognized as the |
|
1611 |
* name of a JVM, but the identifier is ignored and the default vm used |
|
1612 |
* - if the flag appears on an errorLine, an error is generated. |
|
1613 |
* - if the flag appears as the first flag on a predicateLine, and |
|
1614 |
* the machine on which you are running passes the predicate indicated, |
|
1615 |
* then the identifier of the second flag is used as the name of the JVM, |
|
1616 |
* otherwise the identifier of the first flag is used as the name of the JVM. |
|
1617 |
* If no flag is given on the command line, the first vmLine of the jvm.cfg |
|
1618 |
* file determines the name of the JVM. |
|
1619 |
* PredicateLines are only interpreted on first vmLine of a jvm.cfg file, |
|
1620 |
* since they only make sense if someone hasn't specified the name of the |
|
1621 |
* JVM on the command line. |
|
1622 |
* |
|
1623 |
* The intent of the jvm.cfg file is to allow several JVM libraries to |
|
1624 |
* be installed in different subdirectories of a single JRE installation, |
|
1625 |
* for space-savings and convenience in testing. |
|
1626 |
* The intent is explicitly not to provide a full aliasing or predicate |
|
1627 |
* mechanism. |
|
1628 |
*/ |
|
1629 |
jint |
|
1630 |
ReadKnownVMs(const char *jrepath, const char * arch, jboolean speculative) |
|
1631 |
{ |
|
1632 |
FILE *jvmCfg; |
|
1633 |
char jvmCfgName[MAXPATHLEN+20]; |
|
1634 |
char line[MAXPATHLEN+20]; |
|
1635 |
int cnt = 0; |
|
1636 |
int lineno = 0; |
|
1637 |
jlong start, end; |
|
1638 |
int vmType; |
|
1639 |
char *tmpPtr; |
|
1640 |
char *altVMName = NULL; |
|
1641 |
char *serverClassVMName = NULL; |
|
1642 |
static char *whiteSpace = " \t"; |
|
1643 |
if (JLI_IsTraceLauncher()) { |
|
1644 |
start = CounterGet(); |
|
1645 |
} |
|
6535
77ffd0e75bfb
6390477: (launcher) replace unsafe usages of sprintf with snprintf
ksrini
parents:
6005
diff
changeset
|
1646 |
JLI_Snprintf(jvmCfgName, sizeof(jvmCfgName), "%s%slib%s%s%sjvm.cfg", |
77ffd0e75bfb
6390477: (launcher) replace unsafe usages of sprintf with snprintf
ksrini
parents:
6005
diff
changeset
|
1647 |
jrepath, FILESEP, FILESEP, arch, FILESEP); |
2 | 1648 |
|
1649 |
jvmCfg = fopen(jvmCfgName, "r"); |
|
1650 |
if (jvmCfg == NULL) { |
|
1651 |
if (!speculative) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1652 |
JLI_ReportErrorMessage(CFG_ERROR6, jvmCfgName); |
2 | 1653 |
exit(1); |
1654 |
} else { |
|
1655 |
return -1; |
|
1656 |
} |
|
1657 |
} |
|
1658 |
while (fgets(line, sizeof(line), jvmCfg) != NULL) { |
|
1659 |
vmType = VM_UNKNOWN; |
|
1660 |
lineno++; |
|
1661 |
if (line[0] == '#') |
|
1662 |
continue; |
|
1663 |
if (line[0] != '-') { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1664 |
JLI_ReportErrorMessage(CFG_WARN2, lineno, jvmCfgName); |
2 | 1665 |
} |
1666 |
if (cnt >= knownVMsLimit) { |
|
1667 |
GrowKnownVMs(cnt); |
|
1668 |
} |
|
1669 |
line[JLI_StrLen(line)-1] = '\0'; /* remove trailing newline */ |
|
1670 |
tmpPtr = line + JLI_StrCSpn(line, whiteSpace); |
|
1671 |
if (*tmpPtr == 0) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1672 |
JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName); |
2 | 1673 |
} else { |
1674 |
/* Null-terminate this string for JLI_StringDup below */ |
|
1675 |
*tmpPtr++ = 0; |
|
1676 |
tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace); |
|
1677 |
if (*tmpPtr == 0) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1678 |
JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName); |
2 | 1679 |
} else { |
1680 |
if (!JLI_StrCCmp(tmpPtr, "KNOWN")) { |
|
1681 |
vmType = VM_KNOWN; |
|
1682 |
} else if (!JLI_StrCCmp(tmpPtr, "ALIASED_TO")) { |
|
1683 |
tmpPtr += JLI_StrCSpn(tmpPtr, whiteSpace); |
|
1684 |
if (*tmpPtr != 0) { |
|
1685 |
tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace); |
|
1686 |
} |
|
1687 |
if (*tmpPtr == 0) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1688 |
JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName); |
2 | 1689 |
} else { |
1690 |
/* Null terminate altVMName */ |
|
1691 |
altVMName = tmpPtr; |
|
1692 |
tmpPtr += JLI_StrCSpn(tmpPtr, whiteSpace); |
|
1693 |
*tmpPtr = 0; |
|
1694 |
vmType = VM_ALIASED_TO; |
|
1695 |
} |
|
1696 |
} else if (!JLI_StrCCmp(tmpPtr, "WARN")) { |
|
1697 |
vmType = VM_WARN; |
|
1698 |
} else if (!JLI_StrCCmp(tmpPtr, "IGNORE")) { |
|
1699 |
vmType = VM_IGNORE; |
|
1700 |
} else if (!JLI_StrCCmp(tmpPtr, "ERROR")) { |
|
1701 |
vmType = VM_ERROR; |
|
1702 |
} else if (!JLI_StrCCmp(tmpPtr, "IF_SERVER_CLASS")) { |
|
1703 |
tmpPtr += JLI_StrCSpn(tmpPtr, whiteSpace); |
|
1704 |
if (*tmpPtr != 0) { |
|
1705 |
tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace); |
|
1706 |
} |
|
1707 |
if (*tmpPtr == 0) { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1708 |
JLI_ReportErrorMessage(CFG_WARN4, lineno, jvmCfgName); |
2 | 1709 |
} else { |
1710 |
/* Null terminate server class VM name */ |
|
1711 |
serverClassVMName = tmpPtr; |
|
1712 |
tmpPtr += JLI_StrCSpn(tmpPtr, whiteSpace); |
|
1713 |
*tmpPtr = 0; |
|
1714 |
vmType = VM_IF_SERVER_CLASS; |
|
1715 |
} |
|
1716 |
} else { |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1717 |
JLI_ReportErrorMessage(CFG_WARN5, lineno, &jvmCfgName[0]); |
2 | 1718 |
vmType = VM_KNOWN; |
1719 |
} |
|
1720 |
} |
|
1721 |
} |
|
1722 |
||
1723 |
JLI_TraceLauncher("jvm.cfg[%d] = ->%s<-\n", cnt, line); |
|
1724 |
if (vmType != VM_UNKNOWN) { |
|
1725 |
knownVMs[cnt].name = JLI_StringDup(line); |
|
1726 |
knownVMs[cnt].flag = vmType; |
|
1727 |
switch (vmType) { |
|
1728 |
default: |
|
1729 |
break; |
|
1730 |
case VM_ALIASED_TO: |
|
1731 |
knownVMs[cnt].alias = JLI_StringDup(altVMName); |
|
1732 |
JLI_TraceLauncher(" name: %s vmType: %s alias: %s\n", |
|
1733 |
knownVMs[cnt].name, "VM_ALIASED_TO", knownVMs[cnt].alias); |
|
1734 |
break; |
|
1735 |
case VM_IF_SERVER_CLASS: |
|
1736 |
knownVMs[cnt].server_class = JLI_StringDup(serverClassVMName); |
|
1737 |
JLI_TraceLauncher(" name: %s vmType: %s server_class: %s\n", |
|
1738 |
knownVMs[cnt].name, "VM_IF_SERVER_CLASS", knownVMs[cnt].server_class); |
|
1739 |
break; |
|
1740 |
} |
|
1741 |
cnt++; |
|
1742 |
} |
|
1743 |
} |
|
1744 |
fclose(jvmCfg); |
|
1745 |
knownVMsCount = cnt; |
|
1746 |
||
1747 |
if (JLI_IsTraceLauncher()) { |
|
1748 |
end = CounterGet(); |
|
1749 |
printf("%ld micro seconds to parse jvm.cfg\n", |
|
1750 |
(long)(jint)Counter2Micros(end-start)); |
|
1751 |
} |
|
1752 |
||
1753 |
return cnt; |
|
1754 |
} |
|
1755 |
||
1756 |
||
1757 |
static void |
|
1758 |
GrowKnownVMs(int minimum) |
|
1759 |
{ |
|
1760 |
struct vmdesc* newKnownVMs; |
|
1761 |
int newMax; |
|
1762 |
||
1763 |
newMax = (knownVMsLimit == 0 ? INIT_MAX_KNOWN_VMS : (2 * knownVMsLimit)); |
|
1764 |
if (newMax <= minimum) { |
|
1765 |
newMax = minimum; |
|
1766 |
} |
|
1767 |
newKnownVMs = (struct vmdesc*) JLI_MemAlloc(newMax * sizeof(struct vmdesc)); |
|
1768 |
if (knownVMs != NULL) { |
|
1769 |
memcpy(newKnownVMs, knownVMs, knownVMsLimit * sizeof(struct vmdesc)); |
|
1770 |
} |
|
1771 |
JLI_MemFree(knownVMs); |
|
1772 |
knownVMs = newKnownVMs; |
|
1773 |
knownVMsLimit = newMax; |
|
1774 |
} |
|
1775 |
||
1776 |
||
1777 |
/* Returns index of VM or -1 if not found */ |
|
1778 |
static int |
|
1779 |
KnownVMIndex(const char* name) |
|
1780 |
{ |
|
1781 |
int i; |
|
1782 |
if (JLI_StrCCmp(name, "-J") == 0) name += 2; |
|
1783 |
for (i = 0; i < knownVMsCount; i++) { |
|
1784 |
if (!JLI_StrCmp(name, knownVMs[i].name)) { |
|
1785 |
return i; |
|
1786 |
} |
|
1787 |
} |
|
1788 |
return -1; |
|
1789 |
} |
|
1790 |
||
1791 |
static void |
|
1792 |
FreeKnownVMs() |
|
1793 |
{ |
|
1794 |
int i; |
|
1795 |
for (i = 0; i < knownVMsCount; i++) { |
|
1796 |
JLI_MemFree(knownVMs[i].name); |
|
1797 |
knownVMs[i].name = NULL; |
|
1798 |
} |
|
1799 |
JLI_MemFree(knownVMs); |
|
1800 |
} |
|
1801 |
||
1802 |
||
1803 |
/* |
|
1804 |
* Displays the splash screen according to the jar file name |
|
1805 |
* and image file names stored in environment variables |
|
1806 |
*/ |
|
1807 |
static void |
|
1808 |
ShowSplashScreen() |
|
1809 |
{ |
|
1810 |
const char *jar_name = getenv(SPLASH_JAR_ENV_ENTRY); |
|
1811 |
const char *file_name = getenv(SPLASH_FILE_ENV_ENTRY); |
|
1812 |
int data_size; |
|
1813 |
void *image_data; |
|
1814 |
if (jar_name) { |
|
1815 |
image_data = JLI_JarUnpackFile(jar_name, file_name, &data_size); |
|
1816 |
if (image_data) { |
|
1817 |
DoSplashInit(); |
|
1818 |
DoSplashLoadMemory(image_data, data_size); |
|
1819 |
JLI_MemFree(image_data); |
|
1820 |
} |
|
1821 |
} else if (file_name) { |
|
1822 |
DoSplashInit(); |
|
1823 |
DoSplashLoadFile(file_name); |
|
1824 |
} else { |
|
1825 |
return; |
|
1826 |
} |
|
1827 |
DoSplashSetFileJarName(file_name, jar_name); |
|
1828 |
||
1829 |
/* |
|
1830 |
* Done with all command line processing and potential re-execs so |
|
1831 |
* clean up the environment. |
|
1832 |
*/ |
|
1833 |
(void)UnsetEnv(ENV_ENTRY); |
|
1834 |
(void)UnsetEnv(SPLASH_FILE_ENV_ENTRY); |
|
1835 |
(void)UnsetEnv(SPLASH_JAR_ENV_ENTRY); |
|
1836 |
||
1837 |
JLI_MemFree(splash_jar_entry); |
|
1838 |
JLI_MemFree(splash_file_entry); |
|
1839 |
||
1840 |
} |
|
1841 |
||
1842 |
const char* |
|
1843 |
GetDotVersion() |
|
1844 |
{ |
|
1845 |
return _dVersion; |
|
1846 |
} |
|
1847 |
||
1848 |
const char* |
|
1849 |
GetFullVersion() |
|
1850 |
{ |
|
1851 |
return _fVersion; |
|
1852 |
} |
|
1853 |
||
1854 |
const char* |
|
1855 |
GetProgramName() |
|
1856 |
{ |
|
1857 |
return _program_name; |
|
1858 |
} |
|
1859 |
||
1860 |
const char* |
|
1861 |
GetLauncherName() |
|
1862 |
{ |
|
1863 |
return _launcher_name; |
|
1864 |
} |
|
1865 |
||
1866 |
jint |
|
1867 |
GetErgoPolicy() |
|
1868 |
{ |
|
1869 |
return _ergo_policy; |
|
1870 |
} |
|
1871 |
||
1872 |
jboolean |
|
1873 |
IsJavaArgs() |
|
1874 |
{ |
|
1875 |
return _is_java_args; |
|
1876 |
} |
|
1877 |
||
1878 |
static jboolean |
|
1879 |
IsWildCardEnabled() |
|
1880 |
{ |
|
1881 |
return _wc_enabled; |
|
1882 |
} |
|
1883 |
||
1884 |
static int |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1885 |
ContinueInNewThread(InvocationFunctions* ifn, int argc, char **argv, |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1886 |
int mode, char *what, int ret) |
2 | 1887 |
{ |
1888 |
||
1889 |
/* |
|
1890 |
* If user doesn't specify stack size, check if VM has a preference. |
|
1891 |
* Note that HotSpot no longer supports JNI_VERSION_1_1 but it will |
|
1892 |
* return its default stack size through the init args structure. |
|
1893 |
*/ |
|
1894 |
if (threadStackSize == 0) { |
|
1895 |
struct JDK1_1InitArgs args1_1; |
|
1896 |
memset((void*)&args1_1, 0, sizeof(args1_1)); |
|
1897 |
args1_1.version = JNI_VERSION_1_1; |
|
1898 |
ifn->GetDefaultJavaVMInitArgs(&args1_1); /* ignore return value */ |
|
1899 |
if (args1_1.javaStackSize > 0) { |
|
1900 |
threadStackSize = args1_1.javaStackSize; |
|
1901 |
} |
|
1902 |
} |
|
1903 |
||
1904 |
{ /* Create a new thread to create JVM and invoke main method */ |
|
1905 |
JavaMainArgs args; |
|
1906 |
int rslt; |
|
1907 |
||
1908 |
args.argc = argc; |
|
1909 |
args.argv = argv; |
|
7997
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1910 |
args.mode = mode; |
78536cac0841
6912013: Remove the temporary launcher fix to add modules in the bootclasspath
mchung
parents:
7810
diff
changeset
|
1911 |
args.what = what; |
2 | 1912 |
args.ifn = *ifn; |
1913 |
||
1914 |
rslt = ContinueInNewThread0(JavaMain, threadStackSize, (void*)&args); |
|
1915 |
/* If the caller has deemed there is an error we |
|
1916 |
* simply return that, otherwise we return the value of |
|
1917 |
* the callee |
|
1918 |
*/ |
|
1919 |
return (ret != 0) ? ret : rslt; |
|
1920 |
} |
|
1921 |
} |
|
1922 |
||
1923 |
static void |
|
1924 |
DumpState() |
|
1925 |
{ |
|
1926 |
if (!JLI_IsTraceLauncher()) return ; |
|
1927 |
printf("Launcher state:\n"); |
|
1928 |
printf("\tdebug:%s\n", (JLI_IsTraceLauncher() == JNI_TRUE) ? "on" : "off"); |
|
1929 |
printf("\tjavargs:%s\n", (_is_java_args == JNI_TRUE) ? "on" : "off"); |
|
1930 |
printf("\tprogram name:%s\n", GetProgramName()); |
|
1931 |
printf("\tlauncher name:%s\n", GetLauncherName()); |
|
1932 |
printf("\tjavaw:%s\n", (IsJavaw() == JNI_TRUE) ? "on" : "off"); |
|
1933 |
printf("\tfullversion:%s\n", GetFullVersion()); |
|
1934 |
printf("\tdotversion:%s\n", GetDotVersion()); |
|
1935 |
printf("\tergo_policy:"); |
|
1936 |
switch(GetErgoPolicy()) { |
|
1937 |
case NEVER_SERVER_CLASS: |
|
1938 |
printf("NEVER_ACT_AS_A_SERVER_CLASS_MACHINE\n"); |
|
1939 |
break; |
|
1940 |
case ALWAYS_SERVER_CLASS: |
|
1941 |
printf("ALWAYS_ACT_AS_A_SERVER_CLASS_MACHINE\n"); |
|
1942 |
break; |
|
1943 |
default: |
|
1944 |
printf("DEFAULT_ERGONOMICS_POLICY\n"); |
|
1945 |
} |
|
1946 |
} |
|
1947 |
||
1948 |
/* |
|
1949 |
* Return JNI_TRUE for an option string that has no effect but should |
|
1950 |
* _not_ be passed on to the vm; return JNI_FALSE otherwise. On |
|
1951 |
* Solaris SPARC, this screening needs to be done if: |
|
4340
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
3054
diff
changeset
|
1952 |
* -d32 or -d64 is passed to a binary with an unmatched data model |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
3054
diff
changeset
|
1953 |
* (the exec in CreateExecutionEnvironment removes -d<n> options and points the |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
3054
diff
changeset
|
1954 |
* exec to the proper binary). In the case of when the data model and the |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
3054
diff
changeset
|
1955 |
* requested version is matched, an exec would not occur, and these options |
ec6ba551fa78
6367077: Purge LD_LIBRARY_PATH usage from the launcher
ksrini
parents:
3054
diff
changeset
|
1956 |
* were erroneously passed to the vm. |
2 | 1957 |
*/ |
1958 |
jboolean |
|
1959 |
RemovableOption(char * option) |
|
1960 |
{ |
|
1961 |
/* |
|
1962 |
* Unconditionally remove both -d32 and -d64 options since only |
|
1963 |
* the last such options has an effect; e.g. |
|
1964 |
* java -d32 -d64 -d32 -version |
|
1965 |
* is equivalent to |
|
1966 |
* java -d32 -version |
|
1967 |
*/ |
|
1968 |
||
1969 |
if( (JLI_StrCCmp(option, "-d32") == 0 ) || |
|
1970 |
(JLI_StrCCmp(option, "-d64") == 0 ) ) |
|
1971 |
return JNI_TRUE; |
|
1972 |
else |
|
1973 |
return JNI_FALSE; |
|
1974 |
} |
|
1975 |
||
1976 |
/* |
|
1977 |
* A utility procedure to always print to stderr |
|
1978 |
*/ |
|
1979 |
void |
|
1145
404b11752c57
6685121: (launcher) make ReportErrorMessages accessible by other launcher subsystems
ksrini
parents:
399
diff
changeset
|
1980 |
JLI_ReportMessage(const char* fmt, ...) |
2 | 1981 |
{ |
1982 |
va_list vl; |
|
1983 |
va_start(vl, fmt); |
|
1984 |
vfprintf(stderr, fmt, vl); |
|
1985 |
fprintf(stderr, "\n"); |
|
1986 |
va_end(vl); |
|
1987 |
} |