1 /* |
1 /* |
2 * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2007, 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. |
44 jvmti->GetClassSignature(klass, &className, &generic); |
44 jvmti->GetClassSignature(klass, &className, &generic); |
45 if (strcmp(className, CLASS_NAME) == 0) { |
45 if (strcmp(className, CLASS_NAME) == 0) { |
46 char fileName[512]; |
46 char fileName[512]; |
47 nsk_jvmti_getFileName(0, FILE_NAME, fileName, |
47 nsk_jvmti_getFileName(0, FILE_NAME, fileName, |
48 sizeof(fileName)/sizeof(char)); |
48 sizeof(fileName)/sizeof(char)); |
49 if (nsk_jvmti_redefineClass(jvmti, klass, fileName) == NSK_TRUE) { |
49 if (nsk_jvmti_redefineClass(jvmti, klass, fileName)) { |
50 nsk_printf("Agent:: Successfully redefined.."); |
50 nsk_printf("Agent:: Successfully redefined.."); |
51 if (nsk_jvmti_disableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, NULL) == NSK_TRUE) { |
51 if (nsk_jvmti_disableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, NULL)) { |
52 nsk_printf(" Agent :: NOTIFICATIONS ARE DISABLED \n"); |
52 nsk_printf(" Agent :: NOTIFICATIONS ARE DISABLED \n"); |
53 } else { |
53 } else { |
54 nsk_printf(" Agent :: Failed to disabled \n"); |
54 nsk_printf(" Agent :: Failed to disabled \n"); |
55 } |
55 } |
56 } else { |
56 } else { |
79 nsk_printf("Agent:: Could not load JVMTI interface \n"); |
79 nsk_printf("Agent:: Could not load JVMTI interface \n"); |
80 return JNI_ERR; |
80 return JNI_ERR; |
81 } else { |
81 } else { |
82 jvmtiCapabilities caps; |
82 jvmtiCapabilities caps; |
83 jvmtiEventCallbacks eventCallbacks; |
83 jvmtiEventCallbacks eventCallbacks; |
84 if (nsk_jvmti_parseOptions(options) == NSK_FALSE) { |
84 if (!nsk_jvmti_parseOptions(options)) { |
85 nsk_printf("# error agent Failed to parse options \n"); |
85 nsk_printf("# error agent Failed to parse options \n"); |
86 return JNI_ERR; |
86 return JNI_ERR; |
87 } |
87 } |
88 memset(&caps, 0, sizeof(caps)); |
88 memset(&caps, 0, sizeof(caps)); |
89 caps.can_redefine_classes = 1; |
89 caps.can_redefine_classes = 1; |
94 rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)); |
94 rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)); |
95 if (rc != JVMTI_ERROR_NONE) { |
95 if (rc != JVMTI_ERROR_NONE) { |
96 nsk_printf(" Agent:: Error occured while setting event call back \n"); |
96 nsk_printf(" Agent:: Error occured while setting event call back \n"); |
97 return JNI_ERR; |
97 return JNI_ERR; |
98 } |
98 } |
99 if (nsk_jvmti_enableNotification(jvmti, |
99 if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { |
100 JVMTI_EVENT_CLASS_PREPARE, NULL) == NSK_TRUE) { |
|
101 nsk_printf("Agent :: NOTIFICATIONS ARE ENABLED \n"); |
100 nsk_printf("Agent :: NOTIFICATIONS ARE ENABLED \n"); |
102 } else { |
101 } else { |
103 nsk_printf(" Error in Eanableing Notifications.."); |
102 nsk_printf(" Error in Eanableing Notifications.."); |
104 } |
103 } |
105 } |
104 } |