< prev index next >
src/java.desktop/unix/native/libawt_xawt/awt/awt_util.c
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1995, 2014, 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
--- 1,7 ----
/*
! * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 60,104 ****
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#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*/
(*env)->CallStaticVoidMethod(env, threadClass, yieldMethodID);
DASSERT(!((*env)->ExceptionOccurred(env)));
if ((*env)->ExceptionCheck(env)) {
return JNI_FALSE;
}
return JNI_TRUE;
! } /* awtJNI_ThreadYield() */
--- 60,73 ----
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
jboolean
! awtJNI_ThreadYield(JNIEnv *env, jclass threadClass, jmethodID yieldMethodID) {
(*env)->CallStaticVoidMethod(env, threadClass, yieldMethodID);
DASSERT(!((*env)->ExceptionOccurred(env)));
if ((*env)->ExceptionCheck(env)) {
return JNI_FALSE;
}
return JNI_TRUE;
! }
< prev index next >