Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine07/agent01.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 "VMNativeAgent01"3132/*33*/3435JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) {36JNIEnv* jni;37int success = 1;3839// can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here4041jni = (JNIEnv*) nsk_aod_createJNIEnv(vm);42if (jni == NULL)43return JNI_ERR;4445printf("%s: initialization was done\n", AGENT_NAME);46fflush(stdout);4748if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, AGENT_NAME)))49return JNI_ERR;5051if (optionsString == NULL) {52success = 0;53printf("%s: ERROR: unexpected null options\n", AGENT_NAME);54fflush(stdout);55} else {56size_t length = strlen(optionsString);57if (length != 0) {58success = 0;59printf("%s: ERROR: unexpected non-zero length options string: '%s'\n", AGENT_NAME, optionsString);60fflush(stdout);61}62}6364nsk_aod_agentFinished(jni, AGENT_NAME, success);6566return JNI_OK;67}6869}707172