1 #!/bin/sh 2 3 # 4 # Copyright (c) 2003, 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 4870984 28 # @summary JPDA: Add support for RFE 4856541 - varargs 29 # 30 # @author jjh 31 # 32 # @key intermittent 33 # @run shell JdbVarargsTest.sh 34 35 classname=JdbVarargsTest 36 createJavaFile() 37 { 38 cat <<EOF > $classname.java.1 39 public 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 } 63 EOF 64 } 65 66 67 # drive jdb by sending cmds to it and examining its output 68 dojdbCmds() 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 88 mysetup() 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. 104 mysetup 105 106 runit 107 jdbFailIfNotPresent "NONE" 108 jdbFailIfNotPresent "aabb" 109 jdbFailIfNotPresent "$classname varString\(java\.lang\.String\.\.\.\)" 110 jdbFailIfNotPresent 'Breakpoint hit:.*varString\(\)' 111 pass