test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t012/hs302t012.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. |
44 if (strcmp(className,CLASS_NAME) == 0) { |
44 if (strcmp(className,CLASS_NAME) == 0) { |
45 char fileName[512]; |
45 char fileName[512]; |
46 nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); |
46 nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL); |
47 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, |
47 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, |
48 sizeof(fileName)/sizeof(char)); |
48 sizeof(fileName)/sizeof(char)); |
49 if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName) == NSK_TRUE) { |
49 if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) { |
50 nsk_printf("Redefine successful ..\n"); |
50 nsk_printf("Redefine successful ..\n"); |
51 } else { |
51 } else { |
52 nsk_printf("# error :: Redefine failed..\n"); |
52 nsk_printf("# error :: Redefine failed..\n"); |
53 } |
53 } |
54 } |
54 } |
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; |
89 rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)); |
89 rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)); |
90 if (rc != JVMTI_ERROR_NONE) { |
90 if (rc != JVMTI_ERROR_NONE) { |
91 nsk_printf(" Agent:: Error occured while setting event call back \n"); |
91 nsk_printf(" Agent:: Error occured while setting event call back \n"); |
92 return JNI_ERR; |
92 return JNI_ERR; |
93 } |
93 } |
94 if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL) == NSK_TRUE) { |
94 if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) { |
95 nsk_printf(" Enabled. noftification.."); |
95 nsk_printf(" Enabled. noftification.."); |
96 } else { |
96 } else { |
97 nsk_printf(" Failed to Enable .."); |
97 nsk_printf(" Failed to Enable .."); |
98 } |
98 } |
99 } |
99 } |