test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t004/hs301t004.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. |
45 int redefineNumber =0; |
45 int redefineNumber =0; |
46 char fileName[512]; |
46 char fileName[512]; |
47 nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); |
47 nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); |
48 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, |
48 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, |
49 sizeof(fileName)/sizeof(char)); |
49 sizeof(fileName)/sizeof(char)); |
50 if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName) == NSK_TRUE) { |
50 if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { |
51 nsk_printf("Agent:: Redefine successful.\n"); |
51 nsk_printf("Agent:: Redefine successful.\n"); |
52 } else { |
52 } else { |
53 nsk_printf("Agent:: Redefine failed.\n"); |
53 nsk_printf("Agent:: Redefine failed.\n"); |
54 } |
54 } |
55 } |
55 } |
74 nsk_printf("Agent:: Could not load JVMTI interface \n"); |
74 nsk_printf("Agent:: Could not load JVMTI interface \n"); |
75 return JNI_ERR; |
75 return JNI_ERR; |
76 } else { |
76 } else { |
77 jvmtiCapabilities caps; |
77 jvmtiCapabilities caps; |
78 jvmtiEventCallbacks eventCallbacks; |
78 jvmtiEventCallbacks eventCallbacks; |
79 if (nsk_jvmti_parseOptions(options) == NSK_FALSE) { |
79 if (!nsk_jvmti_parseOptions(options)) { |
80 nsk_printf("# error agent Failed to parse options \n"); |
80 nsk_printf("# error agent Failed to parse options \n"); |
81 return JNI_ERR; |
81 return JNI_ERR; |
82 } |
82 } |
83 memset(&caps, 0, sizeof(caps)); |
83 memset(&caps, 0, sizeof(caps)); |
84 caps.can_redefine_classes = 1; |
84 caps.can_redefine_classes = 1; |
91 eventCallbacks.ClassPrepare = &callbackClassPrepare; |
91 eventCallbacks.ClassPrepare = &callbackClassPrepare; |
92 if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) { |
92 if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) { |
93 nsk_printf(" Agent:: Error occured while setting event call back \n"); |
93 nsk_printf(" Agent:: Error occured while setting event call back \n"); |
94 return JNI_ERR; |
94 return JNI_ERR; |
95 } |
95 } |
96 if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL) == NSK_TRUE) { |
96 if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { |
97 nsk_printf(" Enabled notification.\n"); |
97 nsk_printf(" Enabled notification.\n"); |
98 } else { |
98 } else { |
99 nsk_printf(" Failed to enable notifications.\n"); |
99 nsk_printf(" Failed to enable notifications.\n"); |
100 } |
100 } |
101 } |
101 } |