annotate test/hotspot/jtreg/vmTestbase/nsk/jvmti/DisposeEnvironment/disposeenv002/disposeenv002.cpp @ 52064:054a24c46812

8211261: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/[A-G]* Summary: Remove the NSK_CPP_STUB macros Reviewed-by: amenkov, cjplummer
author jcbeyler
date Mon, 08 Oct 2018 13:54:43 -0700
parents 79dc492c00ab
children
rev   line source
iignatyev@50270 1 /*
iignatyev@50270 2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
iignatyev@50270 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
iignatyev@50270 4 *
iignatyev@50270 5 * This code is free software; you can redistribute it and/or modify it
iignatyev@50270 6 * under the terms of the GNU General Public License version 2 only, as
iignatyev@50270 7 * published by the Free Software Foundation.
iignatyev@50270 8 *
iignatyev@50270 9 * This code is distributed in the hope that it will be useful, but WITHOUT
iignatyev@50270 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
iignatyev@50270 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
iignatyev@50270 12 * version 2 for more details (a copy is included in the LICENSE file that
iignatyev@50270 13 * accompanied this code).
iignatyev@50270 14 *
iignatyev@50270 15 * You should have received a copy of the GNU General Public License version
iignatyev@50270 16 * 2 along with this work; if not, write to the Free Software Foundation,
iignatyev@50270 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
iignatyev@50270 18 *
iignatyev@50270 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
iignatyev@50270 20 * or visit www.oracle.com if you need additional information or have any
iignatyev@50270 21 * questions.
iignatyev@50270 22 */
iignatyev@50270 23
iignatyev@50270 24 #include <stdlib.h>
iignatyev@50270 25 #include <string.h>
iignatyev@50270 26 #include "jvmti.h"
iignatyev@50270 27 #include "agent_common.h"
iignatyev@50270 28 #include "jni_tools.h"
iignatyev@50270 29 #include "jvmti_tools.h"
iignatyev@50270 30
iignatyev@50270 31 extern "C" {
iignatyev@50270 32
iignatyev@50270 33 /* ============================================================================= */
iignatyev@50270 34
iignatyev@50270 35 #define STATUS_FAIL 97
iignatyev@50270 36
iignatyev@50270 37 /* ============================================================================= */
iignatyev@50270 38
iignatyev@50270 39 /**
iignatyev@50270 40 * Callback for VM_DEATH event.
iignatyev@50270 41 */
iignatyev@50270 42 JNIEXPORT void JNICALL
iignatyev@50270 43 callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) {
iignatyev@50270 44 int success = NSK_TRUE;
iignatyev@50270 45
iignatyev@50270 46 NSK_DISPLAY0("Disable VM_DEATH event in VM_DEATH callback\n");
iignatyev@50270 47 if (!NSK_JVMTI_VERIFY(
jcbeyler@52064 48 jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_VM_DEATH, NULL))) {
iignatyev@50270 49 success = NSK_FALSE;
iignatyev@50270 50 } else {
iignatyev@50270 51 NSK_DISPLAY0(" ... disabled\n");
iignatyev@50270 52 }
iignatyev@50270 53
iignatyev@50270 54 NSK_DISPLAY0(">>> Testcase #1: Dispose JVMTI environment in VM_DEATH callback\n");
jcbeyler@52064 55 if (!NSK_JVMTI_VERIFY(jvmti->DisposeEnvironment())) {
iignatyev@50270 56 success = NSK_FALSE;
iignatyev@50270 57 } else {
iignatyev@50270 58 NSK_DISPLAY0(" ... disposed\n");
iignatyev@50270 59 }
iignatyev@50270 60
iignatyev@50270 61 if (!success) {
iignatyev@50270 62 NSK_DISPLAY1("Exit with FAIL exit status: %d\n", STATUS_FAIL);
iignatyev@50270 63 NSK_BEFORE_TRACE(exit(STATUS_FAIL));
iignatyev@50270 64 }
iignatyev@50270 65 }
iignatyev@50270 66
iignatyev@50270 67 /* ============================================================================= */
iignatyev@50270 68
iignatyev@50270 69 /** Agent library initialization. */
iignatyev@50270 70 #ifdef STATIC_BUILD
iignatyev@50270 71 JNIEXPORT jint JNICALL Agent_OnLoad_disposeenv002(JavaVM *jvm, char *options, void *reserved) {
iignatyev@50270 72 return Agent_Initialize(jvm, options, reserved);
iignatyev@50270 73 }
iignatyev@50270 74 JNIEXPORT jint JNICALL Agent_OnAttach_disposeenv002(JavaVM *jvm, char *options, void *reserved) {
iignatyev@50270 75 return Agent_Initialize(jvm, options, reserved);
iignatyev@50270 76 }
iignatyev@50270 77 JNIEXPORT jint JNI_OnLoad_disposeenv002(JavaVM *jvm, char *options, void *reserved) {
iignatyev@50270 78 return JNI_VERSION_1_8;
iignatyev@50270 79 }
iignatyev@50270 80 #endif
iignatyev@50270 81 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
iignatyev@50270 82 jvmtiEnv* jvmti = NULL;
iignatyev@50270 83
iignatyev@50270 84 if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
iignatyev@50270 85 return JNI_ERR;
iignatyev@50270 86
iignatyev@50270 87 if (!NSK_VERIFY((jvmti =
iignatyev@50270 88 nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
iignatyev@50270 89 return JNI_ERR;
iignatyev@50270 90
iignatyev@50270 91 {
iignatyev@50270 92 jvmtiEventCallbacks eventCallbacks;
iignatyev@50270 93
iignatyev@50270 94 memset(&eventCallbacks, 0, sizeof(eventCallbacks));
iignatyev@50270 95 eventCallbacks.VMDeath = callbackVMDeath;
jcbeyler@52064 96 if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
iignatyev@50270 97 return JNI_ERR;
iignatyev@50270 98 }
iignatyev@50270 99
iignatyev@50270 100 NSK_DISPLAY0("Enable VM_DEATH event in JVM_OnLoad()\n");
iignatyev@50270 101 if (!NSK_JVMTI_VERIFY(
jcbeyler@52064 102 jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) {
iignatyev@50270 103 return JNI_ERR;
iignatyev@50270 104 }
iignatyev@50270 105 NSK_DISPLAY0(" ... enabled\n");
iignatyev@50270 106 }
iignatyev@50270 107
iignatyev@50270 108 return JNI_OK;
iignatyev@50270 109 }
iignatyev@50270 110
iignatyev@50270 111 /* ============================================================================= */
iignatyev@50270 112
iignatyev@50270 113 }