1 #!/bin/sh 2 3 # 4 # Copyright (c) 2002, 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 4777868 28 # @summary Compile with java -g, do a RedefineClasses, and you don't get local vars 29 # @author Jim Holmlund 30 # 31 # @run shell Redefine-g.sh 32 #pkg=untitled7 33 34 # Compile the first version without -g and the 2nd version with -g. 35 compileOptions= 36 compileOptions2=-g 37 #java=java_g 38 39 # Uncomment this to see the JDI trace 40 # jdbOptions=-dbgtrace 41 42 createJavaFile() 43 { 44 cat <<EOF > $1.java.1 45 46 public class $1 { 47 public $1() { 48 } 49 public static void main(String[] args) { 50 int gus = 22; 51 $1 kk = new $1(); 52 kk.m1("ab"); 53 } 54 55 void m1(String p1) { 56 int m1l1 = 1; 57 System.out.println("m1(String) called"); 58 m1(p1, "2nd"); 59 // @1 uncomment System.out.println("Hello Milpitas!"); 60 } 61 62 void m1(String p1, String p2) { 63 int m1l2 = 2; 64 System.out.println("m2" + p1 + p2); // @1 breakpoint 65 } 66 67 } 68 EOF 69 } 70 71 # This is called to feed cmds to jdb. 72 dojdbCmds() 73 { 74 setBkpts @1 75 runToBkpt @1 76 cmd where 77 cmd locals 78 79 redefineClass @1 80 cmd where 81 cmd locals 82 83 cmd pop 84 cmd where 85 cmd locals 86 87 cmd pop 88 cmd where 89 cmd locals 90 91 cmd allowExit cont 92 } 93 94 95 mysetup() 96 { 97 if [ -z "$TESTSRC" ] ; then 98 TESTSRC=. 99 fi 100 101 for ii in . $TESTSRC $TESTSRC/.. ; do 102 if [ -r "$ii/ShellScaffold.sh" ] ; then 103 . $ii/ShellScaffold.sh 104 break 105 fi 106 done 107 } 108 109 # You could replace this next line with the contents 110 # of ShellScaffold.sh and this script will run just the same. 111 mysetup 112 113 runit 114 115 jdbFailIfNotPresent 'p1 = "ab"' 116 jdbFailIfNotPresent 'p2 = "2nd"' 117 jdbFailIfNotPresent 'm1l2 = 2' 118 jdbFailIfPresent 'm1l1' 119 120 jdbFailIfNotPresent 'args = instance of java.lang.String' 121 jdbFailIfNotPresent 'gus = 22' 122 jdbFailIfNotPresent 'kk = instance of shtest' 123 pass