Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent02.cpp
41160 views
/*1* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223#include <stdio.h>24#include <string.h>25#include <jni.h>26#include <aod.h>2728extern "C" {2930#define AGENT_NAME "VMNativeAgent02"3132#define EXPECTED_OPTIONS "VirtualMachine_TestOptions"3334/*35*/3637JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) {38JNIEnv* jni;39int success = 1;4041// can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here4243jni = (JNIEnv*) nsk_aod_createJNIEnv(vm);44if (jni == NULL)45return JNI_ERR;4647printf("%s: initialization was done\n", AGENT_NAME);48fflush(stdout);4950if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, AGENT_NAME)))51return JNI_ERR;5253if (optionsString == NULL) {54success = 0;55printf("%s: ERROR: unexpected null options\n", AGENT_NAME);56fflush(stdout);57} else {58if (strcmp(optionsString, EXPECTED_OPTIONS)) {59success = 0;60printf("%s: ERROR: unexpected options string: '%s', expected is '%s'\n",61AGENT_NAME, optionsString, EXPECTED_OPTIONS);62fflush(stdout);63}64}6566nsk_aod_agentFinished(jni, AGENT_NAME, success);6768return JNI_OK;69}7071}727374