Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/jni/jni_tools.h
41161 views
1
/*
2
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
#ifndef NSK_JNI_TOOLS_DEFINED
25
#define NSK_JNI_TOOLS_DEFINED
26
27
/*************************************************************/
28
29
#include "jni.h"
30
31
/*************************************************************/
32
33
#include "nsk_tools.h"
34
35
/*************************************************************/
36
37
/* printf format specifier for jlong */
38
#ifdef _WIN32
39
40
#define LL "I64"
41
#include <STDDEF.H>
42
43
#else // !_WIN32
44
45
#include <stdint.h>
46
47
#ifdef _LP64
48
#define LL "l"
49
#else
50
#define LL "ll"
51
#endif
52
53
#endif // !_WIN32
54
55
/**
56
* Additional Java basic types
57
*/
58
59
#ifdef _WIN32
60
typedef unsigned __int64 julong;
61
#else
62
typedef unsigned long long julong;
63
#endif
64
65
/*************************************************************/
66
67
/**
68
* Execute action with JNI call, check result for true and
69
* pending exception and complain error if required.
70
* Also trace action execution if tracing mode enabled.
71
*/
72
#define NSK_JNI_VERIFY(jni, action) \
73
(nsk_ltrace(NSK_TRACE_BEFORE,__FILE__,__LINE__,"%s\n",#action), \
74
nsk_jni_lverify(NSK_TRUE,jni,action,__FILE__,__LINE__,"%s\n",#action))
75
76
/**
77
* Execute action with JNI call, check result for false and
78
* pending exception and complain error if required.
79
* Also trace action execution if tracing mode enabled.
80
*/
81
#define NSK_JNI_VERIFY_NEGATIVE(jni,action) \
82
(nsk_ltrace(NSK_TRACE_BEFORE,__FILE__,__LINE__,"%s\n",#action), \
83
nsk_jni_lverify(NSK_FALSE,jni,action,__FILE__,__LINE__,"%s\n",#action))
84
85
/**
86
* Execute action with JNI call, check result for
87
* pending exception and complain error if required.
88
* Also trace action execution if tracing mode enabled.
89
*/
90
#define NSK_JNI_VERIFY_VOID(jni,action) \
91
(nsk_ltrace(NSK_TRACE_BEFORE,__FILE__,__LINE__,"%s\n",#action), \
92
action, \
93
nsk_jni_lverify_void(jni, __FILE__,__LINE__,"%s\n",#action))
94
95
/*************************************************************/
96
97
extern "C" {
98
99
/*************************************************************/
100
101
/**
102
* If positive, assert status is true; or
103
* if !positive, assert status is not true.
104
* Assert means: complain if the assertion is false.
105
* Return the assertion value, either NSK_TRUE or NSK_FALSE.
106
* Anyway, trace if "nsk_tools" mode is verbose and
107
* print information about pending exceptions if status is false.
108
*/
109
int nsk_jni_lverify(int positive, JNIEnv* jni, int status,
110
const char file[], int line, const char format[], ...);
111
112
/**
113
* If positive, assert status is true; or
114
* if !positive, assert status is not true.
115
* Assert means: complain if the assertion is false.
116
* Return the assertion value, either NSK_TRUE or NSK_FALSE.
117
* Anyway, trace if "nsk_tools" mode is verbose and
118
* print information about pending exceptions if status is false.
119
*/
120
int nsk_jni_lverify_void(JNIEnv* jni, const char file[], int line,
121
const char format[], ...);
122
123
/**
124
* Checks if pending exception exists and then prints error message
125
* with exception description, clears pending exception amd return 1.
126
* Otherwise, does noting and returns 0,
127
*/
128
int nsk_jni_check_exception(JNIEnv* jni, const char file[], int line);
129
130
/**
131
* Convert the digits of the given value argument to a null-terminated
132
* character string and store the result (up to 32 bytes) in string.
133
* If value is negative, the first character of the stored string is
134
* the minus sign (-). The function returns a pointer to the begining
135
* of the result string.
136
*/
137
char *jlong_to_string(jlong value, char *string);
138
139
/**
140
* Convert the digits of the given value argument to a null-terminated
141
* character string and store the result (up to 32 bytes) in string.
142
* The function returns a pointer to the begining of the result string.
143
*/
144
char *julong_to_string(julong value, char *string);
145
146
/**
147
* Sleep for given number of milliseconds.
148
*/
149
void mssleep(long millis);
150
151
/**
152
* Create JavaVMOption array of size 'size' and fills
153
* first argsCnt elements from args[].
154
* Callee is responsible to free JavaVMOption*.
155
* No other memory deallocations are required.
156
*/
157
JavaVMOption* jni_create_vmoptions(int size, char *args[], int argsCnt);
158
159
/**
160
* Print JavaVMInitArgs values to stdout.
161
*/
162
void jni_print_vmargs(JavaVMInitArgs vmargs);
163
164
/*************************************************************/
165
166
}
167
168
/*************************************************************/
169
170
#endif
171
172