test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS301/hs301t002/hs301t002.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. |
55 if (!NSK_VERIFY (JNI_OK == vm->GetEnv((void **)&jvmti, JVMTI_VERSION_1_1))) { |
55 if (!NSK_VERIFY (JNI_OK == vm->GetEnv((void **)&jvmti, JVMTI_VERSION_1_1))) { |
56 nsk_printf(" Agent ::Agent failed to get jvmti env.\n"); |
56 nsk_printf(" Agent ::Agent failed to get jvmti env.\n"); |
57 return JNI_ERR; |
57 return JNI_ERR; |
58 } else { |
58 } else { |
59 jvmtiCapabilities caps; |
59 jvmtiCapabilities caps; |
60 if (nsk_jvmti_parseOptions(options) == NSK_FALSE) { |
60 if (!nsk_jvmti_parseOptions(options)) { |
61 nsk_printf(" Agent:: ## error agent Failed to parse options.\n"); |
61 nsk_printf(" Agent:: ## error agent Failed to parse options.\n"); |
62 return JNI_ERR; |
62 return JNI_ERR; |
63 } |
63 } |
64 memset(&caps, 0, sizeof(caps)); |
64 memset(&caps, 0, sizeof(caps)); |
65 caps.can_redefine_classes = 1; |
65 caps.can_redefine_classes = 1; |
88 nsk_printf("Agent:: (*JNI)->FindClass(jni, %s) returns `null`.\n", SEARCH_NAME); |
88 nsk_printf("Agent:: (*JNI)->FindClass(jni, %s) returns `null`.\n", SEARCH_NAME); |
89 return NSK_FALSE; |
89 return NSK_FALSE; |
90 } |
90 } |
91 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, |
91 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, |
92 sizeof(fileName)/sizeof(char)); |
92 sizeof(fileName)/sizeof(char)); |
93 if (nsk_jvmti_redefineClass(jvmti, cls, fileName) == NSK_TRUE) { |
93 if (nsk_jvmti_redefineClass(jvmti, cls, fileName)) { |
94 nsk_printf("Agent:: MyClass :: Successfully redefined.\n"); |
94 nsk_printf("Agent:: MyClass :: Successfully redefined.\n"); |
95 ret = JNI_TRUE; |
95 ret = JNI_TRUE; |
96 } else { |
96 } else { |
97 nsk_printf("Agent:: MyClass :: Failed to redefine.\n"); |
97 nsk_printf("Agent:: MyClass :: Failed to redefine.\n"); |
98 } |
98 } |