--- old/src/java.desktop/unix/native/common/awt/awt_util.h 2016-07-08 16:31:44.058642920 +0530 +++ new/src/java.desktop/unix/native/common/awt/awt_util.h 2016-07-08 16:31:43.826642920 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -80,7 +80,7 @@ int32_t echoC; }; -extern jboolean awtJNI_ThreadYield(JNIEnv *env); +extern jboolean awtJNI_ThreadYield(JNIEnv *env, jclass threadClass, jmethodID yieldMethodID); /* * Functions for accessing fields by name and signature --- old/src/java.desktop/unix/native/libawt_xawt/awt/awt_util.c 2016-07-08 16:31:44.642642920 +0530 +++ new/src/java.desktop/unix/native/libawt_xawt/awt/awt_util.c 2016-07-08 16:31:44.390642920 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -62,38 +62,7 @@ #endif jboolean -awtJNI_ThreadYield(JNIEnv *env) { - - static jclass threadClass = NULL; - static jmethodID yieldMethodID = NULL; - - /* Initialize our java identifiers once. Checking before locking - * is a huge performance win. - */ - if (threadClass == NULL) { - // should enter a monitor here... - Boolean err = FALSE; - if (threadClass == NULL) { - jclass tc = (*env)->FindClass(env, "java/lang/Thread"); - CHECK_NULL_RETURN(tc, JNI_FALSE); - threadClass = (*env)->NewGlobalRef(env, tc); - (*env)->DeleteLocalRef(env, tc); - if (threadClass != NULL) { - yieldMethodID = (*env)->GetStaticMethodID(env, - threadClass, - "yield", - "()V" - ); - } - } - if (yieldMethodID == NULL) { - threadClass = NULL; - err = TRUE; - } - if (err) { - return JNI_FALSE; - } - } /* threadClass == NULL*/ +awtJNI_ThreadYield(JNIEnv *env, jclass threadClass, jmethodID yieldMethodID) { (*env)->CallStaticVoidMethod(env, threadClass, yieldMethodID); DASSERT(!((*env)->ExceptionOccurred(env))); @@ -101,4 +70,4 @@ return JNI_FALSE; } return JNI_TRUE; -} /* awtJNI_ThreadYield() */ +} --- old/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c 2016-07-08 16:31:45.226642920 +0530 +++ new/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c 2016-07-08 16:31:45.002642920 +0530 @@ -1,5 +1,5 @@ /* - * 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 @@ -52,6 +52,9 @@ uint32_t awt_NumLockMask = 0; Boolean awt_ModLockIsShiftLock = False; +jclass threadClass = NULL; +jmethodID yieldMethodID = NULL; + static int32_t num_buttons = 0; int32_t getNumButtons(); @@ -112,6 +115,16 @@ 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); } /* @@ -692,7 +705,7 @@ /* 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; } }