Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/StackTraceController.cpp
40948 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 <jni.h>
25
#include <stdio.h>
26
#include "jni_tools.h"
27
28
extern "C" {
29
30
#define GET_OBJECT_CLASS(_class, _obj)\
31
if (!NSK_JNI_VERIFY(env, (_class = \
32
env->GetObjectClass(_obj)) != NULL))\
33
return 2
34
35
#define CALL_STATIC_VOID_NOPARAM(_class, _methodName)\
36
GET_STATIC_METHOD_ID(method, _class, _methodName, "()V");\
37
if (!NSK_JNI_VERIFY_VOID(env, env->CallStaticVoidMethod(_class, method)))\
38
return 2
39
40
#define GET_STATIC_METHOD_ID(_methodID, _class, _methodName, _sig)\
41
if (!NSK_JNI_VERIFY(env, (_methodID = \
42
env->GetStaticMethodID(_class, _methodName, _sig)) != NULL))\
43
return 2
44
45
#define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\
46
if (!NSK_JNI_VERIFY(env, (_methodID = \
47
env->GetMethodID(_class, _methodName, _sig)) != NULL))\
48
return 2
49
50
#define CALL_VOID_NOPARAM(_obj, _class, _methodName)\
51
GET_METHOD_ID(method, _class, _methodName, "()V");\
52
if (!NSK_JNI_VERIFY_VOID(env, env->CallVoidMethod(_obj, method)))\
53
return 2
54
55
JNIEXPORT jint JNICALL
56
Java_nsk_monitoring_stress_thread_RunningThread_recursionNative(JNIEnv *env,
57
jobject obj, jint maxDepth, jint currentDepth, jboolean returnToJava) {
58
jmethodID method;
59
jclass threadClass;
60
61
GET_OBJECT_CLASS(threadClass, obj);
62
currentDepth++;
63
64
if (maxDepth > currentDepth) {
65
CALL_STATIC_VOID_NOPARAM(threadClass, "yield");
66
67
if (returnToJava) {
68
GET_METHOD_ID(method, threadClass, "recursionJava", "(II)V");
69
if (!NSK_JNI_VERIFY_VOID(env,
70
env->CallIntMethod(obj, method, maxDepth, currentDepth))) {
71
return 1;
72
}
73
} else {
74
GET_METHOD_ID(method, threadClass, "recursionNative", "(IIZ)I");
75
if (!NSK_JNI_VERIFY_VOID(env,
76
env->CallIntMethod(obj, method, maxDepth, currentDepth, returnToJava))) {
77
return 1;
78
}
79
}
80
}
81
CALL_VOID_NOPARAM(obj, threadClass, "waitForSign");
82
return 0;
83
}
84
85
}
86
87