/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @bug 5086470 6358247
* @summary SynchronizersLockingThread is used by LockedSynchronizers.
* It will create threads that acquire ReentrantLock and also object
* monitors.
* @author Mandy Chung
*
* @build ThreadDump Utils
*/
static void startLockingThreads() {
// wait until t1 and t2 waits
while (count != 0) {
try {
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
static long[] getThreadIds() {
}
int matches = 0;
matches++;
}
matches++;
}
}
if (matches != 2) {
throw new RuntimeException("MonitorInfo missing");
}
}
static class Lock {
}
return name;
}
}
int numOwnedMonitors;
int numOwnedSyncs;
this.threadName = name;
}
int numOwnedMonitors,
int numOwnedSyncs,
this.waitingLock = waitingLock;
this.numOwnedMonitors = numOwnedMonitors;
this.ownedMonitors = ownedMonitors;
this.waitingSync = waitingSync;
this.numOwnedSyncs = numOwnedSyncs;
this.ownedSyncs = ownedSyncs;
}
throw new RuntimeException("Number of locked monitors = " +
" not matched. Expected: " + numOwnedMonitors);
}
// check if each monitor returned in the list is the expected
// one
for (MonitorInfo m : monitors) {
int depth = m.getLockedStackDepth();
}
// check if each expected monitor is included in the returned
// list
}
}
// We can only check if the length matches since we have no
// way to get the AbstractOwnableSynchronizer in ReentrantLock
throw new RuntimeException("Number of locked syncs = " +
" not matched. Expected: " + numOwnedSyncs);
}
}
" not matched. Expected: " + getName());
}
throw new RuntimeException("LockInfo: " + l +
" not matched. Expected: non-null");
}
throw new RuntimeException("LockInfo: " + l +
" not matched. Expected: null");
}
int hcode;
if (waitingLock != null) {
} else {
}
throw new RuntimeException("LockInfo : " + l +
" class name not matched. Expected: " + waitingLockName);
}
if (hcode != l.getIdentityHashCode()) {
throw new RuntimeException("LockInfo: " + l +
" IdentityHashCode not matched. Expected: " + hcode);
}
" class name not matched. Expected: " + waitingLockName);
}
if (hcode != i) {
" IdentityHashCode not matched. Expected: " + hcode);
}
}
stacktrace[depth]);
throw new RuntimeException("LockedStackFrame does not match " +
"stack frame in ThreadInfo.getStackTrace");
}
}
hcode == m.getIdentityHashCode()) {
// monitor matched the expected
return;
}
}
}
}
throw new RuntimeException("Monitor not expected" + m);
}
for (MonitorInfo m : monitors) {
hcode == m.getIdentityHashCode() &&
return;
}
}
throw new RuntimeException("Monitor not found in the returned list" +
}
public Thread1() {
super("t1");
}
public void run() {
A();
}
void A() {
try {
try {
try {
B();
} finally {
}
} finally {
}
} finally {
}
}
void B() {
try {
synchronized(lock5) {
C();
}
} finally {
}
}
void C() {
synchronized(lock6) {
D();
}
}
void D() {
synchronized(lock7) {
try {
// signal to about to wait
count--;
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
void initExpectedResult() {
null,
}
}
public Thread2() {
super("t2");
this.setExpectedResult(null,
}
public void run() {
try {
synchronized(lock7) {
count--;
}
c.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
}
throw new RuntimeException("should not reach here");
}
}
}