1 #!/bin/sh 2 3 # 4 # Copyright (c) 2003, 2014 Oracle and/or its affiliates. All rights reserved. 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 # 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. 24 # 25 26 # @test 27 # @bug 4847812 28 # @summary TTY: jdb lock command displays incorrect data 29 # @author Jim Holmlund 30 # 31 # @run shell JdbLockTest.sh 32 33 # These are variables that can be set to control execution 34 35 #pkg=untitled7 36 classname=JdbLockTest 37 compileOptions=-g 38 #java="java_g" 39 40 createJavaFile() 41 { 42 cat <<EOF > $classname.java.1 43 public class $classname { 44 static String jj = "jj"; 45 public static void main(String args[]) { 46 synchronized(jj) { 47 sleeper xx = new sleeper(); 48 xx.start(); 49 // Give the sleeper a chance to run and get to 50 // the synchronized statement. 51 while(sleeper.started == 0) { 52 try { 53 Thread.sleep(100); 54 } catch(InterruptedException ee) { 55 } 56 } 57 // At this bkpt, sleeper should be waiting on $classname.jj 58 System.out.println("Hello sailor"); // @1 breakpoint 59 } 60 } 61 } 62 63 class sleeper extends Thread { 64 public static int started = 0; 65 public void run() { 66 started = 1; 67 System.out.println(" sleeper starts sleeping"); 68 synchronized($classname.jj) { 69 System.out.println(" sleeper got the lock"); 70 } 71 System.out.println(" sleeper awakes"); 72 } 73 } 74 75 EOF 76 } 77 78 79 # drive jdb by sending cmds to it and examining its output 80 dojdbCmds() 81 { 82 setBkpts @1 83 runToBkpt @1 84 # This should say that main owns the lock 85 # and the sleeper thread is waiting for it. 86 cmd lock $classname.jj 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