< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/share/locks/LockingThread.java

Print this page


   1 /*
   2  * Copyright (c) 2007, 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  */


 470         ready();
 471         doWait();
 472     }
 473 
 474     static synchronized void synchronizedStaticMethod(LockingThread lockingThread) {
 475         int currentStackDepth = lockingThread.expectedDepth();
 476 
 477         lockingThread.log("Enter synchronized static thread method");
 478 
 479         DebugMonitorInfo monitorInfo = new DebugMonitorInfo(LockingThread.class, currentStackDepth, lockingThread, false);
 480         lockingThread.addMonitorInfo(monitorInfo);
 481         lockingThread.createStackFrame();
 482         lockingThread.removeMonitorInfo(monitorInfo);
 483 
 484         lockingThread.log("Exit synchronized static thread method");
 485     }
 486 
 487     // calculate stack depth at which monitor was acquired
 488     int expectedDepth() {
 489         // for each monitor call 2 methods: createStackFrame() and method which acquire monitor
 490         // + when stack creation is finished call 3 methods: createStackFrame()->doWait()->sleep()
 491         return (stackFramesDescription.size() - currentIndex) * 2 + 3;
 492     }
 493 
 494     private native void nativeJNIMonitorEnter(Object object);
 495 
 496     synchronized void synchronizedMethod() {
 497         int currentStackDepth = expectedDepth();
 498 
 499         log("Enter synchronized thread method");
 500 
 501         DebugMonitorInfo monitorInfo = new DebugMonitorInfo(this, currentStackDepth, this, false);
 502         addMonitorInfo(monitorInfo);
 503         createStackFrame();
 504         removeMonitorInfo(monitorInfo);
 505 
 506         log("Exit synchronized thread method");
 507     }
 508 
 509     void synchronizedThisBlock() {
 510         int currentStackDepth = expectedDepth();
 511 


   1 /*
   2  * Copyright (c) 2007, 2019, 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  */


 470         ready();
 471         doWait();
 472     }
 473 
 474     static synchronized void synchronizedStaticMethod(LockingThread lockingThread) {
 475         int currentStackDepth = lockingThread.expectedDepth();
 476 
 477         lockingThread.log("Enter synchronized static thread method");
 478 
 479         DebugMonitorInfo monitorInfo = new DebugMonitorInfo(LockingThread.class, currentStackDepth, lockingThread, false);
 480         lockingThread.addMonitorInfo(monitorInfo);
 481         lockingThread.createStackFrame();
 482         lockingThread.removeMonitorInfo(monitorInfo);
 483 
 484         lockingThread.log("Exit synchronized static thread method");
 485     }
 486 
 487     // calculate stack depth at which monitor was acquired
 488     int expectedDepth() {
 489         // for each monitor call 2 methods: createStackFrame() and method which acquire monitor
 490         // + when stack creation is finished call 4 methods: createStackFrame()->doWait()->sleep()->sleep0()
 491         return (stackFramesDescription.size() - currentIndex) * 2 + 4;
 492     }
 493 
 494     private native void nativeJNIMonitorEnter(Object object);
 495 
 496     synchronized void synchronizedMethod() {
 497         int currentStackDepth = expectedDepth();
 498 
 499         log("Enter synchronized thread method");
 500 
 501         DebugMonitorInfo monitorInfo = new DebugMonitorInfo(this, currentStackDepth, this, false);
 502         addMonitorInfo(monitorInfo);
 503         createStackFrame();
 504         removeMonitorInfo(monitorInfo);
 505 
 506         log("Exit synchronized thread method");
 507     }
 508 
 509     void synchronizedThisBlock() {
 510         int currentStackDepth = expectedDepth();
 511 


< prev index next >