1 /*
2 * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
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
44 * CheckJvmType removes vm style options and TranslateApplicationArgs
45 * removes "-J" prefixes. The CreateExecutionEnvironment function processes
46 * and removes -d<n> options. On unix, there is a possibility that the running
47 * data model may not match to the desired data model, in this case an exec is
48 * required to start the desired model. If the data models match, then
49 * ParseArguments will remove the -d<n> flags. If the data models do not match
50 * the CreateExecutionEnviroment will remove the -d<n> flags.
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 #define USE_STDERR JNI_TRUE /* we usually print to stderr */
65 #define USE_STDOUT JNI_FALSE
66
67 static jboolean printVersion = JNI_FALSE; /* print and exit */
68 static jboolean showVersion = JNI_FALSE; /* print but continue */
69 static jboolean printUsage = JNI_FALSE; /* print and exit*/
70 static jboolean printTo = USE_STDERR; /* where to print version/usage */
71 static jboolean printXUsage = JNI_FALSE; /* print and exit*/
72 static jboolean dryRun = JNI_FALSE; /* initialize VM and exit */
73 static char *showSettings = NULL; /* print but continue */
74 static jboolean showResolvedModules = JNI_FALSE;
195 } while (JNI_FALSE)
196
197 /*
198 * Running Java code in primordial thread caused many problems. We will
199 * create a new thread to invoke JVM. See 6316197 for more information.
200 */
201 static jlong threadStackSize = 0; /* stack size of the new thread */
202 static jlong maxHeapSize = 0; /* max heap size */
203 static jlong initialHeapSize = 0; /* inital heap size */
204
205 /*
206 * A minimum -Xss stack size suitable for all platforms.
207 */
208 #ifndef STACK_SIZE_MINIMUM
209 #define STACK_SIZE_MINIMUM (64 * KB)
210 #endif
211
212 /*
213 * Entry point.
214 */
215 int
216 JLI_Launch(int argc, char ** argv, /* main argc, argc */
217 int jargc, const char** jargv, /* java args */
218 int appclassc, const char** appclassv, /* app classpath */
219 const char* fullversion, /* full version defined */
220 const char* dotversion, /* UNUSED dot version defined */
221 const char* pname, /* program name */
222 const char* lname, /* launcher name */
223 jboolean javaargs, /* JAVA_ARGS */
224 jboolean cpwildcard, /* classpath wildcard*/
225 jboolean javaw, /* windows-only javaw */
226 jint ergo /* unused */
227 )
228 {
229 int mode = LM_UNKNOWN;
230 char *what = NULL;
231 char *main_class = NULL;
232 int ret;
233 InvocationFunctions ifn;
234 jlong start, end;
235 char jvmpath[MAXPATHLEN];
2320 }
2321 }
2322
2323 static void
2324 DumpState()
2325 {
2326 if (!JLI_IsTraceLauncher()) return ;
2327 printf("Launcher state:\n");
2328 printf("\tFirst application arg index: %d\n", JLI_GetAppArgIndex());
2329 printf("\tdebug:%s\n", (JLI_IsTraceLauncher() == JNI_TRUE) ? "on" : "off");
2330 printf("\tjavargs:%s\n", (_is_java_args == JNI_TRUE) ? "on" : "off");
2331 printf("\tprogram name:%s\n", GetProgramName());
2332 printf("\tlauncher name:%s\n", GetLauncherName());
2333 printf("\tjavaw:%s\n", (IsJavaw() == JNI_TRUE) ? "on" : "off");
2334 printf("\tfullversion:%s\n", GetFullVersion());
2335 }
2336
2337 /*
2338 * A utility procedure to always print to stderr
2339 */
2340 void
2341 JLI_ReportMessage(const char* fmt, ...)
2342 {
2343 va_list vl;
2344 va_start(vl, fmt);
2345 vfprintf(stderr, fmt, vl);
2346 fprintf(stderr, "\n");
2347 va_end(vl);
2348 }
2349
2350 /*
2351 * A utility procedure to always print to stdout
2352 */
2353 void
2354 JLI_ShowMessage(const char* fmt, ...)
2355 {
2356 va_list vl;
2357 va_start(vl, fmt);
2358 vfprintf(stdout, fmt, vl);
2359 fprintf(stdout, "\n");
2360 va_end(vl);
|
1 /*
2 * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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
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
44 * CheckJvmType removes vm style options and TranslateApplicationArgs
45 * removes "-J" prefixes. The CreateExecutionEnvironment function processes
46 * and removes -d<n> options. On unix, there is a possibility that the running
47 * data model may not match to the desired data model, in this case an exec is
48 * required to start the desired model. If the data models match, then
49 * ParseArguments will remove the -d<n> flags. If the data models do not match
50 * the CreateExecutionEnviroment will remove the -d<n> flags.
51 */
52
53
54 #include "java.h"
55 #include "jni.h"
56
57 /*
58 * A NOTE TO DEVELOPERS: For performance reasons it is important that
59 * the program image remain relatively small until after SelectVersion
60 * CreateExecutionEnvironment have finished their possibly recursive
61 * processing. Watch everything, but resist all temptations to use Java
62 * interfaces.
63 */
64
65 #define USE_STDERR JNI_TRUE /* we usually print to stderr */
66 #define USE_STDOUT JNI_FALSE
67
68 static jboolean printVersion = JNI_FALSE; /* print and exit */
69 static jboolean showVersion = JNI_FALSE; /* print but continue */
70 static jboolean printUsage = JNI_FALSE; /* print and exit*/
71 static jboolean printTo = USE_STDERR; /* where to print version/usage */
72 static jboolean printXUsage = JNI_FALSE; /* print and exit*/
73 static jboolean dryRun = JNI_FALSE; /* initialize VM and exit */
74 static char *showSettings = NULL; /* print but continue */
75 static jboolean showResolvedModules = JNI_FALSE;
196 } while (JNI_FALSE)
197
198 /*
199 * Running Java code in primordial thread caused many problems. We will
200 * create a new thread to invoke JVM. See 6316197 for more information.
201 */
202 static jlong threadStackSize = 0; /* stack size of the new thread */
203 static jlong maxHeapSize = 0; /* max heap size */
204 static jlong initialHeapSize = 0; /* inital heap size */
205
206 /*
207 * A minimum -Xss stack size suitable for all platforms.
208 */
209 #ifndef STACK_SIZE_MINIMUM
210 #define STACK_SIZE_MINIMUM (64 * KB)
211 #endif
212
213 /*
214 * Entry point.
215 */
216 JNIEXPORT int JNICALL
217 JLI_Launch(int argc, char ** argv, /* main argc, argc */
218 int jargc, const char** jargv, /* java args */
219 int appclassc, const char** appclassv, /* app classpath */
220 const char* fullversion, /* full version defined */
221 const char* dotversion, /* UNUSED dot version defined */
222 const char* pname, /* program name */
223 const char* lname, /* launcher name */
224 jboolean javaargs, /* JAVA_ARGS */
225 jboolean cpwildcard, /* classpath wildcard*/
226 jboolean javaw, /* windows-only javaw */
227 jint ergo /* unused */
228 )
229 {
230 int mode = LM_UNKNOWN;
231 char *what = NULL;
232 char *main_class = NULL;
233 int ret;
234 InvocationFunctions ifn;
235 jlong start, end;
236 char jvmpath[MAXPATHLEN];
2321 }
2322 }
2323
2324 static void
2325 DumpState()
2326 {
2327 if (!JLI_IsTraceLauncher()) return ;
2328 printf("Launcher state:\n");
2329 printf("\tFirst application arg index: %d\n", JLI_GetAppArgIndex());
2330 printf("\tdebug:%s\n", (JLI_IsTraceLauncher() == JNI_TRUE) ? "on" : "off");
2331 printf("\tjavargs:%s\n", (_is_java_args == JNI_TRUE) ? "on" : "off");
2332 printf("\tprogram name:%s\n", GetProgramName());
2333 printf("\tlauncher name:%s\n", GetLauncherName());
2334 printf("\tjavaw:%s\n", (IsJavaw() == JNI_TRUE) ? "on" : "off");
2335 printf("\tfullversion:%s\n", GetFullVersion());
2336 }
2337
2338 /*
2339 * A utility procedure to always print to stderr
2340 */
2341 JNIEXPORT void JNICALL
2342 JLI_ReportMessage(const char* fmt, ...)
2343 {
2344 va_list vl;
2345 va_start(vl, fmt);
2346 vfprintf(stderr, fmt, vl);
2347 fprintf(stderr, "\n");
2348 va_end(vl);
2349 }
2350
2351 /*
2352 * A utility procedure to always print to stdout
2353 */
2354 void
2355 JLI_ShowMessage(const char* fmt, ...)
2356 {
2357 va_list vl;
2358 va_start(vl, fmt);
2359 vfprintf(stdout, fmt, vl);
2360 fprintf(stdout, "\n");
2361 va_end(vl);
|