236 * 1) Disallow specification of another JRE. With 1.9, another
237 * version of the JRE cannot be invoked.
238 * 2) Allow for a JRE version to invoke JDK 1.9 or later. Since
239 * all mJRE directives have been stripped from the request but
240 * the pre 1.9 JRE [ 1.6 thru 1.8 ], it is as if 1.9+ has been
241 * invoked from the command line.
242 */
243 SelectVersion(argc, argv, &main_class);
244
245 CreateExecutionEnvironment(&argc, &argv,
246 jrepath, sizeof(jrepath),
247 jvmpath, sizeof(jvmpath),
248 jvmcfg, sizeof(jvmcfg));
249
250 if (!IsJavaArgs()) {
251 SetJvmEnvironment(argc,argv);
252 }
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()) {
314 * Always detach the main thread so that it appears to have ended when
315 * the application's main method exits. This will invoke the
316 * uncaught exception handler machinery if main threw an
317 * exception. An uncaught exception handler cannot change the
318 * launcher's return code except by calling System.exit.
319 *
320 * Wait for all non-daemon threads to end, then destroy the VM.
321 * This will actually create a trivial new Java waiter thread
322 * named "DestroyJavaVM", but this will be seen as a different
323 * thread from the one that executed main, even though they are
324 * the same C thread. This allows mainThread.join() and
325 * mainThread.isAlive() to work as expected.
326 */
327 #define LEAVE() \
328 do { \
329 if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \
330 JLI_ReportErrorMessage(JVM_ERROR2); \
331 ret = 1; \
332 } \
333 if (JNI_TRUE) { \
334 (*vm)->DestroyJavaVM(vm); \
335 return ret; \
336 } \
337 } while (JNI_FALSE)
338
339 #define CHECK_EXCEPTION_NULL_LEAVE(CENL_exception) \
340 do { \
341 if ((*env)->ExceptionOccurred(env)) { \
342 JLI_ReportExceptionDescription(env); \
343 LEAVE(); \
344 } \
345 if ((CENL_exception) == NULL) { \
346 JLI_ReportErrorMessage(JNI_ERROR); \
347 LEAVE(); \
348 } \
349 } while (JNI_FALSE)
350
351 #define CHECK_EXCEPTION_LEAVE(CEL_return_value) \
352 do { \
353 if ((*env)->ExceptionOccurred(env)) { \
470 * for example, on OSX this sets the application name in the menu bar for
471 * both SWT and JavaFX. So we'll pass the actual application class here
472 * instead of mainClass as that may be a launcher or helper class instead
473 * of the application class.
474 */
475 PostJVMInit(env, appClass, vm);
476 CHECK_EXCEPTION_LEAVE(1);
477 /*
478 * The LoadMainClass not only loads the main class, it will also ensure
479 * that the main method's signature is correct, therefore further checking
480 * is not required. The main method is invoked here so that extraneous java
481 * stacks are not in the application stack trace.
482 */
483 mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
484 "([Ljava/lang/String;)V");
485 CHECK_EXCEPTION_NULL_LEAVE(mainID);
486
487 /* Build platform specific argument array */
488 mainArgs = CreateApplicationArgs(env, argv, argc);
489 CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
490
491 /* Invoke main method. */
492 (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
493
494 /*
495 * The launcher's exit code (in the absence of calls to
496 * System.exit) will be non-zero if main threw an exception.
497 */
498 ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
499 LEAVE();
500 }
501
502 /*
503 * Checks the command line options to find which JVM type was
504 * specified. If no command line option was given for the JVM type,
505 * the default type is used. The environment variable
506 * JDK_ALTERNATE_VM and the command line option -XXaltjvm= are also
507 * checked as ways of specifying which JVM type to invoke.
508 */
509 char *
|
236 * 1) Disallow specification of another JRE. With 1.9, another
237 * version of the JRE cannot be invoked.
238 * 2) Allow for a JRE version to invoke JDK 1.9 or later. Since
239 * all mJRE directives have been stripped from the request but
240 * the pre 1.9 JRE [ 1.6 thru 1.8 ], it is as if 1.9+ has been
241 * invoked from the command line.
242 */
243 SelectVersion(argc, argv, &main_class);
244
245 CreateExecutionEnvironment(&argc, &argv,
246 jrepath, sizeof(jrepath),
247 jvmpath, sizeof(jvmpath),
248 jvmcfg, sizeof(jvmcfg));
249
250 if (!IsJavaArgs()) {
251 SetJvmEnvironment(argc,argv);
252 }
253
254 ifn.CreateJavaVM = 0;
255 ifn.GetDefaultJavaVMInitArgs = 0;
256 ifn.SetNativeThreadName0 = 0;
257
258 if (JLI_IsTraceLauncher()) {
259 start = CounterGet();
260 }
261
262 if (!LoadJavaVM(jvmpath, &ifn)) {
263 return(6);
264 }
265
266 if (JLI_IsTraceLauncher()) {
267 end = CounterGet();
268 }
269
270 JLI_TraceLauncher("%ld micro seconds to LoadJavaVM\n",
271 (long)(jint)Counter2Micros(end-start));
272
273 ++argv;
274 --argc;
275
276 if (IsJavaArgs()) {
315 * Always detach the main thread so that it appears to have ended when
316 * the application's main method exits. This will invoke the
317 * uncaught exception handler machinery if main threw an
318 * exception. An uncaught exception handler cannot change the
319 * launcher's return code except by calling System.exit.
320 *
321 * Wait for all non-daemon threads to end, then destroy the VM.
322 * This will actually create a trivial new Java waiter thread
323 * named "DestroyJavaVM", but this will be seen as a different
324 * thread from the one that executed main, even though they are
325 * the same C thread. This allows mainThread.join() and
326 * mainThread.isAlive() to work as expected.
327 */
328 #define LEAVE() \
329 do { \
330 if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \
331 JLI_ReportErrorMessage(JVM_ERROR2); \
332 ret = 1; \
333 } \
334 if (JNI_TRUE) { \
335 ifn.SetNativeThreadName0("DestroyJavaVM"); \
336 (*vm)->DestroyJavaVM(vm); \
337 return ret; \
338 } \
339 } while (JNI_FALSE)
340
341 #define CHECK_EXCEPTION_NULL_LEAVE(CENL_exception) \
342 do { \
343 if ((*env)->ExceptionOccurred(env)) { \
344 JLI_ReportExceptionDescription(env); \
345 LEAVE(); \
346 } \
347 if ((CENL_exception) == NULL) { \
348 JLI_ReportErrorMessage(JNI_ERROR); \
349 LEAVE(); \
350 } \
351 } while (JNI_FALSE)
352
353 #define CHECK_EXCEPTION_LEAVE(CEL_return_value) \
354 do { \
355 if ((*env)->ExceptionOccurred(env)) { \
472 * for example, on OSX this sets the application name in the menu bar for
473 * both SWT and JavaFX. So we'll pass the actual application class here
474 * instead of mainClass as that may be a launcher or helper class instead
475 * of the application class.
476 */
477 PostJVMInit(env, appClass, vm);
478 CHECK_EXCEPTION_LEAVE(1);
479 /*
480 * The LoadMainClass not only loads the main class, it will also ensure
481 * that the main method's signature is correct, therefore further checking
482 * is not required. The main method is invoked here so that extraneous java
483 * stacks are not in the application stack trace.
484 */
485 mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
486 "([Ljava/lang/String;)V");
487 CHECK_EXCEPTION_NULL_LEAVE(mainID);
488
489 /* Build platform specific argument array */
490 mainArgs = CreateApplicationArgs(env, argv, argc);
491 CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
492
493 /* Set native thread name */
494 ifn.SetNativeThreadName0("main");
495
496 /* Invoke main method. */
497 (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
498
499 /*
500 * The launcher's exit code (in the absence of calls to
501 * System.exit) will be non-zero if main threw an exception.
502 */
503 ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
504 LEAVE();
505 }
506
507 /*
508 * Checks the command line options to find which JVM type was
509 * specified. If no command line option was given for the JVM type,
510 * the default type is used. The environment variable
511 * JDK_ALTERNATE_VM and the command line option -XXaltjvm= are also
512 * checked as ways of specifying which JVM type to invoke.
513 */
514 char *
|