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 /*
954 * Clears all errors caused by getCanonicalName() on the mainclass and
955 * leaves the JAVA_MAIN_CLASS__<pid> empty.
956 */
957 (*env)->ExceptionClear(env);
958 return;
959 }
960
961 const char *mainClassName = NULL;
962 NULL_CHECK(mainClassName = (*env)->GetStringUTFChars(env, mainClassString, NULL));
963
964 char envVar[80];
965 /*
966 * The JAVA_MAIN_CLASS_<pid> environment variable is used to pass
967 * the name of a Java class whose main() method is invoked by
968 * the Java launcher code to start the application, to the AWT code
969 * in order to assign the name to the Apple menu bar when the app
970 * is active on the Mac.
971 * The _<pid> part is added to avoid collisions with child processes.
972 *
973 * WARNING: This environment variable is an implementation detail and
974 * isn't meant for use outside of the core platform. The mechanism for
975 * passing this information from Java launcher to other modules may
976 * change drastically between update release, and it may even be
977 * removed or replaced with another mechanism.
978 *
979 * NOTE: It is used by SWT, and JavaFX.
1046 int rslt;
1047 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1048 {
1049 JavaLaunchHelper* launcher = [[[JavaLaunchHelper alloc] init] autorelease];
1050 [launcher performSelectorOnMainThread:@selector(launchJava:)
1051 withObject:[NSValue valueWithPointer:(void*)&args]
1052 waitUntilDone:YES];
1053 rslt = [launcher getReturnValue];
1054 }
1055 [pool drain];
1056 return rslt;
1057 } else {
1058 return ContinueInNewThread(ifn, threadStackSize, argc, argv, mode, what, ret);
1059 }
1060 }
1061
1062 /*
1063 * Note the jvmInstance must be initialized first before entering into
1064 * ShowSplashScreen, as there is a callback into the JLI_GetJavaVMInstance.
1065 */
1066 void PostJVMInit(JNIEnv *env, jclass mainClass, JavaVM *vm) {
1067 jvmInstance = vm;
1068 SetMainClassForAWT(env, mainClass);
1069 CHECK_EXCEPTION_RETURN();
1070 ShowSplashScreen();
1071 }
1072
1073 jboolean
1074 ProcessPlatformOption(const char* arg)
1075 {
1076 if (JLI_StrCmp(arg, "-XstartOnFirstThread") == 0) {
1077 SetXStartOnFirstThreadArg();
1078 return JNI_TRUE;
1079 } else if (JLI_StrCCmp(arg, "-Xdock:") == 0) {
1080 SetXDockArgForAWT(arg);
1081 return JNI_TRUE;
1082 }
1083 // arguments we know not
1084 return JNI_FALSE;
1085 }
|