< prev index next >

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

Print this page




1500 NewPlatformString(JNIEnv *env, char *s)
1501 {
1502     int len = (int)JLI_StrLen(s);
1503     jbyteArray ary;
1504     jclass cls = GetLauncherHelperClass(env);
1505     NULL_CHECK0(cls);
1506     if (s == NULL)
1507         return 0;
1508 
1509     ary = (*env)->NewByteArray(env, len);
1510     if (ary != 0) {
1511         jstring str = 0;
1512         (*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s);
1513         if (!(*env)->ExceptionOccurred(env)) {
1514             if (makePlatformStringMID == NULL) {
1515                 NULL_CHECK0(makePlatformStringMID = (*env)->GetStaticMethodID(env,
1516                         cls, "makePlatformString", "(Z[B)Ljava/lang/String;"));
1517             }
1518             str = (*env)->CallStaticObjectMethod(env, cls,
1519                     makePlatformStringMID, USE_STDERR, ary);

1520             (*env)->DeleteLocalRef(env, ary);
1521             return str;
1522         }
1523     }
1524     return 0;
1525 }
1526 
1527 /*
1528  * Returns a new array of Java string objects for the specified
1529  * array of platform strings.
1530  */
1531 jobjectArray
1532 NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
1533 {
1534     jarray cls;
1535     jarray ary;
1536     int i;
1537 
1538     NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String"));
1539     NULL_CHECK0(ary = (*env)->NewObjectArray(env, strc, cls, 0));


1568                 "(ZILjava/lang/String;)Ljava/lang/Class;"));
1569 
1570     NULL_CHECK0(str = NewPlatformString(env, name));
1571     NULL_CHECK0(result = (*env)->CallStaticObjectMethod(env, cls, mid,
1572                                                         USE_STDERR, mode, str));
1573 
1574     if (JLI_IsTraceLauncher()) {
1575         end   = CounterGet();
1576         printf("%ld micro seconds to load main class\n",
1577                (long)(jint)Counter2Micros(end-start));
1578         printf("----%s----\n", JLDEBUG_ENV_ENTRY);
1579     }
1580 
1581     return (jclass)result;
1582 }
1583 
1584 static jclass
1585 GetApplicationClass(JNIEnv *env)
1586 {
1587     jmethodID mid;

1588     jclass cls = GetLauncherHelperClass(env);
1589     NULL_CHECK0(cls);
1590     NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls,
1591                 "getApplicationClass",
1592                 "()Ljava/lang/Class;"));
1593 
1594     return (*env)->CallStaticObjectMethod(env, cls, mid);


1595 }
1596 
1597 static char* expandWildcardOnLongOpt(char* arg) {
1598     char *p, *value;
1599     size_t optLen, valueLen;
1600     p = JLI_StrChr(arg, '=');
1601 
1602     if (p == NULL || p[1] == '\0') {
1603         JLI_ReportErrorMessage(ARG_ERROR1, arg);
1604         exit(1);
1605     }
1606     p++;
1607     value = (char *) JLI_WildcardExpandClasspath(p);
1608     if (p == value) {
1609         // no wildcard
1610         return arg;
1611     }
1612 
1613     optLen = p - arg;
1614     valueLen = JLI_StrLen(value);




1500 NewPlatformString(JNIEnv *env, char *s)
1501 {
1502     int len = (int)JLI_StrLen(s);
1503     jbyteArray ary;
1504     jclass cls = GetLauncherHelperClass(env);
1505     NULL_CHECK0(cls);
1506     if (s == NULL)
1507         return 0;
1508 
1509     ary = (*env)->NewByteArray(env, len);
1510     if (ary != 0) {
1511         jstring str = 0;
1512         (*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s);
1513         if (!(*env)->ExceptionOccurred(env)) {
1514             if (makePlatformStringMID == NULL) {
1515                 NULL_CHECK0(makePlatformStringMID = (*env)->GetStaticMethodID(env,
1516                         cls, "makePlatformString", "(Z[B)Ljava/lang/String;"));
1517             }
1518             str = (*env)->CallStaticObjectMethod(env, cls,
1519                     makePlatformStringMID, USE_STDERR, ary);
1520             CHECK_EXCEPTION_RETURN_VALUE(0);
1521             (*env)->DeleteLocalRef(env, ary);
1522             return str;
1523         }
1524     }
1525     return 0;
1526 }
1527 
1528 /*
1529  * Returns a new array of Java string objects for the specified
1530  * array of platform strings.
1531  */
1532 jobjectArray
1533 NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
1534 {
1535     jarray cls;
1536     jarray ary;
1537     int i;
1538 
1539     NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String"));
1540     NULL_CHECK0(ary = (*env)->NewObjectArray(env, strc, cls, 0));


1569                 "(ZILjava/lang/String;)Ljava/lang/Class;"));
1570 
1571     NULL_CHECK0(str = NewPlatformString(env, name));
1572     NULL_CHECK0(result = (*env)->CallStaticObjectMethod(env, cls, mid,
1573                                                         USE_STDERR, mode, str));
1574 
1575     if (JLI_IsTraceLauncher()) {
1576         end   = CounterGet();
1577         printf("%ld micro seconds to load main class\n",
1578                (long)(jint)Counter2Micros(end-start));
1579         printf("----%s----\n", JLDEBUG_ENV_ENTRY);
1580     }
1581 
1582     return (jclass)result;
1583 }
1584 
1585 static jclass
1586 GetApplicationClass(JNIEnv *env)
1587 {
1588     jmethodID mid;
1589     jclass appClass;
1590     jclass cls = GetLauncherHelperClass(env);
1591     NULL_CHECK0(cls);
1592     NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls,
1593                 "getApplicationClass",
1594                 "()Ljava/lang/Class;"));
1595 
1596     appClass = (*env)->CallStaticObjectMethod(env, cls, mid);
1597     CHECK_EXCEPTION_RETURN_VALUE(0);
1598     return appClass;
1599 }
1600 
1601 static char* expandWildcardOnLongOpt(char* arg) {
1602     char *p, *value;
1603     size_t optLen, valueLen;
1604     p = JLI_StrChr(arg, '=');
1605 
1606     if (p == NULL || p[1] == '\0') {
1607         JLI_ReportErrorMessage(ARG_ERROR1, arg);
1608         exit(1);
1609     }
1610     p++;
1611     value = (char *) JLI_WildcardExpandClasspath(p);
1612     if (p == value) {
1613         // no wildcard
1614         return arg;
1615     }
1616 
1617     optLen = p - arg;
1618     valueLen = JLI_StrLen(value);


< prev index next >