< prev index next >

src/java.base/share/native/launcher/main.c

Print this page
rev 17323 : [mq]: 8180334-00.patch

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -83,10 +83,12 @@
 int WINAPI
 WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
 {
     int margc;
     char** margv;
+    int jargc;
+    char** jargv;
     const jboolean const_javaw = JNI_TRUE;
 
     __initenv = _environ;
 
 #else /* JAVAW */

@@ -93,15 +95,49 @@
 int
 main(int argc, char **argv)
 {
     int margc;
     char** margv;
+    int jargc;
+    char** jargv;
     const jboolean const_javaw = JNI_FALSE;
 #endif /* JAVAW */
+    {
+        int i, main_jargc, extra_jargc;
+        JLI_List list;
 
-    JLI_InitArgProcessing(!HAS_JAVA_ARGS, const_disable_argfile);
+        main_jargc = (sizeof(const_jargs) / sizeof(char *)) > 1
+            ? sizeof(const_jargs) / sizeof(char *)
+            : 0; // ignore the null terminator index
 
+        extra_jargc = (sizeof(const_extra_jargs) / sizeof(char *)) > 1
+            ? sizeof(const_extra_jargs) / sizeof(char *)
+            : 0; // ignore the null terminator index
+
+        if (main_jargc > 0 && extra_jargc > 0) { // combine extra java args
+            jargc = main_jargc + extra_jargc;
+            list = JLI_List_new(jargc + 1);
+
+            for (i = 0 ; i < extra_jargc; i++) {
+                JLI_List_add(list, JLI_StringDup(const_extra_jargs[i]));
+            }
+
+            for (i = 0 ; i < main_jargc ; i++) {
+                JLI_List_add(list, JLI_StringDup(const_jargs[i]));
+            }
+
+            // terminate the list
+            JLI_List_add(list, NULL);
+            jargv = list->elements;
+         } else { // no extra args, business as usual
+            jargc = main_jargc;
+            jargv = (char **) const_jargs;
+         }
+    }
+
+    JLI_InitArgProcessing(jargc > 0, const_disable_argfile);
+
 #ifdef _WIN32
     {
         int i = 0;
         if (getenv(JLDEBUG_ENV_ENTRY) != NULL) {
             printf("Windows original main args:\n");

@@ -162,14 +198,14 @@
         JLI_List_add(args, NULL);
         margv = args->elements;
     }
 #endif /* WIN32 */
     return JLI_Launch(margc, margv,
-                   sizeof(const_jargs) / sizeof(char *), const_jargs,
+                   jargc, (const char**) jargv,
                    0, NULL,
                    VERSION_STRING,
                    DOT_VERSION,
                    (const_progname != NULL) ? const_progname : *margv,
                    (const_launcher != NULL) ? const_launcher : *margv,
-                   HAS_JAVA_ARGS,
+                   jargc > 0,
                    const_cpwildcard, const_javaw, 0);
 }
< prev index next >