test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/em02t010.cpp
changeset 54744 be7839b9493f
parent 52293 d01d4bd7c5b3
child 57629 7aba63ce3b3a
equal deleted inserted replaced
54743:ba74d2de9a01 54744:be7839b9493f
     1 /*
     1 /*
     2  * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    22  */
    22  */
    23 
    23 
    24 #include <string.h>
    24 #include <string.h>
    25 #include "jvmti.h"
    25 #include "jvmti.h"
    26 #include "agent_common.h"
    26 #include "agent_common.h"
       
    27 #include "ExceptionCheckingJniEnv.hpp"
    27 #include "jni_tools.h"
    28 #include "jni_tools.h"
    28 #include "jvmti_tools.h"
    29 #include "jvmti_tools.h"
    29 #include "JVMTITools.h"
    30 #include "JVMTITools.h"
    30 
    31 
    31 extern "C" {
    32 extern "C" {
   449 
   450 
   450 /** Agent algorithm. */
   451 /** Agent algorithm. */
   451 static void JNICALL
   452 static void JNICALL
   452 agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
   453 agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
   453 
   454 
       
   455     ExceptionCheckingJniEnvPtr ec_jni(agentJNI);
   454     int i;
   456     int i;
   455     jfieldID field_accID, field_modID;
   457     jfieldID field_accID, field_modID;
   456     jclass cls;
   458     jclass cls;
   457 
   459 
   458 
   460 
   459     if (!nsk_jvmti_waitForSync(timeout))
   461     if (!nsk_jvmti_waitForSync(timeout))
   460         return;
   462         return;
   461 
   463 
   462     cls = agentJNI->FindClass(CLASS_NAME);
   464     cls = ec_jni->FindClass(CLASS_NAME, TRACE_JNI_CALL);
   463     if (!NSK_JNI_VERIFY(agentJNI, cls != NULL))
   465     field_accID = ec_jni->GetStaticFieldID(cls, FIELD_ACC_NAME, "I", TRACE_JNI_CALL);
   464         return;
   466     field_modID = ec_jni->GetStaticFieldID(cls, FIELD_MOD_NAME, "I", TRACE_JNI_CALL);
   465 
       
   466     field_accID = agentJNI->GetStaticFieldID(cls, FIELD_ACC_NAME, "I");
       
   467     if (!NSK_JNI_VERIFY(agentJNI, field_accID != NULL))
       
   468         return;
       
   469 
       
   470     field_modID = agentJNI->GetStaticFieldID(cls, FIELD_MOD_NAME, "I");
       
   471     if (!NSK_JNI_VERIFY(agentJNI, field_modID != NULL))
       
   472         return;
       
   473 
   467 
   474     if (!NSK_JVMTI_VERIFY(jvmti->SetFieldModificationWatch(cls, field_modID)))
   468     if (!NSK_JVMTI_VERIFY(jvmti->SetFieldModificationWatch(cls, field_modID)))
   475         return;
   469         return;
   476 
   470 
   477     if (!NSK_JVMTI_VERIFY(jvmti->SetFieldAccessWatch(cls, field_accID)))
   471     if (!NSK_JVMTI_VERIFY(jvmti->SetFieldAccessWatch(cls, field_accID)))