< prev index next >

src/java.base/windows/native/libjli/java_md.c

Print this page




  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
  23  * questions.
  24  */
  25 
  26 #include <windows.h>
  27 #include <io.h>
  28 #include <process.h>
  29 #include <stdlib.h>
  30 #include <stdio.h>
  31 #include <stdarg.h>
  32 #include <string.h>
  33 #include <sys/types.h>
  34 #include <sys/stat.h>
  35 #include <wtypes.h>
  36 #include <commctrl.h>

  37 
  38 #include <jni.h>
  39 #include "java.h"
  40 
  41 #define JVM_DLL "jvm.dll"
  42 #define JAVA_DLL "java.dll"
  43 
  44 /*
  45  * Prototypes.
  46  */
  47 static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
  48                            char *jvmpath, jint jvmpathsize);
  49 static jboolean GetJREPath(char *path, jint pathsize);
  50 
  51 #ifdef USE_REGISTRY_LOOKUP
  52 jboolean GetPublicJREHome(char *buf, jint bufsize);
  53 #endif
  54 
  55 /* We supports warmup for UI stack that is performed in parallel
  56  * to VM initialization.


 998     int isTool;
 999     jclass cls = GetLauncherHelperClass(env);
1000     NULL_CHECK0(cls);
1001 
1002     if (argc == 0) {
1003         return NewPlatformStringArray(env, strv, argc);
1004     }
1005     // the holy grail we need to compare with.
1006     stdargs = JLI_GetStdArgs();
1007     stdargc = JLI_GetStdArgc();
1008 
1009     // sanity check, this should never happen
1010     if (argc > stdargc) {
1011         JLI_TraceLauncher("Warning: app args is larger than the original, %d %d\n", argc, stdargc);
1012         JLI_TraceLauncher("passing arguments as-is.\n");
1013         return NewPlatformStringArray(env, strv, argc);
1014     }
1015 
1016     // sanity check, match the args we have, to the holy grail
1017     idx = JLI_GetAppArgIndex();











1018     isTool = (idx == 0);
1019     if (isTool) { idx++; } // skip tool name
1020     JLI_TraceLauncher("AppArgIndex: %d points to %s\n", idx, stdargs[idx].arg);
1021 
1022     appArgIdx = calloc(argc, sizeof(int));
1023     for (i = idx, j = 0; i < stdargc; i++) {
1024         if (isTool) { // filter -J used by tools to pass JVM options
1025             arg = stdargs[i].arg;
1026             if (arg[0] == '-' && arg[1] == 'J') {
1027                 continue;
1028             }
1029         }
1030         appArgIdx[j++] = i;
1031     }
1032     // sanity check, ensure same number of arguments for application
1033     if (j != argc) {
1034         JLI_TraceLauncher("Warning: app args count doesn't match, %d %d\n", j, argc);
1035         JLI_TraceLauncher("passing arguments as-is.\n");
1036         JLI_MemFree(appArgIdx);
1037         return NewPlatformStringArray(env, strv, argc);




  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
  23  * questions.
  24  */
  25 
  26 #include <windows.h>
  27 #include <io.h>
  28 #include <process.h>
  29 #include <stdlib.h>
  30 #include <stdio.h>
  31 #include <stdarg.h>
  32 #include <string.h>
  33 #include <sys/types.h>
  34 #include <sys/stat.h>
  35 #include <wtypes.h>
  36 #include <commctrl.h>
  37 #include <assert.h>
  38 
  39 #include <jni.h>
  40 #include "java.h"
  41 
  42 #define JVM_DLL "jvm.dll"
  43 #define JAVA_DLL "java.dll"
  44 
  45 /*
  46  * Prototypes.
  47  */
  48 static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
  49                            char *jvmpath, jint jvmpathsize);
  50 static jboolean GetJREPath(char *path, jint pathsize);
  51 
  52 #ifdef USE_REGISTRY_LOOKUP
  53 jboolean GetPublicJREHome(char *buf, jint bufsize);
  54 #endif
  55 
  56 /* We supports warmup for UI stack that is performed in parallel
  57  * to VM initialization.


 999     int isTool;
1000     jclass cls = GetLauncherHelperClass(env);
1001     NULL_CHECK0(cls);
1002 
1003     if (argc == 0) {
1004         return NewPlatformStringArray(env, strv, argc);
1005     }
1006     // the holy grail we need to compare with.
1007     stdargs = JLI_GetStdArgs();
1008     stdargc = JLI_GetStdArgc();
1009 
1010     // sanity check, this should never happen
1011     if (argc > stdargc) {
1012         JLI_TraceLauncher("Warning: app args is larger than the original, %d %d\n", argc, stdargc);
1013         JLI_TraceLauncher("passing arguments as-is.\n");
1014         return NewPlatformStringArray(env, strv, argc);
1015     }
1016 
1017     // sanity check, match the args we have, to the holy grail
1018     idx = JLI_GetAppArgIndex();
1019 
1020     // First arg index is NOT_FOUND
1021     if (idx < 0) {
1022         // The only allowed value should be NOT_FOUND (-1) unless another change introduces
1023         // a different negative index
1024         assert (idx == -1);
1025         JLI_TraceLauncher("Warning: first app arg index not found, %d\n", idx);
1026         JLI_TraceLauncher("passing arguments as-is.\n");
1027         return NewPlatformStringArray(env, strv, argc);
1028     }
1029 
1030     isTool = (idx == 0);
1031     if (isTool) { idx++; } // skip tool name
1032     JLI_TraceLauncher("AppArgIndex: %d points to %s\n", idx, stdargs[idx].arg);
1033 
1034     appArgIdx = calloc(argc, sizeof(int));
1035     for (i = idx, j = 0; i < stdargc; i++) {
1036         if (isTool) { // filter -J used by tools to pass JVM options
1037             arg = stdargs[i].arg;
1038             if (arg[0] == '-' && arg[1] == 'J') {
1039                 continue;
1040             }
1041         }
1042         appArgIdx[j++] = i;
1043     }
1044     // sanity check, ensure same number of arguments for application
1045     if (j != argc) {
1046         JLI_TraceLauncher("Warning: app args count doesn't match, %d %d\n", j, argc);
1047         JLI_TraceLauncher("passing arguments as-is.\n");
1048         JLI_MemFree(appArgIdx);
1049         return NewPlatformStringArray(env, strv, argc);


< prev index next >