< prev index next >

src/java.base/share/native/libjli/java.c

Print this page

        

@@ -433,11 +433,12 @@
     }
 
     ret = 1;
 
     /*
-     * Get the application's main class.
+     * Get the application's main class. It also checks if the main
+     * method exists.
      *
      * See bugid 5030265.  The Main-Class name has already been parsed
      * from the manifest, but not parsed properly for UTF-8 support.
      * Hence the code here ignores the value previously extracted and
      * uses the pre-existing code to reextract the value.  This is

@@ -465,45 +466,49 @@
      * applications own main class but rather a helper class. To keep things
      * consistent in the UI we need to track and report the application main class.
      */
     appClass = GetApplicationClass(env);
     NULL_CHECK_RETURN_VALUE(appClass, -1);
+
+    /* Build platform specific argument array */
+    mainArgs = CreateApplicationArgs(env, argv, argc);
+    CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
+
+    if (dryRun) {
+        ret = 0;
+        LEAVE();
+    }
+
     /*
      * PostJVMInit uses the class name as the application name for GUI purposes,
      * for example, on OSX this sets the application name in the menu bar for
      * both SWT and JavaFX. So we'll pass the actual application class here
      * instead of mainClass as that may be a launcher or helper class instead
      * of the application class.
      */
     PostJVMInit(env, appClass, vm);
     CHECK_EXCEPTION_LEAVE(1);
+
     /*
      * The LoadMainClass not only loads the main class, it will also ensure
      * that the main method's signature is correct, therefore further checking
      * is not required. The main method is invoked here so that extraneous java
      * stacks are not in the application stack trace.
      */
     mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
                                        "([Ljava/lang/String;)V");
     CHECK_EXCEPTION_NULL_LEAVE(mainID);
 
-    /* Build platform specific argument array */
-    mainArgs = CreateApplicationArgs(env, argv, argc);
-    CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
-
-    if (dryRun) {
-        ret = 0;
-    } else {
         /* Invoke main method. */
         (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
 
         /*
          * The launcher's exit code (in the absence of calls to
          * System.exit) will be non-zero if main threw an exception.
          */
         ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
-    }
+
     LEAVE();
 }
 
 /*
  * Test if the given option name has a whitespace separated argument.
< prev index next >