Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace011.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/strace011";29static const char *SthreadName_mn="getName";30static const char *SthreadName_s="()Ljava/lang/String;";31static const char *Slongparam="(J)V";3233JNIEXPORT void JNICALL34Java_nsk_stress_strace_strace011Thread_recursiveMethod(JNIEnv *env, jobject obj)35{36jclass testClass, threadClass;37jint currDepth, achivedCount, maxDepth;38jobject testField, lockedObject;39jboolean isLocked;4041jfieldID field;42jmethodID method;4344FIND_CLASS(testClass, Stest_cn);45GET_OBJECT_CLASS(threadClass, obj);4647/* currDepth++ */48GET_INT_FIELD(currDepth, obj, threadClass, "currentDepth");49currDepth++;50SET_INT_FIELD(obj, threadClass, "currentDepth", currDepth);5152GET_STATIC_INT_FIELD(maxDepth, testClass, "DEPTH");535455if (maxDepth - currDepth > 0)56{57CALL_VOID_NOPARAM(obj, threadClass, "recursiveMethod");58}596061if (maxDepth == currDepth)62{63int alltime;6465GET_OBJ_FIELD(testField, obj, threadClass, "test",66"Lnsk/stress/strace/strace011;");6768MONITOR_ENTER(testField);69GET_STATIC_INT_FIELD(achivedCount, testClass, "achivedCount");70achivedCount++;71SET_STATIC_INT_FIELD(testClass, "achivedCount", achivedCount);72MONITOR_EXIT(testField);7374alltime = 0;75GET_STATIC_BOOL_FIELD(isLocked, testClass, "isLocked");7677while (isLocked != JNI_TRUE)78{79MONITOR_ENTER(testField);80CALL_VOID(testField, threadClass, "wait", Slongparam, 1LL);81alltime++;8283MONITOR_EXIT(testField);8485GET_STATIC_BOOL_FIELD(isLocked, testClass, "isLocked");86}8788GET_STATIC_OBJ_FIELD(lockedObject, testClass, "lockedObject",89"Ljava/lang/Object;");9091MONITOR_ENTER(testField);92GET_STATIC_INT_FIELD(achivedCount, testClass, "achivedCount");93achivedCount++;94SET_STATIC_INT_FIELD(testClass, "achivedCount", achivedCount);95MONITOR_EXIT(testField);969798/* printf("entering to monitor\n"); */99100MONITOR_ENTER(lockedObject);101102/* printf("exiting from monitor\n"); */103104MONITOR_EXIT(lockedObject);105}106107currDepth--;108GET_OBJECT_CLASS(threadClass, obj);109SET_INT_FIELD(obj, threadClass, "currentDepth", currDepth);110}111112}113114115