Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/jni/jni_tools.h
41161 views
/*1* Copyright (c) 2003, 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#ifndef NSK_JNI_TOOLS_DEFINED24#define NSK_JNI_TOOLS_DEFINED2526/*************************************************************/2728#include "jni.h"2930/*************************************************************/3132#include "nsk_tools.h"3334/*************************************************************/3536/* printf format specifier for jlong */37#ifdef _WIN323839#define LL "I64"40#include <STDDEF.H>4142#else // !_WIN324344#include <stdint.h>4546#ifdef _LP6447#define LL "l"48#else49#define LL "ll"50#endif5152#endif // !_WIN325354/**55* Additional Java basic types56*/5758#ifdef _WIN3259typedef unsigned __int64 julong;60#else61typedef unsigned long long julong;62#endif6364/*************************************************************/6566/**67* Execute action with JNI call, check result for true and68* pending exception and complain error if required.69* Also trace action execution if tracing mode enabled.70*/71#define NSK_JNI_VERIFY(jni, action) \72(nsk_ltrace(NSK_TRACE_BEFORE,__FILE__,__LINE__,"%s\n",#action), \73nsk_jni_lverify(NSK_TRUE,jni,action,__FILE__,__LINE__,"%s\n",#action))7475/**76* Execute action with JNI call, check result for false and77* pending exception and complain error if required.78* Also trace action execution if tracing mode enabled.79*/80#define NSK_JNI_VERIFY_NEGATIVE(jni,action) \81(nsk_ltrace(NSK_TRACE_BEFORE,__FILE__,__LINE__,"%s\n",#action), \82nsk_jni_lverify(NSK_FALSE,jni,action,__FILE__,__LINE__,"%s\n",#action))8384/**85* Execute action with JNI call, check result for86* pending exception and complain error if required.87* Also trace action execution if tracing mode enabled.88*/89#define NSK_JNI_VERIFY_VOID(jni,action) \90(nsk_ltrace(NSK_TRACE_BEFORE,__FILE__,__LINE__,"%s\n",#action), \91action, \92nsk_jni_lverify_void(jni, __FILE__,__LINE__,"%s\n",#action))9394/*************************************************************/9596extern "C" {9798/*************************************************************/99100/**101* If positive, assert status is true; or102* if !positive, assert status is not true.103* Assert means: complain if the assertion is false.104* Return the assertion value, either NSK_TRUE or NSK_FALSE.105* Anyway, trace if "nsk_tools" mode is verbose and106* print information about pending exceptions if status is false.107*/108int nsk_jni_lverify(int positive, JNIEnv* jni, int status,109const char file[], int line, const char format[], ...);110111/**112* If positive, assert status is true; or113* if !positive, assert status is not true.114* Assert means: complain if the assertion is false.115* Return the assertion value, either NSK_TRUE or NSK_FALSE.116* Anyway, trace if "nsk_tools" mode is verbose and117* print information about pending exceptions if status is false.118*/119int nsk_jni_lverify_void(JNIEnv* jni, const char file[], int line,120const char format[], ...);121122/**123* Checks if pending exception exists and then prints error message124* with exception description, clears pending exception amd return 1.125* Otherwise, does noting and returns 0,126*/127int nsk_jni_check_exception(JNIEnv* jni, const char file[], int line);128129/**130* Convert the digits of the given value argument to a null-terminated131* character string and store the result (up to 32 bytes) in string.132* If value is negative, the first character of the stored string is133* the minus sign (-). The function returns a pointer to the begining134* of the result string.135*/136char *jlong_to_string(jlong value, char *string);137138/**139* Convert the digits of the given value argument to a null-terminated140* character string and store the result (up to 32 bytes) in string.141* The function returns a pointer to the begining of the result string.142*/143char *julong_to_string(julong value, char *string);144145/**146* Sleep for given number of milliseconds.147*/148void mssleep(long millis);149150/**151* Create JavaVMOption array of size 'size' and fills152* first argsCnt elements from args[].153* Callee is responsible to free JavaVMOption*.154* No other memory deallocations are required.155*/156JavaVMOption* jni_create_vmoptions(int size, char *args[], int argsCnt);157158/**159* Print JavaVMInitArgs values to stdout.160*/161void jni_print_vmargs(JavaVMInitArgs vmargs);162163/*************************************************************/164165}166167/*************************************************************/168169#endif170171172