Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace014.cpp
41155 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 <stdio.h>24#include "nsk_strace.h"2526extern "C" {2728static const char *Stest_cn="nsk/stress/strace/strace014";29static const char *SthreadName_mn="getName";30static const char *SthreadName_s="()Ljava/lang/String;";3132JNIEXPORT void JNICALL33Java_nsk_stress_strace_strace014Thread_recursiveMethod(JNIEnv *env, jobject obj)34{35jclass testClass, threadClass;36jint currDepth, achivedCount, maxDepth;37jobject testField, lockedObject;38jboolean proceed;3940jfieldID field;41jmethodID method;4243FIND_CLASS(testClass, Stest_cn);44GET_OBJECT_CLASS(threadClass, obj);4546/* currDepth++ */47GET_INT_FIELD(currDepth, obj, threadClass, "currentDepth");48currDepth++;49SET_INT_FIELD(obj, threadClass, "currentDepth", currDepth);50GET_STATIC_INT_FIELD(maxDepth, testClass, "DEPTH");515253if (maxDepth - currDepth > 0)54{55CALL_VOID_NOPARAM(obj, threadClass, "recursiveMethod");56}575859if (maxDepth == currDepth)60{61GET_OBJ_FIELD(testField, obj, threadClass, "test",62"Lnsk/stress/strace/strace014;");6364MONITOR_ENTER(testField);65GET_STATIC_INT_FIELD(achivedCount, testClass, "achivedCount");66achivedCount++;67SET_STATIC_INT_FIELD(testClass, "achivedCount", achivedCount);68MONITOR_EXIT(testField);6970GET_STATIC_OBJ_FIELD(lockedObject, testClass, "lockedObject",71"Ljava/lang/Object;");727374MONITOR_ENTER(lockedObject);75GET_STATIC_BOOL_FIELD(proceed, testClass, "proceed");76while (proceed != JNI_TRUE)77{78/* printf("waiting on a monitor\n"); */79CALL_VOID_NOPARAM(lockedObject, threadClass, "wait");8081GET_STATIC_BOOL_FIELD(proceed, testClass, "proceed");82}83MONITOR_EXIT(lockedObject);8485/* printf("got notify\n"); */86}8788currDepth--;89GET_OBJECT_CLASS(threadClass, obj);90SET_INT_FIELD(obj, threadClass, "currentDepth", currDepth);91}9293}949596