test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t004/hs302t004.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. |
41 if (strcmp(className,CLASS_NAME) == 0) { |
41 if (strcmp(className,CLASS_NAME) == 0) { |
42 char fileName[512]; |
42 char fileName[512]; |
43 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, |
43 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, |
44 sizeof(fileName)/sizeof(char)); |
44 sizeof(fileName)/sizeof(char)); |
45 nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); |
45 nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); |
46 if (nsk_jvmti_redefineClass(jvmti_env, klass,fileName) == NSK_TRUE) { |
46 if (nsk_jvmti_redefineClass(jvmti_env, klass,fileName)) { |
47 nsk_printf("Redefine successful ..\n"); |
47 nsk_printf("Redefine successful ..\n"); |
48 } else { |
48 } else { |
49 nsk_printf("# error :: Redefine failed..\n"); |
49 nsk_printf("# error :: Redefine failed..\n"); |
50 } |
50 } |
51 } |
51 } |
71 nsk_printf("Agent:: Could not load JVMTI interface \n"); |
71 nsk_printf("Agent:: Could not load JVMTI interface \n"); |
72 return JNI_ERR; |
72 return JNI_ERR; |
73 } else { |
73 } else { |
74 jvmtiCapabilities caps; |
74 jvmtiCapabilities caps; |
75 jvmtiEventCallbacks eventCallbacks; |
75 jvmtiEventCallbacks eventCallbacks; |
76 if (nsk_jvmti_parseOptions(options) == NSK_FALSE) { |
76 if (!nsk_jvmti_parseOptions(options)) { |
77 nsk_printf("# error agent Failed to parse options \n"); |
77 nsk_printf("# error agent Failed to parse options \n"); |
78 return JNI_ERR; |
78 return JNI_ERR; |
79 } |
79 } |
80 memset(&caps, 0, sizeof(caps)); |
80 memset(&caps, 0, sizeof(caps)); |
81 caps.can_redefine_classes = 1; |
81 caps.can_redefine_classes = 1; |
86 rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)); |
86 rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)); |
87 if (rc != JVMTI_ERROR_NONE) { |
87 if (rc != JVMTI_ERROR_NONE) { |
88 nsk_printf(" Agent:: Error occured while setting event call back \n"); |
88 nsk_printf(" Agent:: Error occured while setting event call back \n"); |
89 return JNI_ERR; |
89 return JNI_ERR; |
90 } |
90 } |
91 if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL) == NSK_TRUE) { |
91 if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { |
92 nsk_printf(" Enabled. noftification.."); |
92 nsk_printf(" Enabled. noftification.."); |
93 } else { |
93 } else { |
94 nsk_printf(" Failed to Enable .."); |
94 nsk_printf(" Failed to Enable .."); |
95 } |
95 } |
96 } |
96 } |