214 } |
214 } |
215 AddOption("-Dsun.java.launcher.diag=true", NULL); |
215 AddOption("-Dsun.java.launcher.diag=true", NULL); |
216 } |
216 } |
217 |
217 |
218 /* |
218 /* |
219 * Make sure the specified version of the JRE is running. |
219 * SelectVersion() has several responsibilities: |
220 * |
220 * |
221 * There are three things to note about the SelectVersion() routine: |
221 * 1) Disallow specification of another JRE. With 1.9, another |
222 * 1) If the version running isn't correct, this routine doesn't |
222 * version of the JRE cannot be invoked. |
223 * return (either the correct version has been exec'd or an error |
223 * 2) Allow for a JRE version to invoke JDK 1.9 or later. Since |
224 * was issued). |
224 * all mJRE directives have been stripped from the request but |
225 * 2) Argc and Argv in this scope are *not* altered by this routine. |
225 * the pre 1.9 JRE [ 1.6 thru 1.8 ], it is as if 1.9+ has been |
226 * It is the responsibility of subsequent code to ignore the |
226 * invoked from the command line. |
227 * arguments handled by this routine. |
|
228 * 3) As a side-effect, the variable "main_class" is guaranteed to |
|
229 * be set (if it should ever be set). This isn't exactly the |
|
230 * poster child for structured programming, but it is a small |
|
231 * price to pay for not processing a jar file operand twice. |
|
232 * (Note: This side effect has been disabled. See comment on |
|
233 * bugid 5030265 below.) |
|
234 */ |
227 */ |
235 SelectVersion(argc, argv, &main_class); |
228 SelectVersion(argc, argv, &main_class); |
236 |
229 |
237 CreateExecutionEnvironment(&argc, &argv, |
230 CreateExecutionEnvironment(&argc, &argv, |
238 jrepath, sizeof(jrepath), |
231 jrepath, sizeof(jrepath), |
847 /* |
838 /* |
848 * If the version has already been selected, set *main_class |
839 * If the version has already been selected, set *main_class |
849 * with the value passed through the environment (if any) and |
840 * with the value passed through the environment (if any) and |
850 * simply return. |
841 * simply return. |
851 */ |
842 */ |
|
843 |
|
844 /* |
|
845 * This environmental variable can be set by mJRE capable JREs |
|
846 * [ 1.5 thru 1.8 ]. All other aspects of mJRE processing have been |
|
847 * stripped by those JREs. This environmental variable allows 1.9+ |
|
848 * JREs to be started by these mJRE capable JREs. |
|
849 * Note that mJRE directives in the jar manifest file would have been |
|
850 * ignored for a JRE started by another JRE... |
|
851 * .. skipped for JRE 1.5 and beyond. |
|
852 * .. not even checked for pre 1.5. |
|
853 */ |
852 if ((env_in = getenv(ENV_ENTRY)) != NULL) { |
854 if ((env_in = getenv(ENV_ENTRY)) != NULL) { |
853 if (*env_in != '\0') |
855 if (*env_in != '\0') |
854 *main_class = JLI_StringDup(env_in); |
856 *main_class = JLI_StringDup(env_in); |
855 return; |
857 return; |
856 } |
858 } |
857 |
859 |
858 /* |
860 /* |
859 * Scan through the arguments for options relevant to multiple JRE |
861 * Scan through the arguments for options relevant to multiple JRE |
860 * support. For reference, the command line syntax is defined as: |
862 * support. Multiple JRE support existed in JRE versions 1.5 thru 1.8. |
861 * |
863 * |
862 * SYNOPSIS |
864 * This capability is no longer available with JRE versions 1.9 and later. |
863 * java [options] class [argument...] |
865 * These command line options are reported as errors. |
864 * |
|
865 * java [options] -jar file.jar [argument...] |
|
866 * |
|
867 * As the scan is performed, make a copy of the argument list with |
|
868 * the version specification options (new to 1.5) removed, so that |
|
869 * a version less than 1.5 can be exec'd. |
|
870 * |
|
871 * Note that due to the syntax of the native Windows interface |
|
872 * CreateProcess(), processing similar to the following exists in |
|
873 * the Windows platform specific routine ExecJRE (in java_md.c). |
|
874 * Changes here should be reproduced there. |
|
875 */ |
866 */ |
876 new_argv = JLI_MemAlloc((argc + 1) * sizeof(char*)); |
|
877 new_argv[0] = argv[0]; |
|
878 new_argp = &new_argv[1]; |
|
879 argc--; |
867 argc--; |
880 argv++; |
868 argv++; |
881 while ((arg = *argv) != 0 && *arg == '-') { |
869 while ((arg = *argv) != 0 && *arg == '-') { |
882 if (JLI_StrCCmp(arg, "-version:") == 0) { |
870 if (JLI_StrCCmp(arg, "-version:") == 0) { |
883 version = arg + 9; |
871 JLI_ReportErrorMessage(SPC_ERROR1); |
884 } else if (JLI_StrCmp(arg, "-jre-restrict-search") == 0) { |
872 } else if (JLI_StrCmp(arg, "-jre-restrict-search") == 0) { |
885 restrict_search = 1; |
873 JLI_ReportErrorMessage(SPC_ERROR2); |
886 } else if (JLI_StrCmp(arg, "-no-jre-restrict-search") == 0) { |
874 } else if (JLI_StrCmp(arg, "-jre-no-restrict-search") == 0) { |
887 restrict_search = 0; |
875 JLI_ReportErrorMessage(SPC_ERROR2); |
888 } else { |
876 } else { |
889 if (JLI_StrCmp(arg, "-jar") == 0) |
877 if (JLI_StrCmp(arg, "-jar") == 0) |
890 jarflag = 1; |
878 jarflag = 1; |
891 /* deal with "unfortunate" classpath syntax */ |
879 /* deal with "unfortunate" classpath syntax */ |
892 if ((JLI_StrCmp(arg, "-classpath") == 0 || JLI_StrCmp(arg, "-cp") == 0) && |
880 if ((JLI_StrCmp(arg, "-classpath") == 0 || JLI_StrCmp(arg, "-cp") == 0) && |
893 (argc >= 2)) { |
881 (argc >= 2)) { |
894 *new_argp++ = arg; |
|
895 argc--; |
882 argc--; |
896 argv++; |
883 argv++; |
897 arg = *argv; |
884 arg = *argv; |
898 } |
885 } |
899 |
886 |
906 } else if (JLI_StrCCmp(arg, "-Djava.awt.headless=") == 0) { |
893 } else if (JLI_StrCCmp(arg, "-Djava.awt.headless=") == 0) { |
907 headlessflag = 0; |
894 headlessflag = 0; |
908 } else if (JLI_StrCCmp(arg, "-splash:") == 0) { |
895 } else if (JLI_StrCCmp(arg, "-splash:") == 0) { |
909 splash_file_name = arg+8; |
896 splash_file_name = arg+8; |
910 } |
897 } |
911 *new_argp++ = arg; |
|
912 } |
898 } |
913 argc--; |
899 argc--; |
914 argv++; |
900 argv++; |
915 } |
901 } |
916 if (argc <= 0) { /* No operand? Possibly legit with -[full]version */ |
902 if (argc <= 0) { /* No operand? Possibly legit with -[full]version */ |
917 operand = NULL; |
903 operand = NULL; |
918 } else { |
904 } else { |
919 argc--; |
905 argc--; |
920 *new_argp++ = operand = *argv++; |
906 operand = *argv++; |
921 } |
907 } |
922 while (argc-- > 0) /* Copy over [argument...] */ |
|
923 *new_argp++ = *argv++; |
|
924 *new_argp = NULL; |
|
925 |
908 |
926 /* |
909 /* |
927 * If there is a jar file, read the manifest. If the jarfile can't be |
910 * If there is a jar file, read the manifest. If the jarfile can't be |
928 * read, the manifest can't be read from the jar file, or the manifest |
911 * read, the manifest can't be read from the jar file, or the manifest |
929 * is corrupt, issue the appropriate error messages and exit. |
912 * is corrupt, issue the appropriate error messages and exit. |
972 JLI_StrCpy(splash_jar_entry, SPLASH_JAR_ENV_ENTRY "="); |
955 JLI_StrCpy(splash_jar_entry, SPLASH_JAR_ENV_ENTRY "="); |
973 JLI_StrCat(splash_jar_entry, splash_jar_name); |
956 JLI_StrCat(splash_jar_entry, splash_jar_name); |
974 putenv(splash_jar_entry); |
957 putenv(splash_jar_entry); |
975 } |
958 } |
976 |
959 |
977 /* |
|
978 * The JRE-Version and JRE-Restrict-Search values (if any) from the |
|
979 * manifest are overwritten by any specified on the command line. |
|
980 */ |
|
981 if (version != NULL) |
|
982 info.jre_version = version; |
|
983 if (restrict_search != -1) |
|
984 info.jre_restrict_search = restrict_search; |
|
985 |
960 |
986 /* |
961 /* |
987 * "Valid" returns (other than unrecoverable errors) follow. Set |
962 * "Valid" returns (other than unrecoverable errors) follow. Set |
988 * main_class as a side-effect of this routine. |
963 * main_class as a side-effect of this routine. |
989 */ |
964 */ |
990 if (info.main_class != NULL) |
965 if (info.main_class != NULL) |
991 *main_class = JLI_StringDup(info.main_class); |
966 *main_class = JLI_StringDup(info.main_class); |
992 |
967 |
993 /* |
|
994 * If no version selection information is found either on the command |
|
995 * line or in the manifest, simply return. |
|
996 */ |
|
997 if (info.jre_version == NULL) { |
968 if (info.jre_version == NULL) { |
998 JLI_FreeManifest(); |
969 JLI_FreeManifest(); |
999 JLI_MemFree(new_argv); |
|
1000 return; |
970 return; |
1001 } |
971 } |
1002 |
972 |
1003 /* |
|
1004 * Check for correct syntax of the version specification (JSR 56). |
|
1005 */ |
|
1006 if (!JLI_ValidVersionString(info.jre_version)) { |
|
1007 JLI_ReportErrorMessage(SPC_ERROR1, info.jre_version); |
|
1008 exit(1); |
|
1009 } |
|
1010 |
|
1011 /* |
|
1012 * Find the appropriate JVM on the system. Just to be as forgiving as |
|
1013 * possible, if the standard algorithms don't locate an appropriate |
|
1014 * jre, check to see if the one running will satisfy the requirements. |
|
1015 * This can happen on systems which haven't been set-up for multiple |
|
1016 * JRE support. |
|
1017 */ |
|
1018 jre = LocateJRE(&info); |
|
1019 JLI_TraceLauncher("JRE-Version = %s, JRE-Restrict-Search = %s Selected = %s\n", |
|
1020 (info.jre_version?info.jre_version:"null"), |
|
1021 (info.jre_restrict_search?"true":"false"), (jre?jre:"null")); |
|
1022 |
|
1023 if (jre == NULL) { |
|
1024 if (JLI_AcceptableRelease(GetFullVersion(), info.jre_version)) { |
|
1025 JLI_FreeManifest(); |
|
1026 JLI_MemFree(new_argv); |
|
1027 return; |
|
1028 } else { |
|
1029 JLI_ReportErrorMessage(CFG_ERROR4, info.jre_version); |
|
1030 exit(1); |
|
1031 } |
|
1032 } |
|
1033 |
|
1034 /* |
|
1035 * If I'm not the chosen one, exec the chosen one. Returning from |
|
1036 * ExecJRE indicates that I am indeed the chosen one. |
|
1037 * |
|
1038 * The private environment variable _JAVA_VERSION_SET is used to |
|
1039 * prevent the chosen one from re-reading the manifest file and |
|
1040 * using the values found within to override the (potential) command |
|
1041 * line flags stripped from argv (because the target may not |
|
1042 * understand them). Passing the MainClass value is an optimization |
|
1043 * to avoid locating, expanding and parsing the manifest extra |
|
1044 * times. |
|
1045 */ |
|
1046 if (info.main_class != NULL) { |
|
1047 if (JLI_StrLen(info.main_class) <= MAXNAMELEN) { |
|
1048 (void)JLI_StrCat(env_entry, info.main_class); |
|
1049 } else { |
|
1050 JLI_ReportErrorMessage(CLS_ERROR5, MAXNAMELEN); |
|
1051 exit(1); |
|
1052 } |
|
1053 } |
|
1054 (void)putenv(env_entry); |
|
1055 ExecJRE(jre, new_argv); |
|
1056 JLI_FreeManifest(); |
|
1057 JLI_MemFree(new_argv); |
|
1058 return; |
|
1059 } |
973 } |
1060 |
974 |
1061 /* |
975 /* |
1062 * Parses command line arguments. Returns JNI_FALSE if launcher |
976 * Parses command line arguments. Returns JNI_FALSE if launcher |
1063 * should exit without starting vm, returns JNI_TRUE if vm needs |
977 * should exit without starting vm, returns JNI_TRUE if vm needs |
1152 } else if (JLI_StrCmp(arg, "-checksource") == 0 || |
1066 } else if (JLI_StrCmp(arg, "-checksource") == 0 || |
1153 JLI_StrCmp(arg, "-cs") == 0 || |
1067 JLI_StrCmp(arg, "-cs") == 0 || |
1154 JLI_StrCmp(arg, "-noasyncgc") == 0) { |
1068 JLI_StrCmp(arg, "-noasyncgc") == 0) { |
1155 /* No longer supported */ |
1069 /* No longer supported */ |
1156 JLI_ReportErrorMessage(ARG_WARN, arg); |
1070 JLI_ReportErrorMessage(ARG_WARN, arg); |
1157 } else if (JLI_StrCCmp(arg, "-version:") == 0 || |
1071 } else if (JLI_StrCCmp(arg, "-splash:") == 0) { |
1158 JLI_StrCmp(arg, "-no-jre-restrict-search") == 0 || |
|
1159 JLI_StrCmp(arg, "-jre-restrict-search") == 0 || |
|
1160 JLI_StrCCmp(arg, "-splash:") == 0) { |
|
1161 ; /* Ignore machine independent options already handled */ |
1072 ; /* Ignore machine independent options already handled */ |
1162 } else if (ProcessPlatformOption(arg)) { |
1073 } else if (ProcessPlatformOption(arg)) { |
1163 ; /* Processing of platform dependent options */ |
1074 ; /* Processing of platform dependent options */ |
1164 } else if (RemovableOption(arg)) { |
1075 } else if (RemovableOption(arg)) { |
1165 ; /* Do not pass option to vm. */ |
1076 ; /* Do not pass option to vm. */ |