src/java.base/macosx/native/libjli/java_md_macosx.c

Print this page




 931          * isn't meant for use outside of the core platform. The mechanism for
 932          * passing this information from Java launcher to other modules may
 933          * change drastically between update release, and it may even be
 934          * removed or replaced with another mechanism.
 935          *
 936          * NOTE: It is used by SWT, and JavaFX.
 937          */
 938         snprintf(envVar, sizeof(envVar), "APP_ICON_%d", getpid());
 939         setenv(envVar, (arg + 12), 1);
 940     }
 941 }
 942 
 943 static void
 944 SetMainClassForAWT(JNIEnv *env, jclass mainClass) {
 945     jclass classClass = NULL;
 946     NULL_CHECK(classClass = FindBootStrapClass(env, "java/lang/Class"));
 947 
 948     jmethodID getCanonicalNameMID = NULL;
 949     NULL_CHECK(getCanonicalNameMID = (*env)->GetMethodID(env, classClass, "getCanonicalName", "()Ljava/lang/String;"));
 950 
 951     jstring mainClassString = NULL;
 952     NULL_CHECK(mainClassString = (*env)->CallObjectMethod(env, mainClass, getCanonicalNameMID));



 953 
 954     const char *mainClassName = NULL;
 955     NULL_CHECK(mainClassName = (*env)->GetStringUTFChars(env, mainClassString, NULL));
 956 
 957     char envVar[80];
 958     /*
 959      * The JAVA_MAIN_CLASS_<pid> environment variable is used to pass
 960      * the name of a Java class whose main() method is invoked by
 961      * the Java launcher code to start the application, to the AWT code
 962      * in order to assign the name to the Apple menu bar when the app
 963      * is active on the Mac.
 964      * The _<pid> part is added to avoid collisions with child processes.
 965      *
 966      * WARNING: This environment variable is an implementation detail and
 967      * isn't meant for use outside of the core platform. The mechanism for
 968      * passing this information from Java launcher to other modules may
 969      * change drastically between update release, and it may even be
 970      * removed or replaced with another mechanism.
 971      *
 972      * NOTE: It is used by SWT, and JavaFX.


1039         int rslt;
1040         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1041         {
1042             JavaLaunchHelper* launcher = [[[JavaLaunchHelper alloc] init] autorelease];
1043             [launcher performSelectorOnMainThread:@selector(launchJava:)
1044                                        withObject:[NSValue valueWithPointer:(void*)&args]
1045                                     waitUntilDone:YES];
1046             rslt = [launcher getReturnValue];
1047         }
1048         [pool drain];
1049         return rslt;
1050     } else {
1051         return ContinueInNewThread(ifn, threadStackSize, argc, argv, mode, what, ret);
1052     }
1053 }
1054 
1055 /*
1056  * Note the jvmInstance must be initialized first before entering into
1057  * ShowSplashScreen, as there is a callback into the JLI_GetJavaVMInstance.
1058  */
1059 void PostJVMInit(JNIEnv *env, jstring mainClass, JavaVM *vm) {
1060     jvmInstance = vm;
1061     SetMainClassForAWT(env, mainClass);
1062     CHECK_EXCEPTION_RETURN();
1063     ShowSplashScreen();
1064 }
1065 
1066 jboolean
1067 ProcessPlatformOption(const char* arg)
1068 {
1069     if (JLI_StrCmp(arg, "-XstartOnFirstThread") == 0) {
1070        SetXStartOnFirstThreadArg();
1071        return JNI_TRUE;
1072     } else if (JLI_StrCCmp(arg, "-Xdock:") == 0) {
1073        SetXDockArgForAWT(arg);
1074        return JNI_TRUE;
1075     }
1076     // arguments we know not
1077     return JNI_FALSE;
1078 }


 931          * isn't meant for use outside of the core platform. The mechanism for
 932          * passing this information from Java launcher to other modules may
 933          * change drastically between update release, and it may even be
 934          * removed or replaced with another mechanism.
 935          *
 936          * NOTE: It is used by SWT, and JavaFX.
 937          */
 938         snprintf(envVar, sizeof(envVar), "APP_ICON_%d", getpid());
 939         setenv(envVar, (arg + 12), 1);
 940     }
 941 }
 942 
 943 static void
 944 SetMainClassForAWT(JNIEnv *env, jclass mainClass) {
 945     jclass classClass = NULL;
 946     NULL_CHECK(classClass = FindBootStrapClass(env, "java/lang/Class"));
 947 
 948     jmethodID getCanonicalNameMID = NULL;
 949     NULL_CHECK(getCanonicalNameMID = (*env)->GetMethodID(env, classClass, "getCanonicalName", "()Ljava/lang/String;"));
 950 
 951     jstring mainClassString = (*env)->CallObjectMethod(env, mainClass, getCanonicalNameMID);
 952     if ((*env)->ExceptionCheck(env)) {
 953         (*env)->ExceptionClear(env);
 954         return;
 955     }
 956 
 957     const char *mainClassName = NULL;
 958     NULL_CHECK(mainClassName = (*env)->GetStringUTFChars(env, mainClassString, NULL));
 959 
 960     char envVar[80];
 961     /*
 962      * The JAVA_MAIN_CLASS_<pid> environment variable is used to pass
 963      * the name of a Java class whose main() method is invoked by
 964      * the Java launcher code to start the application, to the AWT code
 965      * in order to assign the name to the Apple menu bar when the app
 966      * is active on the Mac.
 967      * The _<pid> part is added to avoid collisions with child processes.
 968      *
 969      * WARNING: This environment variable is an implementation detail and
 970      * isn't meant for use outside of the core platform. The mechanism for
 971      * passing this information from Java launcher to other modules may
 972      * change drastically between update release, and it may even be
 973      * removed or replaced with another mechanism.
 974      *
 975      * NOTE: It is used by SWT, and JavaFX.


1042         int rslt;
1043         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1044         {
1045             JavaLaunchHelper* launcher = [[[JavaLaunchHelper alloc] init] autorelease];
1046             [launcher performSelectorOnMainThread:@selector(launchJava:)
1047                                        withObject:[NSValue valueWithPointer:(void*)&args]
1048                                     waitUntilDone:YES];
1049             rslt = [launcher getReturnValue];
1050         }
1051         [pool drain];
1052         return rslt;
1053     } else {
1054         return ContinueInNewThread(ifn, threadStackSize, argc, argv, mode, what, ret);
1055     }
1056 }
1057 
1058 /*
1059  * Note the jvmInstance must be initialized first before entering into
1060  * ShowSplashScreen, as there is a callback into the JLI_GetJavaVMInstance.
1061  */
1062 void PostJVMInit(JNIEnv *env, jclass mainClass, JavaVM *vm) {
1063     jvmInstance = vm;
1064     SetMainClassForAWT(env, mainClass);
1065     CHECK_EXCEPTION_RETURN();
1066     ShowSplashScreen();
1067 }
1068 
1069 jboolean
1070 ProcessPlatformOption(const char* arg)
1071 {
1072     if (JLI_StrCmp(arg, "-XstartOnFirstThread") == 0) {
1073        SetXStartOnFirstThreadArg();
1074        return JNI_TRUE;
1075     } else if (JLI_StrCCmp(arg, "-Xdock:") == 0) {
1076        SetXDockArgForAWT(arg);
1077        return JNI_TRUE;
1078     }
1079     // arguments we know not
1080     return JNI_FALSE;
1081 }