src/macosx/native/sun/awt/awt.m

Print this page




 418     jint status = (*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_4);
 419     if (status != JNI_OK || env == NULL) {
 420         AWT_DEBUG_LOG(@"Can't get JNIEnv");
 421         return JNI_VERSION_1_4;
 422     }
 423 
 424 JNF_COCOA_ENTER(env);
 425 
 426     // Launcher sets this env variable if -XstartOnFirstThread is specified
 427     char envVar[80];
 428     snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid());
 429     if (getenv(envVar) != NULL) {
 430         forceEmbeddedMode = YES;
 431         unsetenv(envVar);
 432     }
 433 
 434     if (isSWTInWebStart(env)) {
 435         forceEmbeddedMode = YES;
 436     }
 437     JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
 438     jclass jc_ThreadGroupUtils = (*env)->FindClass(env, "sun/misc/ThreadGroupUtils");
 439     jmethodID sjm_getRootThreadGroup = (*env)->GetStaticMethodID(env, jc_ThreadGroupUtils, "getRootThreadGroup", "()Ljava/lang/ThreadGroup;");
 440     jobject rootThreadGroup = (*env)->CallStaticObjectMethod(env, jc_ThreadGroupUtils, sjm_getRootThreadGroup);
 441     [ThreadUtilities setAppkitThreadGroup:(*env)->NewGlobalRef(env, rootThreadGroup)];
 442     // The current thread was attached in getJNIEnvUnchached.
 443     // Detach it back. It will be reattached later if needed with a proper TG
 444     [ThreadUtilities detachCurrentThread];
 445 
 446     BOOL headless = isHeadless(env);
 447 
 448     // We need to let Foundation know that this is a multithreaded application, if it isn't already.
 449     if (![NSThread isMultiThreaded]) {
 450         [NSThread detachNewThreadSelector:nil toTarget:nil withObject:nil];
 451     }
 452 
 453     [AWTStarter start:headless];
 454 
 455 JNF_COCOA_EXIT(env);
 456 
 457     if (verbose) AWT_DEBUG_LOG(@"exiting JNI_OnLoad");
 458 


 418     jint status = (*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_4);
 419     if (status != JNI_OK || env == NULL) {
 420         AWT_DEBUG_LOG(@"Can't get JNIEnv");
 421         return JNI_VERSION_1_4;
 422     }
 423 
 424 JNF_COCOA_ENTER(env);
 425 
 426     // Launcher sets this env variable if -XstartOnFirstThread is specified
 427     char envVar[80];
 428     snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid());
 429     if (getenv(envVar) != NULL) {
 430         forceEmbeddedMode = YES;
 431         unsetenv(envVar);
 432     }
 433 
 434     if (isSWTInWebStart(env)) {
 435         forceEmbeddedMode = YES;
 436     }
 437     JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
 438     jclass jc_ThreadGroupUtils = (*env)->FindClass(env, "sun/awt/util/ThreadGroupUtils");
 439     jmethodID sjm_getRootThreadGroup = (*env)->GetStaticMethodID(env, jc_ThreadGroupUtils, "getRootThreadGroup", "()Ljava/lang/ThreadGroup;");
 440     jobject rootThreadGroup = (*env)->CallStaticObjectMethod(env, jc_ThreadGroupUtils, sjm_getRootThreadGroup);
 441     [ThreadUtilities setAppkitThreadGroup:(*env)->NewGlobalRef(env, rootThreadGroup)];
 442     // The current thread was attached in getJNIEnvUnchached.
 443     // Detach it back. It will be reattached later if needed with a proper TG
 444     [ThreadUtilities detachCurrentThread];
 445 
 446     BOOL headless = isHeadless(env);
 447 
 448     // We need to let Foundation know that this is a multithreaded application, if it isn't already.
 449     if (![NSThread isMultiThreaded]) {
 450         [NSThread detachNewThreadSelector:nil toTarget:nil withObject:nil];
 451     }
 452 
 453     [AWTStarter start:headless];
 454 
 455 JNF_COCOA_EXIT(env);
 456 
 457     if (verbose) AWT_DEBUG_LOG(@"exiting JNI_OnLoad");
 458