annotate test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach012/attach012Agent00.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 27ba7cc31f9f
rev   line source
iignatyev@50270 1 /*
iignatyev@50270 2 * Copyright (c) 2008, 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 #include <stdio.h>
iignatyev@50270 24 #include <stdlib.h>
iignatyev@50270 25 #include <string.h>
iignatyev@50270 26 #include <jni.h>
iignatyev@50270 27 #include <jvmti.h>
iignatyev@50270 28 #include <aod.h>
iignatyev@50270 29 #include <jvmti_aod.h>
iignatyev@50270 30
iignatyev@50270 31 extern "C" {
iignatyev@50270 32
iignatyev@50270 33 /*
iignatyev@50270 34 * Agent tries to get all potential capabilities
iignatyev@50270 35 * (capabilities returned by the JVMTI function GetPotentialCapabilities)
iignatyev@50270 36 */
iignatyev@50270 37
iignatyev@50270 38 #ifdef STATIC_BUILD
iignatyev@50270 39 JNIEXPORT jint JNI_OnLoad_attach012Agent00(JavaVM *jvm, char *options, void *reserved) {
iignatyev@50270 40 return JNI_VERSION_1_8;
iignatyev@50270 41 }
iignatyev@50270 42 #endif
iignatyev@50270 43
iignatyev@50270 44 JNIEXPORT jint JNICALL
iignatyev@50270 45 #ifdef STATIC_BUILD
iignatyev@50270 46 Agent_OnAttach_attach012Agent00(JavaVM *vm, char *optionsString, void *reserved)
iignatyev@50270 47 #else
iignatyev@50270 48 Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
iignatyev@50270 49 #endif
iignatyev@50270 50 {
iignatyev@50270 51 jvmtiEnv* jvmti;
iignatyev@50270 52 JNIEnv* jni = NULL;
iignatyev@50270 53 Options* options = NULL;
iignatyev@50270 54 const char* agentName;
iignatyev@50270 55 jvmtiCapabilities caps;
iignatyev@50270 56
iignatyev@50270 57 if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
iignatyev@50270 58 return JNI_ERR;
iignatyev@50270 59
iignatyev@50270 60 agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
iignatyev@50270 61
iignatyev@50270 62 if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
iignatyev@50270 63 return NSK_FALSE;
iignatyev@50270 64
iignatyev@50270 65 if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
iignatyev@50270 66 return JNI_ERR;
iignatyev@50270 67
jcbeyler@52064 68 if (!NSK_JVMTI_VERIFY(jvmti->GetPotentialCapabilities(&caps)) ) {
iignatyev@50270 69 return JNI_ERR;
iignatyev@50270 70 }
iignatyev@50270 71
iignatyev@50270 72 NSK_DISPLAY1("%s: potential capabilities:\n", agentName);
iignatyev@50270 73
iignatyev@50270 74 printCapabilities(caps);
iignatyev@50270 75
iignatyev@50270 76 NSK_DISPLAY1("%s: trying to get all potential capabilities:\n", agentName);
iignatyev@50270 77
jcbeyler@52064 78 if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)) ) {
iignatyev@50270 79 return JNI_ERR;
iignatyev@50270 80 }
iignatyev@50270 81
iignatyev@50270 82 NSK_DISPLAY1("%s: initialization was done\n", agentName);
iignatyev@50270 83
iignatyev@50270 84 if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
iignatyev@50270 85 return JNI_ERR;
iignatyev@50270 86
iignatyev@50270 87 nsk_aod_agentFinished(jni, agentName, 1);
iignatyev@50270 88
iignatyev@50270 89 return JNI_OK;
iignatyev@50270 90 }
iignatyev@50270 91
iignatyev@50270 92 }