test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t001/hs203t001.cpp
equal
deleted
inserted
replaced
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. |
95 char fileName[512]; |
95 char fileName[512]; |
96 threadClass = jni->FindClass(SEARCH_NAME); |
96 threadClass = jni->FindClass(SEARCH_NAME); |
97 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, |
97 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, |
98 sizeof(fileName)/sizeof(char)); |
98 sizeof(fileName)/sizeof(char)); |
99 nsk_printf(" %d..",redefineNumber); |
99 nsk_printf(" %d..",redefineNumber); |
100 if (nsk_jvmti_redefineClass(jvmti, threadClass, fileName) == NSK_TRUE) { |
100 if (nsk_jvmti_redefineClass(jvmti, threadClass, fileName)) { |
101 nsk_printf("\nMyClass :: Successfully redefined..\n"); |
101 nsk_printf("\nMyClass :: Successfully redefined..\n"); |
102 } else { |
102 } else { |
103 nsk_printf("\nMyClass :: Failed to redefine ..\n"); |
103 nsk_printf("\nMyClass :: Failed to redefine ..\n"); |
104 } |
104 } |
105 nsk_printf(" End of REDEFINE CLASS LOADER \n"); |
105 nsk_printf(" End of REDEFINE CLASS LOADER \n"); |
116 JNIEnv* jni, |
116 JNIEnv* jni, |
117 jthread thread, |
117 jthread thread, |
118 jmethodID method, |
118 jmethodID method, |
119 jlocation location) { |
119 jlocation location) { |
120 nsk_printf("Agent::... BreakPoint Reached..\n"); |
120 nsk_printf("Agent::... BreakPoint Reached..\n"); |
121 if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_SINGLE_STEP,thread) == NSK_TRUE) { |
121 if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_SINGLE_STEP,thread)) { |
122 nsk_printf(" .... Enabled..\n"); |
122 nsk_printf(" .... Enabled..\n"); |
123 } |
123 } |
124 return; |
124 return; |
125 } |
125 } |
126 |
126 |
143 nsk_printf("Agent:: Could not load JVMTI interface \n"); |
143 nsk_printf("Agent:: Could not load JVMTI interface \n"); |
144 return JNI_ERR; |
144 return JNI_ERR; |
145 } else { |
145 } else { |
146 jvmtiCapabilities caps; |
146 jvmtiCapabilities caps; |
147 jvmtiEventCallbacks eventCallbacks; |
147 jvmtiEventCallbacks eventCallbacks; |
148 if (nsk_jvmti_parseOptions(options) == NSK_FALSE) { |
148 if (!nsk_jvmti_parseOptions(options)) { |
149 nsk_printf("# error agent Failed to parse options \n"); |
149 nsk_printf("# error agent Failed to parse options \n"); |
150 return JNI_ERR; |
150 return JNI_ERR; |
151 } |
151 } |
152 memset(&caps, 0, sizeof(caps)); |
152 memset(&caps, 0, sizeof(caps)); |
153 caps.can_redefine_classes = 1; |
153 caps.can_redefine_classes = 1; |
164 rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)); |
164 rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)); |
165 if (rc != JVMTI_ERROR_NONE) { |
165 if (rc != JVMTI_ERROR_NONE) { |
166 nsk_printf(" Agent:: Error occured while setting event call back \n"); |
166 nsk_printf(" Agent:: Error occured while setting event call back \n"); |
167 return JNI_ERR; |
167 return JNI_ERR; |
168 } |
168 } |
169 if ((nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_LOAD, NULL) == NSK_TRUE) && |
169 if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_LOAD, NULL) && |
170 (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_BREAKPOINT,NULL) == NSK_TRUE)) { |
170 nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_BREAKPOINT,NULL)) { |
171 nsk_printf("Agent :: NOTIFICATIONS ARE ENABLED \n"); |
171 nsk_printf("Agent :: NOTIFICATIONS ARE ENABLED \n"); |
172 } else { |
172 } else { |
173 nsk_printf(" Error in Eanableing Notifications.."); |
173 nsk_printf(" Error in Eanableing Notifications.."); |
174 } |
174 } |
175 } |
175 } |