提交 e20a87d0 编写于 作者: A anthony

7174704: [macosx] New issue in 7u6 b12: HeadlessPrintingTest failure

Summary: Load the lwawt native library on Mac regardless of the headless/headful mode. Also, some minor cleanup.
Reviewed-by: art, serb
上级 676fd12a
......@@ -227,7 +227,7 @@ static void AWT_NSUncaughtExceptionHandler(NSException *exception) {
id jrsAppKitAWTClass = objc_getClass("JRSAppKitAWT");
SEL markAppSel = @selector(markAppIsDaemon);
if (![jrsAppKitAWTClass respondsToSelector:markAppSel]) return NO;
return (BOOL)[jrsAppKitAWTClass performSelector:markAppSel];
return [jrsAppKitAWTClass performSelector:markAppSel] ? YES : NO;
}
+ (void)appKitIsRunning:(id)arg {
......@@ -337,6 +337,8 @@ AWT_ASSERT_APPKIT_THREAD;
// Headless mode trumps either ordinary AWT or SWT-in-AWT mode. Declare us a daemon and return.
if (headless) {
// Note that we don't install run loop observers in headless mode
// because we don't need them (see 7174704)
if (!forceEmbeddedMode) {
setUpAppKitThreadName();
}
......
......@@ -79,10 +79,8 @@ JNIEXPORT jboolean JNICALL AWTIsHeadless() {
#ifdef MACOSX
#define XAWT_PATH "/libawt_xawt.dylib"
#define LWAWT_PATH "/libawt_lwawt.dylib"
#define DEFAULT_PATH LWAWT_PATH
#define HEADLESS_PATH "/libawt_headless.dylib"
#else
#define XAWT_PATH "/libawt_xawt.so"
#define DEFAULT_PATH XAWT_PATH
......@@ -100,11 +98,6 @@ AWT_OnLoad(JavaVM *vm, void *reserved)
struct utsname name;
JNIEnv *env = (JNIEnv *)JNU_GetEnv(vm, JNI_VERSION_1_2);
void *v;
char *envvar;
int xt_before_xm = 0;
int XAWT = 0;
jstring toolkit = NULL;
jstring propname = NULL;
jstring fmanager = NULL;
jstring fmProp = NULL;
......@@ -124,56 +117,32 @@ AWT_OnLoad(JavaVM *vm, void *reserved)
/*
* The code below is responsible for:
* 1. Loading appropriate awt library, i.e. libawt_xawt or libawt_headless
* 2. Setting "awt.toolkit" system property to use the appropriate Java toolkit class,
* (if user has specified the toolkit in env varialble)
* 2. Set the "sun.font.fontmanager" system property.
*/
propname = (*env)->NewStringUTF(env, "awt.toolkit");
fmProp = (*env)->NewStringUTF(env, "sun.font.fontmanager");
tk = DEFAULT_PATH; /* default value, may be changed below */
/* Check if toolkit is specified in env variable */
envvar = getenv("AWT_TOOLKIT");
if (envvar && (strstr(envvar, "XToolkit"))) {
toolkit = (*env)->NewStringUTF(env, "sun.awt.X11.XToolkit");
tk = XAWT_PATH;
fmanager = (*env)->NewStringUTF(env, "sun.awt.X11FontManager");
#ifdef MACOSX
} else {
fmanager = (*env)->NewStringUTF(env, "sun.font.CFontManager");
tk = LWAWT_PATH;
#else
fmanager = (*env)->NewStringUTF(env, "sun.awt.X11FontManager");
tk = XAWT_PATH;
#endif
}
/* If user specified toolkit then set java system property */
if (toolkit && propname) {
JNU_CallStaticMethodByName (env,
NULL,
"java/lang/System",
"setProperty",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
propname,toolkit);
}
if (fmanager && fmProp) {
JNU_CallStaticMethodByName (env,
NULL,
"java/lang/System",
"setProperty",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
fmProp, fmanager);
JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "setProperty",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
fmProp, fmanager);
}
/* Calculate library name to load */
#ifndef MACOSX
if (AWTIsHeadless()) {
tk = HEADLESS_PATH;
}
#endif
/* Calculate library name to load */
strncpy(p, tk, MAXPATHLEN-len-1);
if (toolkit) {
(*env)->DeleteLocalRef(env, toolkit);
}
if (propname) {
(*env)->DeleteLocalRef(env, propname);
}
if (fmProp) {
(*env)->DeleteLocalRef(env, fmProp);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册