< prev index next >

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

Print this page




 224  */
 225 JNIEXPORT int JNICALL
 226 JLI_Launch(int argc, char ** argv,              /* main argc, argv */
 227         int jargc, const char** jargv,          /* java args */
 228         int appclassc, const char** appclassv,  /* app classpath */
 229         const char* fullversion,                /* full version defined */
 230         const char* dotversion,                 /* UNUSED dot version defined */
 231         const char* pname,                      /* program name */
 232         const char* lname,                      /* launcher name */
 233         jboolean javaargs,                      /* JAVA_ARGS */
 234         jboolean cpwildcard,                    /* classpath wildcard*/
 235         jboolean javaw,                         /* windows-only javaw */
 236         jint ergo                               /* unused */
 237 )
 238 {
 239     int mode = LM_UNKNOWN;
 240     char *what = NULL;
 241     char *main_class = NULL;
 242     int ret;
 243     InvocationFunctions ifn;
 244     jlong start, end;
 245     char jvmpath[MAXPATHLEN];
 246     char jrepath[MAXPATHLEN];
 247     char jvmcfg[MAXPATHLEN];
 248 
 249     _fVersion = fullversion;
 250     _launcher_name = lname;
 251     _program_name = pname;
 252     _is_java_args = javaargs;
 253     _wc_enabled = cpwildcard;
 254 
 255     InitLauncher(javaw);
 256     DumpState();
 257     if (JLI_IsTraceLauncher()) {
 258         int i;
 259         printf("Java args:\n");
 260         for (i = 0; i < jargc ; i++) {
 261             printf("jargv[%d] = %s\n", i, jargv[i]);
 262         }
 263         printf("Command line args:\n");
 264         for (i = 0; i < argc ; i++) {


 391     } while (JNI_FALSE)
 392 
 393 
 394 int
 395 JavaMain(void* _args)
 396 {
 397     JavaMainArgs *args = (JavaMainArgs *)_args;
 398     int argc = args->argc;
 399     char **argv = args->argv;
 400     int mode = args->mode;
 401     char *what = args->what;
 402     InvocationFunctions ifn = args->ifn;
 403 
 404     JavaVM *vm = 0;
 405     JNIEnv *env = 0;
 406     jclass mainClass = NULL;
 407     jclass appClass = NULL; // actual application class being launched
 408     jmethodID mainID;
 409     jobjectArray mainArgs;
 410     int ret = 0;
 411     jlong start, end;
 412 
 413     RegisterThread();
 414 
 415     /* Initialize the virtual machine */
 416     start = CounterGet();
 417     if (!InitializeJVM(&vm, &env, &ifn)) {
 418         JLI_ReportErrorMessage(JVM_ERROR1);
 419         exit(1);
 420     }
 421 
 422     if (showSettings != NULL) {
 423         ShowSettings(env, showSettings);
 424         CHECK_EXCEPTION_LEAVE(1);
 425     }
 426 
 427     // show resolved modules and continue
 428     if (showResolvedModules) {
 429         ShowResolvedModules(env);
 430         CHECK_EXCEPTION_LEAVE(1);
 431     }


1601     CHECK_EXCEPTION_RETURN_VALUE(0);
1602     for (i = 0; i < strc; i++) {
1603         jstring str = NewPlatformString(env, *strv++);
1604         NULL_CHECK0(str);
1605         (*env)->SetObjectArrayElement(env, ary, i, str);
1606         (*env)->DeleteLocalRef(env, str);
1607     }
1608     return ary;
1609 }
1610 
1611 /*
1612  * Loads a class and verifies that the main class is present and it is ok to
1613  * call it for more details refer to the java implementation.
1614  */
1615 static jclass
1616 LoadMainClass(JNIEnv *env, int mode, char *name)
1617 {
1618     jmethodID mid;
1619     jstring str;
1620     jobject result;
1621     jlong start, end;
1622     jclass cls = GetLauncherHelperClass(env);
1623     NULL_CHECK0(cls);
1624     if (JLI_IsTraceLauncher()) {
1625         start = CounterGet();
1626     }
1627     NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls,
1628                 "checkAndLoadMain",
1629                 "(ZILjava/lang/String;)Ljava/lang/Class;"));
1630 
1631     NULL_CHECK0(str = NewPlatformString(env, name));
1632     NULL_CHECK0(result = (*env)->CallStaticObjectMethod(env, cls, mid,
1633                                                         USE_STDERR, mode, str));
1634 
1635     if (JLI_IsTraceLauncher()) {
1636         end   = CounterGet();
1637         printf("%ld micro seconds to load main class\n",
1638                (long)(jint)Counter2Micros(end-start));
1639         printf("----%s----\n", JLDEBUG_ENV_ENTRY);
1640     }
1641 


2063  *   otherwise the identifier of the first flag is used as the name of the JVM.
2064  * If no flag is given on the command line, the first vmLine of the jvm.cfg
2065  * file determines the name of the JVM.
2066  * PredicateLines are only interpreted on first vmLine of a jvm.cfg file,
2067  * since they only make sense if someone hasn't specified the name of the
2068  * JVM on the command line.
2069  *
2070  * The intent of the jvm.cfg file is to allow several JVM libraries to
2071  * be installed in different subdirectories of a single JRE installation,
2072  * for space-savings and convenience in testing.
2073  * The intent is explicitly not to provide a full aliasing or predicate
2074  * mechanism.
2075  */
2076 jint
2077 ReadKnownVMs(const char *jvmCfgName, jboolean speculative)
2078 {
2079     FILE *jvmCfg;
2080     char line[MAXPATHLEN+20];
2081     int cnt = 0;
2082     int lineno = 0;
2083     jlong start, end;
2084     int vmType;
2085     char *tmpPtr;
2086     char *altVMName = NULL;
2087     char *serverClassVMName = NULL;
2088     static char *whiteSpace = " \t";
2089     if (JLI_IsTraceLauncher()) {
2090         start = CounterGet();
2091     }
2092 
2093     jvmCfg = fopen(jvmCfgName, "r");
2094     if (jvmCfg == NULL) {
2095       if (!speculative) {
2096         JLI_ReportErrorMessage(CFG_ERROR6, jvmCfgName);
2097         exit(1);
2098       } else {
2099         return -1;
2100       }
2101     }
2102     while (fgets(line, sizeof(line), jvmCfg) != NULL) {
2103         vmType = VM_UNKNOWN;




 224  */
 225 JNIEXPORT int JNICALL
 226 JLI_Launch(int argc, char ** argv,              /* main argc, argv */
 227         int jargc, const char** jargv,          /* java args */
 228         int appclassc, const char** appclassv,  /* app classpath */
 229         const char* fullversion,                /* full version defined */
 230         const char* dotversion,                 /* UNUSED dot version defined */
 231         const char* pname,                      /* program name */
 232         const char* lname,                      /* launcher name */
 233         jboolean javaargs,                      /* JAVA_ARGS */
 234         jboolean cpwildcard,                    /* classpath wildcard*/
 235         jboolean javaw,                         /* windows-only javaw */
 236         jint ergo                               /* unused */
 237 )
 238 {
 239     int mode = LM_UNKNOWN;
 240     char *what = NULL;
 241     char *main_class = NULL;
 242     int ret;
 243     InvocationFunctions ifn;
 244     jlong start = 0, end = 0;
 245     char jvmpath[MAXPATHLEN];
 246     char jrepath[MAXPATHLEN];
 247     char jvmcfg[MAXPATHLEN];
 248 
 249     _fVersion = fullversion;
 250     _launcher_name = lname;
 251     _program_name = pname;
 252     _is_java_args = javaargs;
 253     _wc_enabled = cpwildcard;
 254 
 255     InitLauncher(javaw);
 256     DumpState();
 257     if (JLI_IsTraceLauncher()) {
 258         int i;
 259         printf("Java args:\n");
 260         for (i = 0; i < jargc ; i++) {
 261             printf("jargv[%d] = %s\n", i, jargv[i]);
 262         }
 263         printf("Command line args:\n");
 264         for (i = 0; i < argc ; i++) {


 391     } while (JNI_FALSE)
 392 
 393 
 394 int
 395 JavaMain(void* _args)
 396 {
 397     JavaMainArgs *args = (JavaMainArgs *)_args;
 398     int argc = args->argc;
 399     char **argv = args->argv;
 400     int mode = args->mode;
 401     char *what = args->what;
 402     InvocationFunctions ifn = args->ifn;
 403 
 404     JavaVM *vm = 0;
 405     JNIEnv *env = 0;
 406     jclass mainClass = NULL;
 407     jclass appClass = NULL; // actual application class being launched
 408     jmethodID mainID;
 409     jobjectArray mainArgs;
 410     int ret = 0;
 411     jlong start, end = 0;
 412 
 413     RegisterThread();
 414 
 415     /* Initialize the virtual machine */
 416     start = CounterGet();
 417     if (!InitializeJVM(&vm, &env, &ifn)) {
 418         JLI_ReportErrorMessage(JVM_ERROR1);
 419         exit(1);
 420     }
 421 
 422     if (showSettings != NULL) {
 423         ShowSettings(env, showSettings);
 424         CHECK_EXCEPTION_LEAVE(1);
 425     }
 426 
 427     // show resolved modules and continue
 428     if (showResolvedModules) {
 429         ShowResolvedModules(env);
 430         CHECK_EXCEPTION_LEAVE(1);
 431     }


1601     CHECK_EXCEPTION_RETURN_VALUE(0);
1602     for (i = 0; i < strc; i++) {
1603         jstring str = NewPlatformString(env, *strv++);
1604         NULL_CHECK0(str);
1605         (*env)->SetObjectArrayElement(env, ary, i, str);
1606         (*env)->DeleteLocalRef(env, str);
1607     }
1608     return ary;
1609 }
1610 
1611 /*
1612  * Loads a class and verifies that the main class is present and it is ok to
1613  * call it for more details refer to the java implementation.
1614  */
1615 static jclass
1616 LoadMainClass(JNIEnv *env, int mode, char *name)
1617 {
1618     jmethodID mid;
1619     jstring str;
1620     jobject result;
1621     jlong start = 0, end = 0;
1622     jclass cls = GetLauncherHelperClass(env);
1623     NULL_CHECK0(cls);
1624     if (JLI_IsTraceLauncher()) {
1625         start = CounterGet();
1626     }
1627     NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls,
1628                 "checkAndLoadMain",
1629                 "(ZILjava/lang/String;)Ljava/lang/Class;"));
1630 
1631     NULL_CHECK0(str = NewPlatformString(env, name));
1632     NULL_CHECK0(result = (*env)->CallStaticObjectMethod(env, cls, mid,
1633                                                         USE_STDERR, mode, str));
1634 
1635     if (JLI_IsTraceLauncher()) {
1636         end = CounterGet();
1637         printf("%ld micro seconds to load main class\n",
1638                (long)(jint)Counter2Micros(end-start));
1639         printf("----%s----\n", JLDEBUG_ENV_ENTRY);
1640     }
1641 


2063  *   otherwise the identifier of the first flag is used as the name of the JVM.
2064  * If no flag is given on the command line, the first vmLine of the jvm.cfg
2065  * file determines the name of the JVM.
2066  * PredicateLines are only interpreted on first vmLine of a jvm.cfg file,
2067  * since they only make sense if someone hasn't specified the name of the
2068  * JVM on the command line.
2069  *
2070  * The intent of the jvm.cfg file is to allow several JVM libraries to
2071  * be installed in different subdirectories of a single JRE installation,
2072  * for space-savings and convenience in testing.
2073  * The intent is explicitly not to provide a full aliasing or predicate
2074  * mechanism.
2075  */
2076 jint
2077 ReadKnownVMs(const char *jvmCfgName, jboolean speculative)
2078 {
2079     FILE *jvmCfg;
2080     char line[MAXPATHLEN+20];
2081     int cnt = 0;
2082     int lineno = 0;
2083     jlong start = 0, end = 0;
2084     int vmType;
2085     char *tmpPtr;
2086     char *altVMName = NULL;
2087     char *serverClassVMName = NULL;
2088     static char *whiteSpace = " \t";
2089     if (JLI_IsTraceLauncher()) {
2090         start = CounterGet();
2091     }
2092 
2093     jvmCfg = fopen(jvmCfgName, "r");
2094     if (jvmCfg == NULL) {
2095       if (!speculative) {
2096         JLI_ReportErrorMessage(CFG_ERROR6, jvmCfgName);
2097         exit(1);
2098       } else {
2099         return -1;
2100       }
2101     }
2102     while (fgets(line, sizeof(line), jvmCfg) != NULL) {
2103         vmType = VM_UNKNOWN;


< prev index next >