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 # @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 } 87 88 89 mysetup() 90 { 91 if [ -z "$TESTSRC" ] ; then 92 TESTSRC=. 93 fi 94 95 for ii in . $TESTSRC $TESTSRC/.. ; do 96 if [ -r "$ii/ShellScaffold.sh" ] ; then 97 . $ii/ShellScaffold.sh 98 break 99 fi 100 done 101 } 102 103 # You could replace this next line with the contents 104 # of ShellScaffold.sh and this script will run just the same. 105 mysetup 106 107 runit 108 jdbFailIfPresent "Waiting thread: main" 109 pass