blob: 72d9561f54ceb4879780375982eeeca7b8acf653 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001#!/bin/sh
2
3#
4# Copyright 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 4870984
28# @summary JPDA: Add support for RFE 4856541 - varargs
29#
30# @author jjh
31#
32# @run shell JdbVarargsTest.sh
33
34classname=JdbVarargsTest
35compileOptions="-source 1.5 -target 1.5"
36createJavaFile()
37{
38 cat <<EOF > $classname.java.1
39public class $classname {
40
41 public static void main(String args[]) {
42 int ii = 0; // @1 breakpoint
43
44 // Call the varargs method so the bkpt will be hit
45 varString(new String[] {"a", "b"});
46 }
47
48 static String varString(String... ss) {
49 if (ss == null) {
50 return "-null-";
51 }
52 if (ss.length == 0) {
53 return "NONE";
54 }
55 String retVal = "";
56 for (int ii = 0; ii < ss.length; ii++) {
57 retVal += ss[ii];
58 }
59 return retVal;
60 }
61
62}
63EOF
64}
65
66
67# drive jdb by sending cmds to it and examining its output
68dojdbCmds()
69{
70 setBkpts @1
71 runToBkpt @1
72
73 # check that 'methods' shows the ...
74 cmd methods "$classname"
75
76 # check that we can call with no args
77 cmd eval "$classname.varString();"
78
79 # check that we can call with var args
80 cmd eval "$classname.varString(\"aa\", \"bb\");"
81
82 # check that we can stop in ...
83 cmd stop in "$classname.varString(java.lang.String...)"
84 contToBkpt
85}
86
87
88mysetup()
89{
90 if [ -z "$TESTSRC" ] ; then
91 TESTSRC=.
92 fi
93
94 for ii in . $TESTSRC $TESTSRC/.. ; do
95 if [ -r "$ii/ShellScaffold.sh" ] ; then
96 . $ii/ShellScaffold.sh
97 break
98 fi
99 done
100}
101
102# You could replace this next line with the contents
103# of ShellScaffold.sh and this script will run just the same.
104mysetup
105
106runit
107jdbFailIfNotPresent "NONE"
108jdbFailIfNotPresent "aabb"
109jdbFailIfNotPresent "$classname varString\(java\.lang\.String\.\.\.\)"
110jdbFailIfNotPresent 'Breakpoint hit:.*varString\(\)'
111pass