2
|
1 |
#!/bin/sh
|
|
2 |
|
|
3 |
#
|
5506
|
4 |
# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
2
|
5 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
6 |
#
|
|
7 |
# This code is free software; you can redistribute it and/or modify it
|
|
8 |
# under the terms of the GNU General Public License version 2 only, as
|
|
9 |
# published by the Free Software Foundation.
|
|
10 |
#
|
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
# accompanied this code).
|
|
16 |
#
|
|
17 |
# You should have received a copy of the GNU General Public License version
|
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
#
|
5506
|
21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
# or visit www.oracle.com if you need additional information or have any
|
|
23 |
# questions.
|
2
|
24 |
#
|
|
25 |
|
|
26 |
# @test
|
|
27 |
# @bug 4847812
|
|
28 |
# @summary TTY: jdb lock command displays incorrect data
|
|
29 |
# @author Jim Holmlund
|
|
30 |
# @run shell JdbLockTest.sh
|
|
31 |
|
|
32 |
# These are variables that can be set to control execution
|
|
33 |
|
|
34 |
#pkg=untitled7
|
|
35 |
classname=JdbLockTest
|
|
36 |
compileOptions=-g
|
|
37 |
#java="java_g"
|
|
38 |
|
|
39 |
createJavaFile()
|
|
40 |
{
|
|
41 |
cat <<EOF > $classname.java.1
|
|
42 |
public class $classname {
|
|
43 |
static String jj = "jj";
|
|
44 |
public static void main(String args[]) {
|
|
45 |
synchronized(jj) {
|
|
46 |
sleeper xx = new sleeper();
|
|
47 |
xx.start();
|
|
48 |
// Give the sleeper a chance to run and get to
|
|
49 |
// the synchronized statement.
|
|
50 |
while(sleeper.started == 0) {
|
|
51 |
try {
|
|
52 |
Thread.sleep(100);
|
|
53 |
} catch(InterruptedException ee) {
|
|
54 |
}
|
|
55 |
}
|
|
56 |
// At this bkpt, sleeper should be waiting on $classname.jj
|
|
57 |
System.out.println("Hello sailor"); // @1 breakpoint
|
|
58 |
}
|
|
59 |
}
|
|
60 |
}
|
|
61 |
|
|
62 |
class sleeper extends Thread {
|
|
63 |
public static int started = 0;
|
|
64 |
public void run() {
|
|
65 |
started = 1;
|
|
66 |
System.out.println(" sleeper starts sleeping");
|
|
67 |
synchronized($classname.jj) {
|
|
68 |
System.out.println(" sleeper got the lock");
|
|
69 |
}
|
|
70 |
System.out.println(" sleeper awakes");
|
|
71 |
}
|
|
72 |
}
|
|
73 |
|
|
74 |
EOF
|
|
75 |
}
|
|
76 |
|
|
77 |
|
|
78 |
# drive jdb by sending cmds to it and examining its output
|
|
79 |
dojdbCmds()
|
|
80 |
{
|
|
81 |
setBkpts @1
|
|
82 |
runToBkpt @1
|
|
83 |
# This should say that main owns the lock
|
|
84 |
# and the sleeper thread is waiting for it.
|
|
85 |
cmd lock $classname.jj
|
|
86 |
cmd quit
|
|
87 |
}
|
|
88 |
|
|
89 |
|
|
90 |
mysetup()
|
|
91 |
{
|
|
92 |
if [ -z "$TESTSRC" ] ; then
|
|
93 |
TESTSRC=.
|
|
94 |
fi
|
|
95 |
|
|
96 |
for ii in . $TESTSRC $TESTSRC/.. ; do
|
|
97 |
if [ -r "$ii/ShellScaffold.sh" ] ; then
|
|
98 |
. $ii/ShellScaffold.sh
|
|
99 |
break
|
|
100 |
fi
|
|
101 |
done
|
|
102 |
}
|
|
103 |
|
|
104 |
# You could replace this next line with the contents
|
|
105 |
# of ShellScaffold.sh and this script will run just the same.
|
|
106 |
mysetup
|
|
107 |
|
|
108 |
runit
|
|
109 |
jdbFailIfPresent "Waiting thread: main"
|
|
110 |
pass
|