src/macosx/bin/java_md_macosx.c

Print this page




 889  * Note there is a callback on this function from the splashscreen logic,
 890  * this as well SetJavaVMValue() needs to be simplified.
 891  */
 892 JavaVM*
 893 JLI_GetJavaVMInstance()
 894 {
 895     return jvmInstance;
 896 }
 897 
 898 void
 899 RegisterThread()
 900 {
 901     objc_registerThreadWithCollector();
 902 }
 903 
 904 static void
 905 SetXDockArgForAWT(const char *arg)
 906 {
 907     char envVar[80];
 908     if (strstr(arg, "-Xdock:name=") == arg) {















 909         snprintf(envVar, sizeof(envVar), "APP_NAME_%d", getpid());
 910         setenv(envVar, (arg + 12), 1);
 911     }
 912 
 913     if (strstr(arg, "-Xdock:icon=") == arg) {















 914         snprintf(envVar, sizeof(envVar), "APP_ICON_%d", getpid());
 915         setenv(envVar, (arg + 12), 1);
 916     }
 917 }
 918 
 919 static void
 920 SetMainClassForAWT(JNIEnv *env, jclass mainClass) {
 921     jclass classClass = NULL;
 922     NULL_CHECK(classClass = FindBootStrapClass(env, "java/lang/Class"));
 923 
 924     jmethodID getCanonicalNameMID = NULL;
 925     NULL_CHECK(getCanonicalNameMID = (*env)->GetMethodID(env, classClass, "getCanonicalName", "()Ljava/lang/String;"));
 926 
 927     jstring mainClassString = NULL;
 928     NULL_CHECK(mainClassString = (*env)->CallObjectMethod(env, mainClass, getCanonicalNameMID));
 929 
 930     const char *mainClassName = NULL;
 931     NULL_CHECK(mainClassName = (*env)->GetStringUTFChars(env, mainClassString, NULL));
 932 
 933     char envVar[80];
















 934     snprintf(envVar, sizeof(envVar), "JAVA_MAIN_CLASS_%d", getpid());
 935     setenv(envVar, mainClassName, 1);
 936 
 937     (*env)->ReleaseStringUTFChars(env, mainClassString, mainClassName);
 938 }
 939 
 940 void
 941 SetXStartOnFirstThreadArg()
 942 {
 943     // XXX: BEGIN HACK
 944     // short circuit hack for <https://bugs.eclipse.org/bugs/show_bug.cgi?id=211625>
 945     // need a way to get AWT/Swing apps launched when spawned from Eclipse,
 946     // which currently has no UI to not pass the -XstartOnFirstThread option
 947     if (getenv("HACK_IGNORE_START_ON_FIRST_THREAD") != NULL) return;
 948     // XXX: END HACK
 949 
 950     sameThread = JNI_TRUE;
 951     // Set a variable that tells us we started on the main thread.
 952     // This is used by the AWT during startup. (See awt.m)
 953     char envVar[80];




 889  * Note there is a callback on this function from the splashscreen logic,
 890  * this as well SetJavaVMValue() needs to be simplified.
 891  */
 892 JavaVM*
 893 JLI_GetJavaVMInstance()
 894 {
 895     return jvmInstance;
 896 }
 897 
 898 void
 899 RegisterThread()
 900 {
 901     objc_registerThreadWithCollector();
 902 }
 903 
 904 static void
 905 SetXDockArgForAWT(const char *arg)
 906 {
 907     char envVar[80];
 908     if (strstr(arg, "-Xdock:name=") == arg) {
 909         /*
 910          * The APP_NAME_<pid> environment variable is used to pass
 911          * an application name as specified with the -Xdock:name command
 912          * line option from Java launcher code to the AWT code in order
 913          * to assign this name to the app's dock tile on the Mac.
 914          * The _<pid> part is added to avoid collisions with child processes.
 915          *
 916          * WARNING: This environment variable is an implementation detail and
 917          * isn't meant for use outside of the core platform. The mechanism for
 918          * passing this information from Java launcher to other modules may
 919          * change drastically between update release, and it may even be
 920          * removed or replaced with another mechanism.
 921          *
 922          * NOTE: It is used by SWT, and JavaFX.
 923          */
 924         snprintf(envVar, sizeof(envVar), "APP_NAME_%d", getpid());
 925         setenv(envVar, (arg + 12), 1);
 926     }
 927 
 928     if (strstr(arg, "-Xdock:icon=") == arg) {
 929         /*
 930          * The APP_ICON_<pid> environment variable is used to pass
 931          * an application icon as specified with the -Xdock:icon command
 932          * line option from Java launcher code to the AWT code in order
 933          * to assign this icon to the app's dock tile on the Mac.
 934          * The _<pid> part is added to avoid collisions with child processes.
 935          *
 936          * WARNING: This environment variable is an implementation detail and
 937          * isn't meant for use outside of the core platform. The mechanism for
 938          * passing this information from Java launcher to other modules may
 939          * change drastically between update release, and it may even be
 940          * removed or replaced with another mechanism.
 941          *
 942          * NOTE: It is used by SWT, and JavaFX.
 943          */
 944         snprintf(envVar, sizeof(envVar), "APP_ICON_%d", getpid());
 945         setenv(envVar, (arg + 12), 1);
 946     }
 947 }
 948 
 949 static void
 950 SetMainClassForAWT(JNIEnv *env, jclass mainClass) {
 951     jclass classClass = NULL;
 952     NULL_CHECK(classClass = FindBootStrapClass(env, "java/lang/Class"));
 953 
 954     jmethodID getCanonicalNameMID = NULL;
 955     NULL_CHECK(getCanonicalNameMID = (*env)->GetMethodID(env, classClass, "getCanonicalName", "()Ljava/lang/String;"));
 956 
 957     jstring mainClassString = NULL;
 958     NULL_CHECK(mainClassString = (*env)->CallObjectMethod(env, mainClass, getCanonicalNameMID));
 959 
 960     const char *mainClassName = NULL;
 961     NULL_CHECK(mainClassName = (*env)->GetStringUTFChars(env, mainClassString, NULL));
 962 
 963     char envVar[80];
 964     /*
 965      * The JAVA_MAIN_CLASS_<pid> environment variable is used to pass
 966      * the name of a Java class whose main() method is invoked by
 967      * the Java launcher code to start the application, to the AWT code
 968      * in order to assign the name to the Apple menu bar when the app
 969      * is active on the Mac.
 970      * The _<pid> part is added to avoid collisions with child processes.
 971      *
 972      * WARNING: This environment variable is an implementation detail and
 973      * isn't meant for use outside of the core platform. The mechanism for
 974      * passing this information from Java launcher to other modules may
 975      * change drastically between update release, and it may even be
 976      * removed or replaced with another mechanism.
 977      *
 978      * NOTE: It is used by SWT, and JavaFX.
 979      */
 980     snprintf(envVar, sizeof(envVar), "JAVA_MAIN_CLASS_%d", getpid());
 981     setenv(envVar, mainClassName, 1);
 982 
 983     (*env)->ReleaseStringUTFChars(env, mainClassString, mainClassName);
 984 }
 985 
 986 void
 987 SetXStartOnFirstThreadArg()
 988 {
 989     // XXX: BEGIN HACK
 990     // short circuit hack for <https://bugs.eclipse.org/bugs/show_bug.cgi?id=211625>
 991     // need a way to get AWT/Swing apps launched when spawned from Eclipse,
 992     // which currently has no UI to not pass the -XstartOnFirstThread option
 993     if (getenv("HACK_IGNORE_START_ON_FIRST_THREAD") != NULL) return;
 994     // XXX: END HACK
 995 
 996     sameThread = JNI_TRUE;
 997     // Set a variable that tells us we started on the main thread.
 998     // This is used by the AWT during startup. (See awt.m)
 999     char envVar[80];