2
|
1 |
#!/bin/sh
|
|
2 |
|
|
3 |
#
|
|
4 |
# Copyright 2002-2003 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
# CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
# have any 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 cont
|
|
92 |
cmd quit
|
|
93 |
}
|
|
94 |
|
|
95 |
|
|
96 |
mysetup()
|
|
97 |
{
|
|
98 |
if [ -z "$TESTSRC" ] ; then
|
|
99 |
TESTSRC=.
|
|
100 |
fi
|
|
101 |
|
|
102 |
for ii in . $TESTSRC $TESTSRC/.. ; do
|
|
103 |
if [ -r "$ii/ShellScaffold.sh" ] ; then
|
|
104 |
. $ii/ShellScaffold.sh
|
|
105 |
break
|
|
106 |
fi
|
|
107 |
done
|
|
108 |
}
|
|
109 |
|
|
110 |
# You could replace this next line with the contents
|
|
111 |
# of ShellScaffold.sh and this script will run just the same.
|
|
112 |
mysetup
|
|
113 |
|
|
114 |
runit
|
|
115 |
|
|
116 |
jdbFailIfNotPresent 'p1 = "ab"'
|
|
117 |
jdbFailIfNotPresent 'p2 = "2nd"'
|
|
118 |
jdbFailIfNotPresent 'm1l2 = 2'
|
|
119 |
jdbFailIfPresent 'm1l1'
|
|
120 |
|
|
121 |
jdbFailIfNotPresent 'args = instance of java.lang.String'
|
|
122 |
jdbFailIfNotPresent 'gus = 22'
|
|
123 |
jdbFailIfNotPresent 'kk = instance of shtest'
|
|
124 |
pass
|