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. |
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))) |