test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS302/hs302t007/hs302t007.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 52949 c78a17d24618
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     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.
    39     if (strcmp(className,CLASS_NAME) == 0) {
    39     if (strcmp(className,CLASS_NAME) == 0) {
    40         char fileName[512];
    40         char fileName[512];
    41         nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL);
    41         nsk_jvmti_disableNotification(jvmti_env, JVMTI_EVENT_CLASS_PREPARE, NULL);
    42         nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName,
    42         nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName,
    43                         sizeof(fileName)/sizeof(char));
    43                         sizeof(fileName)/sizeof(char));
    44         if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName) == NSK_TRUE) {
    44         if (nsk_jvmti_redefineClass(jvmti_env, klass, fileName)) {
    45             nsk_printf("Redefine successful ..\n");
    45             nsk_printf("Redefine successful ..\n");
    46         } else {
    46         } else {
    47             nsk_printf("# error :: Redefine failed..\n");
    47             nsk_printf("# error :: Redefine failed..\n");
    48         }
    48         }
    49     }
    49     }
    69         nsk_printf("Agent:: Could not load JVMTI interface \n");
    69         nsk_printf("Agent:: Could not load JVMTI interface \n");
    70         return JNI_ERR;
    70         return JNI_ERR;
    71     } else {
    71     } else {
    72         jvmtiCapabilities caps;
    72         jvmtiCapabilities caps;
    73         jvmtiEventCallbacks eventCallbacks;
    73         jvmtiEventCallbacks eventCallbacks;
    74         if (nsk_jvmti_parseOptions(options) == NSK_FALSE) {
    74         if (!nsk_jvmti_parseOptions(options)) {
    75             nsk_printf("# error agent Failed to parse options \n");
    75             nsk_printf("# error agent Failed to parse options \n");
    76             return JNI_ERR;
    76             return JNI_ERR;
    77         }
    77         }
    78         memset(&caps, 0, sizeof(caps));
    78         memset(&caps, 0, sizeof(caps));
    79         caps.can_redefine_classes = 1;
    79         caps.can_redefine_classes = 1;
    84         rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks));
    84         rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks));
    85         if (rc != JVMTI_ERROR_NONE) {
    85         if (rc != JVMTI_ERROR_NONE) {
    86             nsk_printf(" Agent:: Error occured while setting event call back \n");
    86             nsk_printf(" Agent:: Error occured while setting event call back \n");
    87             return JNI_ERR;
    87             return JNI_ERR;
    88         }
    88         }
    89         if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL) == NSK_TRUE) {
    89         if (nsk_jvmti_enableNotification(jvmti, JVMTI_EVENT_CLASS_PREPARE, NULL)) {
    90             nsk_printf(" Enabled. noftification..");
    90             nsk_printf(" Enabled. noftification..");
    91         } else {
    91         } else {
    92             nsk_printf(" Failed to Enable ..");
    92             nsk_printf(" Failed to Enable ..");
    93         }
    93         }
    94     }
    94     }