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