< prev index next >

src/share/bin/java.c

Print this page
rev 11229 : 8068033: JNI exception pending in jdk/src/share/bin/java.c
Reviewed-by: mchung, serb
   1 /*
   2  * Copyright (c) 1995, 2014, 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


 442      * applications that may or may not have a Main-Class manifest entry.
 443      */
 444     mainClass = LoadMainClass(env, mode, what);
 445     CHECK_EXCEPTION_NULL_LEAVE(mainClass);
 446     /*
 447      * In some cases when launching an application that needs a helper, e.g., a
 448      * JavaFX application with no main method, the mainClass will not be the
 449      * applications own main class but rather a helper class. To keep things
 450      * consistent in the UI we need to track and report the application main class.
 451      */
 452     appClass = GetApplicationClass(env);
 453     NULL_CHECK_RETURN_VALUE(appClass, -1);
 454     /*
 455      * PostJVMInit uses the class name as the application name for GUI purposes,
 456      * for example, on OSX this sets the application name in the menu bar for
 457      * both SWT and JavaFX. So we'll pass the actual application class here
 458      * instead of mainClass as that may be a launcher or helper class instead
 459      * of the application class.
 460      */
 461     PostJVMInit(env, appClass, vm);

 462     /*
 463      * The LoadMainClass not only loads the main class, it will also ensure
 464      * that the main method's signature is correct, therefore further checking
 465      * is not required. The main method is invoked here so that extraneous java
 466      * stacks are not in the application stack trace.
 467      */
 468     mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
 469                                        "([Ljava/lang/String;)V");
 470     CHECK_EXCEPTION_NULL_LEAVE(mainID);
 471 
 472     /* Build platform specific argument array */
 473     mainArgs = CreateApplicationArgs(env, argv, argc);
 474     CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
 475 
 476     /* Invoke main method. */
 477     (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
 478 
 479     /*
 480      * The launcher's exit code (in the absence of calls to
 481      * System.exit) will be non-zero if main threw an exception.


   1 /*
   2  * Copyright (c) 1995, 2015, 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


 442      * applications that may or may not have a Main-Class manifest entry.
 443      */
 444     mainClass = LoadMainClass(env, mode, what);
 445     CHECK_EXCEPTION_NULL_LEAVE(mainClass);
 446     /*
 447      * In some cases when launching an application that needs a helper, e.g., a
 448      * JavaFX application with no main method, the mainClass will not be the
 449      * applications own main class but rather a helper class. To keep things
 450      * consistent in the UI we need to track and report the application main class.
 451      */
 452     appClass = GetApplicationClass(env);
 453     NULL_CHECK_RETURN_VALUE(appClass, -1);
 454     /*
 455      * PostJVMInit uses the class name as the application name for GUI purposes,
 456      * for example, on OSX this sets the application name in the menu bar for
 457      * both SWT and JavaFX. So we'll pass the actual application class here
 458      * instead of mainClass as that may be a launcher or helper class instead
 459      * of the application class.
 460      */
 461     PostJVMInit(env, appClass, vm);
 462     CHECK_EXCEPTION_LEAVE(1);
 463     /*
 464      * The LoadMainClass not only loads the main class, it will also ensure
 465      * that the main method's signature is correct, therefore further checking
 466      * is not required. The main method is invoked here so that extraneous java
 467      * stacks are not in the application stack trace.
 468      */
 469     mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
 470                                        "([Ljava/lang/String;)V");
 471     CHECK_EXCEPTION_NULL_LEAVE(mainID);
 472 
 473     /* Build platform specific argument array */
 474     mainArgs = CreateApplicationArgs(env, argv, argc);
 475     CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
 476 
 477     /* Invoke main method. */
 478     (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
 479 
 480     /*
 481      * The launcher's exit code (in the absence of calls to
 482      * System.exit) will be non-zero if main threw an exception.


< prev index next >