jdk/src/share/bin/java.c
changeset 13411 224a28370893
parent 12550 482c64a6f825
child 14518 f4b1adde53b3
equal deleted inserted replaced
13410:e667545511c7 13411:224a28370893
   102                                int *pmode, char **pwhat,
   102                                int *pmode, char **pwhat,
   103                                int *pret, const char *jrepath);
   103                                int *pret, const char *jrepath);
   104 static jboolean InitializeJVM(JavaVM **pvm, JNIEnv **penv,
   104 static jboolean InitializeJVM(JavaVM **pvm, JNIEnv **penv,
   105                               InvocationFunctions *ifn);
   105                               InvocationFunctions *ifn);
   106 static jstring NewPlatformString(JNIEnv *env, char *s);
   106 static jstring NewPlatformString(JNIEnv *env, char *s);
   107 static jobjectArray NewPlatformStringArray(JNIEnv *env, char **strv, int strc);
       
   108 static jclass LoadMainClass(JNIEnv *env, int mode, char *name);
   107 static jclass LoadMainClass(JNIEnv *env, int mode, char *name);
   109 
   108 
   110 static void TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***pargv);
   109 static void TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***pargv);
   111 static jboolean AddApplicationOptions(int cpathc, const char **cpathv);
   110 static jboolean AddApplicationOptions(int cpathc, const char **cpathv);
   112 static void SetApplicationClassPath(const char**);
   111 static void SetApplicationClassPath(const char**);
   158 
   157 
   159 /*
   158 /*
   160  * Running Java code in primordial thread caused many problems. We will
   159  * Running Java code in primordial thread caused many problems. We will
   161  * create a new thread to invoke JVM. See 6316197 for more information.
   160  * create a new thread to invoke JVM. See 6316197 for more information.
   162  */
   161  */
   163 static jlong threadStackSize = 0;  /* stack size of the new thread */
   162 static jlong threadStackSize    = 0;  /* stack size of the new thread */
   164 static jlong maxHeapSize        = 0;  /* max heap size */
   163 static jlong maxHeapSize        = 0;  /* max heap size */
   165 static jlong initialHeapSize    = 0;  /* inital heap size */
   164 static jlong initialHeapSize    = 0;  /* inital heap size */
   166 
   165 
   167 /*
   166 /*
   168  * Entry point.
   167  * Entry point.
   200     _wc_enabled = cpwildcard;
   199     _wc_enabled = cpwildcard;
   201     _ergo_policy = ergo;
   200     _ergo_policy = ergo;
   202 
   201 
   203     InitLauncher(javaw);
   202     InitLauncher(javaw);
   204     DumpState();
   203     DumpState();
       
   204     if (JLI_IsTraceLauncher()) {
       
   205         int i;
       
   206         printf("Command line args:\n");
       
   207         for (i = 0; i < argc ; i++) {
       
   208             printf("argv[%d] = %s\n", i, argv[i]);
       
   209         }
       
   210         AddOption("-Dsun.java.launcher.diag=true", NULL);
       
   211     }
   205 
   212 
   206     /*
   213     /*
   207      * Make sure the specified version of the JRE is running.
   214      * Make sure the specified version of the JRE is running.
   208      *
   215      *
   209      * There are three things to note about the SelectVersion() routine:
   216      * There are three things to note about the SelectVersion() routine:
   219      *     price to pay for not processing a jar file operand twice.
   226      *     price to pay for not processing a jar file operand twice.
   220      *     (Note: This side effect has been disabled.  See comment on
   227      *     (Note: This side effect has been disabled.  See comment on
   221      *     bugid 5030265 below.)
   228      *     bugid 5030265 below.)
   222      */
   229      */
   223     SelectVersion(argc, argv, &main_class);
   230     SelectVersion(argc, argv, &main_class);
   224 
       
   225     if (JLI_IsTraceLauncher()) {
       
   226         int i;
       
   227         printf("Command line args:\n");
       
   228         for (i = 0; i < argc ; i++) {
       
   229             printf("argv[%d] = %s\n", i, argv[i]);
       
   230         }
       
   231         AddOption("-Dsun.java.launcher.diag=true", NULL);
       
   232     }
       
   233 
   231 
   234     CreateExecutionEnvironment(&argc, &argv,
   232     CreateExecutionEnvironment(&argc, &argv,
   235                                jrepath, sizeof(jrepath),
   233                                jrepath, sizeof(jrepath),
   236                                jvmpath, sizeof(jvmpath),
   234                                jvmpath, sizeof(jvmpath),
   237                                jvmcfg,  sizeof(jvmcfg));
   235                                jvmcfg,  sizeof(jvmcfg));
   433      */
   431      */
   434     mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
   432     mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
   435                                        "([Ljava/lang/String;)V");
   433                                        "([Ljava/lang/String;)V");
   436     CHECK_EXCEPTION_NULL_LEAVE(mainID);
   434     CHECK_EXCEPTION_NULL_LEAVE(mainID);
   437 
   435 
   438     /* Build argument array */
   436     /* Build platform specific argument array */
   439     mainArgs = NewPlatformStringArray(env, argv, argc);
   437     mainArgs = CreateApplicationArgs(env, argv, argc);
   440     CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
   438     CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
   441 
   439 
   442     /* Invoke main method. */
   440     /* Invoke main method. */
   443     (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
   441     (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
   444 
   442 
  1118     return r == JNI_OK;
  1116     return r == JNI_OK;
  1119 }
  1117 }
  1120 
  1118 
  1121 static jclass helperClass = NULL;
  1119 static jclass helperClass = NULL;
  1122 
  1120 
  1123 static jclass
  1121 jclass
  1124 GetLauncherHelperClass(JNIEnv *env) {
  1122 GetLauncherHelperClass(JNIEnv *env)
       
  1123 {
  1125     if (helperClass == NULL) {
  1124     if (helperClass == NULL) {
  1126         NULL_CHECK0(helperClass = FindBootStrapClass(env,
  1125         NULL_CHECK0(helperClass = FindBootStrapClass(env,
  1127                 "sun/launcher/LauncherHelper"));
  1126                 "sun/launcher/LauncherHelper"));
  1128     }
  1127     }
  1129     return helperClass;
  1128     return helperClass;
  1163 
  1162 
  1164 /*
  1163 /*
  1165  * Returns a new array of Java string objects for the specified
  1164  * Returns a new array of Java string objects for the specified
  1166  * array of platform strings.
  1165  * array of platform strings.
  1167  */
  1166  */
  1168 static jobjectArray
  1167 jobjectArray
  1169 NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
  1168 NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
  1170 {
  1169 {
  1171     jarray cls;
  1170     jarray cls;
  1172     jarray ary;
  1171     jarray ary;
  1173     int i;
  1172     int i;
  1208 
  1207 
  1209     if (JLI_IsTraceLauncher()) {
  1208     if (JLI_IsTraceLauncher()) {
  1210         end   = CounterGet();
  1209         end   = CounterGet();
  1211         printf("%ld micro seconds to load main class\n",
  1210         printf("%ld micro seconds to load main class\n",
  1212                (long)(jint)Counter2Micros(end-start));
  1211                (long)(jint)Counter2Micros(end-start));
  1213         printf("----_JAVA_LAUNCHER_DEBUG----\n");
  1212         printf("----%s----\n", JLDEBUG_ENV_ENTRY);
  1214     }
  1213     }
  1215 
  1214 
  1216     return (jclass)result;
  1215     return (jclass)result;
  1217 }
  1216 }
  1218 
  1217 
  1743         knownVMs[i].name = NULL;
  1742         knownVMs[i].name = NULL;
  1744     }
  1743     }
  1745     JLI_MemFree(knownVMs);
  1744     JLI_MemFree(knownVMs);
  1746 }
  1745 }
  1747 
  1746 
  1748 
       
  1749 /*
  1747 /*
  1750  * Displays the splash screen according to the jar file name
  1748  * Displays the splash screen according to the jar file name
  1751  * and image file names stored in environment variables
  1749  * and image file names stored in environment variables
  1752  */
  1750  */
  1753 void
  1751 void