Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/nsk_strace.h
41155 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
#include <stdlib.h>
25
#include "jni_tools.h"
26
27
#ifndef _IS_NSK_STRACE_DEFINED_
28
#define _IS_NSK_STRACE_DEFINED_
29
30
#define JNI_VERSION JNI_VERSION_1_1
31
32
#define EXCEPTION_CLEAR env->ExceptionClear()
33
#define EXCEPTION_OCCURRED env->ExceptionOccurred()
34
35
// Check for pending exception of the specified type
36
// If it's present, then clear it
37
#define EXCEPTION_CHECK(exceptionClass, recurDepth) \
38
if (EXCEPTION_OCCURRED != NULL) { \
39
jobject exception = EXCEPTION_OCCURRED; \
40
if (env->IsInstanceOf(exception, exceptionClass) == JNI_TRUE) { \
41
EXCEPTION_CLEAR; \
42
NSK_DISPLAY1("StackOverflowError occurred at depth %d\n", recurDepth); \
43
} \
44
}
45
46
#define FIND_CLASS(_class, _className)\
47
if (!NSK_JNI_VERIFY(env, (_class = \
48
env->FindClass(_className)) != NULL))\
49
exit(1)
50
51
#define GET_OBJECT_CLASS(_class, _obj)\
52
if (!NSK_JNI_VERIFY(env, (_class = \
53
env->GetObjectClass(_obj)) != NULL))\
54
exit(1)
55
56
#define GET_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\
57
if (!NSK_JNI_VERIFY(env, (_fieldID = \
58
env->GetFieldID(_class, _fieldName, _fieldSig)) != NULL))\
59
exit(1)
60
61
#define GET_STATIC_FIELD_ID(_fieldID, _class, _fieldName, _fieldSig)\
62
if (!NSK_JNI_VERIFY(env, (_fieldID = \
63
env->GetStaticFieldID(_class, _fieldName, _fieldSig)) != NULL))\
64
exit(1)
65
66
#define GET_STATIC_BOOL_FIELD(_value, _class, _fieldName)\
67
GET_STATIC_FIELD_ID(field, _class, _fieldName, "Z");\
68
_value = env->GetStaticBooleanField(_class, field)
69
70
#define GET_STATIC_INT_FIELD(_value, _class, _fieldName)\
71
GET_STATIC_FIELD_ID(field, _class, _fieldName, "I");\
72
_value = env->GetStaticIntField(_class, field)
73
74
#define GET_STATIC_OBJ_FIELD(_value, _class, _fieldName, _fieldSig)\
75
GET_STATIC_FIELD_ID(field, _class, _fieldName, _fieldSig);\
76
_value = env->GetStaticObjectField(_class, field)
77
78
#define GET_INT_FIELD(_value, _obj, _class, _fieldName)\
79
GET_FIELD_ID(field, _class, _fieldName, "I");\
80
_value = env->GetIntField(_obj, field)
81
82
#define SET_INT_FIELD(_obj, _class, _fieldName, _newValue)\
83
GET_FIELD_ID(field, _class, _fieldName, "I");\
84
env->SetIntField(_obj, field, _newValue)
85
86
#define SET_STATIC_INT_FIELD(_class, _fieldName, _newValue)\
87
GET_STATIC_FIELD_ID(field, _class, _fieldName, "I");\
88
env->SetStaticIntField(_class, field, _newValue)
89
90
#define GET_OBJ_FIELD(_value, _obj, _class, _fieldName, _fieldSig)\
91
GET_FIELD_ID(field, _class, _fieldName, _fieldSig);\
92
_value = env->GetObjectField(_obj, field)
93
94
#define GET_STATIC_METHOD_ID(_methodID, _class, _methodName, _sig)\
95
if (!NSK_JNI_VERIFY(env, (_methodID = \
96
env->GetStaticMethodID(_class, _methodName, _sig)) != NULL))\
97
exit(1)
98
99
#define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\
100
if (!NSK_JNI_VERIFY(env, (_methodID = \
101
env->GetMethodID(_class, _methodName, _sig)) != NULL))\
102
exit(1)
103
104
#define CALL_STATIC_VOID_NOPARAM(_class, _methodName)\
105
GET_STATIC_METHOD_ID(method, _class, _methodName, "()V");\
106
if (!NSK_JNI_VERIFY_VOID(env, env->CallStaticVoidMethod(_class, method)))\
107
exit(1)
108
109
#define CALL_STATIC_VOID(_class, _methodName, _sig, _param)\
110
GET_STATIC_METHOD_ID(method, _class, _methodName, _sig);\
111
if (!NSK_JNI_VERIFY_VOID(env, env->CallStaticVoidMethod(_class, method, _param)))\
112
exit(1)
113
114
#define CALL_VOID_NOPARAM(_obj, _class, _methodName)\
115
GET_METHOD_ID(method, _class, _methodName, "()V");\
116
if (!NSK_JNI_VERIFY_VOID(env, env->CallVoidMethod(_obj, method)))\
117
exit(1)
118
119
#define CALL_VOID(_obj, _class, _methodName, _sig, _param)\
120
GET_METHOD_ID(method, _class, _methodName, _sig);\
121
if (!NSK_JNI_VERIFY_VOID(env, env->CallVoidMethod(_obj, method, _param)))\
122
exit(1)
123
124
#define MONITOR_ENTER(x) \
125
NSK_JNI_VERIFY(env, env->MonitorEnter(x) == 0)
126
127
#define MONITOR_EXIT(x) \
128
NSK_JNI_VERIFY(env, env->MonitorExit(x) == 0)
129
130
#endif /* _IS_NSK_STRACE_DEFINED_ */
131
132