< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/LockingThreads.cpp

Print this page
rev 51840 : [mq]: refactor


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 #include <jni.h>
  24 #include "jni_tools.h"
  25 
  26 extern "C" {
  27 
  28 #define FIND_CLASS(_class, _className)\
  29         if (!NSK_JNI_VERIFY(env, (_class = \
  30              NSK_CPP_STUB2(FindClass, env, _className)) != NULL))\
  31                 return
  32 
  33 #define GET_OBJECT_CLASS(_class, _obj)\
  34         if (!NSK_JNI_VERIFY(env, (_class = \
  35              NSK_CPP_STUB2(GetObjectClass, env, _obj)) != NULL))\
  36                 return
  37 
  38 #define GET_OBJ_FIELD(_value, _obj, _class, _fieldName, _fieldSig)\
  39         GET_FIELD_ID(field, _class, _fieldName, _fieldSig);\
  40         _value = NSK_CPP_STUB3(GetObjectField, env, _obj, field)
  41 
  42 #define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\
  43         if (!NSK_JNI_VERIFY(env, (_fieldID = \
  44              NSK_CPP_STUB4(GetFieldID, env, _class,\
  45              _fieldName, _fieldSig)) != NULL))\
  46                 return
  47 
  48 #define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\
  49         if (!NSK_JNI_VERIFY(env, (_methodID = \
  50              NSK_CPP_STUB4(GetMethodID, env, _class,\
  51              _methodName, _sig)) != NULL))\
  52                 return
  53 
  54 #define CALL_VOID_NOPARAM(_obj, _class, _methodName)\
  55             GET_METHOD_ID(method, _class, _methodName, "()V");\
  56         if (!NSK_JNI_VERIFY_VOID(env, NSK_CPP_STUB3(CallVoidMethod, env, _obj,\
  57              method)))\
  58                 return
  59 /*
  60  * Class:     nsk_monitoring_share_thread_LockingThreads_Thread1
  61  * Method:    B
  62  * Signature: ()V
  63  */
  64 JNIEXPORT void JNICALL Java_nsk_monitoring_share_thread_LockingThreads_00024Thread1_B
  65   (JNIEnv *env, jobject o) {
  66         jclass testBugClass, threadClass;
  67         jobject lock4, lock5;
  68         jfieldID field;
  69         jmethodID method;
  70 
  71         GET_OBJECT_CLASS(threadClass, o);
  72         FIND_CLASS(testBugClass, "nsk/share/TestBug");
  73         GET_OBJ_FIELD(lock4, o, threadClass, "lock4", "Lnsk/monitoring/share/thread/LockingThreads$CustomLock;");
  74         GET_OBJ_FIELD(lock5, o, threadClass, "lock5", "Lnsk/monitoring/share/thread/LockingThreads$CustomLock;");
  75         if (env->MonitorEnter(lock4) == JNI_OK) {
  76                 if (env->MonitorEnter(lock5) == JNI_OK) {
  77                         CALL_VOID_NOPARAM(o, threadClass, "C");


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 #include <jni.h>
  24 #include "jni_tools.h"
  25 
  26 extern "C" {
  27 
  28 #define FIND_CLASS(_class, _className)\
  29         if (!NSK_JNI_VERIFY(env, (_class = \
  30              env->FindClass(_className)) != NULL))\
  31                 return
  32 
  33 #define GET_OBJECT_CLASS(_class, _obj)\
  34         if (!NSK_JNI_VERIFY(env, (_class = \
  35              env->GetObjectClass(_obj)) != NULL))\
  36                 return
  37 
  38 #define GET_OBJ_FIELD(_value, _obj, _class, _fieldName, _fieldSig)\
  39         GET_FIELD_ID(field, _class, _fieldName, _fieldSig);\
  40         _value = env->GetObjectField(_obj, field)
  41 
  42 #define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\
  43         if (!NSK_JNI_VERIFY(env, (_fieldID = \
  44              env->GetFieldID(_class, _fieldName, _fieldSig)) != NULL))\

  45                 return
  46 
  47 #define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\
  48         if (!NSK_JNI_VERIFY(env, (_methodID = \
  49              env->GetMethodID(_class, _methodName, _sig)) != NULL))\

  50                 return
  51 
  52 #define CALL_VOID_NOPARAM(_obj, _class, _methodName)\
  53             GET_METHOD_ID(method, _class, _methodName, "()V");\
  54         if (!NSK_JNI_VERIFY_VOID(env, env->CallVoidMethod(_obj, method)))\

  55                 return
  56 /*
  57  * Class:     nsk_monitoring_share_thread_LockingThreads_Thread1
  58  * Method:    B
  59  * Signature: ()V
  60  */
  61 JNIEXPORT void JNICALL Java_nsk_monitoring_share_thread_LockingThreads_00024Thread1_B
  62   (JNIEnv *env, jobject o) {
  63         jclass testBugClass, threadClass;
  64         jobject lock4, lock5;
  65         jfieldID field;
  66         jmethodID method;
  67 
  68         GET_OBJECT_CLASS(threadClass, o);
  69         FIND_CLASS(testBugClass, "nsk/share/TestBug");
  70         GET_OBJ_FIELD(lock4, o, threadClass, "lock4", "Lnsk/monitoring/share/thread/LockingThreads$CustomLock;");
  71         GET_OBJ_FIELD(lock5, o, threadClass, "lock5", "Lnsk/monitoring/share/thread/LockingThreads$CustomLock;");
  72         if (env->MonitorEnter(lock4) == JNI_OK) {
  73                 if (env->MonitorEnter(lock5) == JNI_OK) {
  74                         CALL_VOID_NOPARAM(o, threadClass, "C");
< prev index next >