Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/StackTraceController.cpp
40948 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#include <jni.h>24#include <stdio.h>25#include "jni_tools.h"2627extern "C" {2829#define GET_OBJECT_CLASS(_class, _obj)\30if (!NSK_JNI_VERIFY(env, (_class = \31env->GetObjectClass(_obj)) != NULL))\32return 23334#define CALL_STATIC_VOID_NOPARAM(_class, _methodName)\35GET_STATIC_METHOD_ID(method, _class, _methodName, "()V");\36if (!NSK_JNI_VERIFY_VOID(env, env->CallStaticVoidMethod(_class, method)))\37return 23839#define GET_STATIC_METHOD_ID(_methodID, _class, _methodName, _sig)\40if (!NSK_JNI_VERIFY(env, (_methodID = \41env->GetStaticMethodID(_class, _methodName, _sig)) != NULL))\42return 24344#define GET_METHOD_ID(_methodID, _class, _methodName, _sig)\45if (!NSK_JNI_VERIFY(env, (_methodID = \46env->GetMethodID(_class, _methodName, _sig)) != NULL))\47return 24849#define CALL_VOID_NOPARAM(_obj, _class, _methodName)\50GET_METHOD_ID(method, _class, _methodName, "()V");\51if (!NSK_JNI_VERIFY_VOID(env, env->CallVoidMethod(_obj, method)))\52return 25354JNIEXPORT jint JNICALL55Java_nsk_monitoring_stress_thread_RunningThread_recursionNative(JNIEnv *env,56jobject obj, jint maxDepth, jint currentDepth, jboolean returnToJava) {57jmethodID method;58jclass threadClass;5960GET_OBJECT_CLASS(threadClass, obj);61currentDepth++;6263if (maxDepth > currentDepth) {64CALL_STATIC_VOID_NOPARAM(threadClass, "yield");6566if (returnToJava) {67GET_METHOD_ID(method, threadClass, "recursionJava", "(II)V");68if (!NSK_JNI_VERIFY_VOID(env,69env->CallIntMethod(obj, method, maxDepth, currentDepth))) {70return 1;71}72} else {73GET_METHOD_ID(method, threadClass, "recursionNative", "(IIZ)I");74if (!NSK_JNI_VERIFY_VOID(env,75env->CallIntMethod(obj, method, maxDepth, currentDepth, returnToJava))) {76return 1;77}78}79}80CALL_VOID_NOPARAM(obj, threadClass, "waitForSign");81return 0;82}8384}858687