< prev index next >
src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -50,10 +50,13 @@
#include <unistd.h>
uint32_t awt_NumLockMask = 0;
Boolean awt_ModLockIsShiftLock = False;
+jclass threadClass = NULL;
+jmethodID yieldMethodID = NULL;
+
static int32_t num_buttons = 0;
int32_t getNumButtons();
extern JavaVM *jvm;
@@ -110,10 +113,20 @@
awt_NumLockMask = (*env)->GetStaticIntField(env, clazz, fid);
DTRACE_PRINTLN1("awt_NumLockMask = %u", awt_NumLockMask);
fid = (*env)->GetStaticFieldID(env, clazz, "modLockIsShiftLock", "I");
CHECK_NULL(fid);
awt_ModLockIsShiftLock = (*env)->GetStaticIntField(env, clazz, fid) != 0 ? True : False;
+
+ jclass tc = (*env)->FindClass(env, "java/lang/Thread");
+ CHECK_NULL(tc);
+ threadClass = (*env)->NewGlobalRef(env, tc);
+ (*env)->DeleteLocalRef(env, tc);
+ if (threadClass != NULL) {
+ yieldMethodID = (*env)->GetStaticMethodID(env, threadClass,
+ "yield", "()V");
+ }
+ CHECK_NULL(yieldMethodID);
}
/*
* Class: sun_awt_X11_XToolkit
* Method: getTrayIconDisplayTimeout
@@ -690,11 +703,11 @@
AWT_NOFLUSH_UNLOCK();
/* ACTUALLY DO THE POLL() */
if (timeout == 0) {
// be sure other threads get a chance
- if (!awtJNI_ThreadYield(env)) {
+ if (!awtJNI_ThreadYield(env, threadClass, yieldMethodID)) {
return FALSE;
}
}
if (tracing) poll_sleep_time = awtJNI_TimeMillis();
< prev index next >