1 #!/bin/sh 2 # 3 # Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 # 6 # This code is free software; you can redistribute it and/or modify it 7 # under the terms of the GNU General Public License version 2 only, as 8 # published by the Free Software Foundation. 9 # 10 # This code is distributed in the hope that it will be useful, but WITHOUT 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 # version 2 for more details (a copy is included in the LICENSE file that 14 # accompanied this code). 15 # 16 # You should have received a copy of the GNU General Public License version 17 # 2 along with this work; if not, write to the Free Software Foundation, 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 # 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 # or visit www.oracle.com if you need additional information or have any 22 # questions. 23 # 24 25 # @test 26 # @bug 8160024 27 # @summary jdb returns invalid argument count if first parameter to Arrays.asList is null 28 # The test checks if evaluation of the expression java.util.Arrays.asList(null, "a") 29 # works normally and does not throw an IllegalArgumentException. 30 # 31 # @run shell/timeout=300 EvalArraysAsList.sh 32 # 33 34 35 classname=EvalArraysAsList 36 37 createJavaFile() 38 { 39 cat <<EOF > $classname.java.1 40 public class $classname { 41 public static void main(String[] args) { 42 java.util.List<Object> l = java.util.Arrays.asList(null, "a"); 43 System.out.println("java.util.Arrays.asList(null, \"a\") returns: " + l); 44 return; // @1 breakpoint 45 } 46 } 47 EOF 48 } 49 50 # drive jdb by sending cmds to it and examining its output 51 dojdbCmds() 52 { 53 setBkpts @1 54 runToBkpt @1 55 56 cmd eval "java.util.Arrays.asList(null, null)" 57 jdbFailIfPresent "IllegalArgumentException" 3 58 59 cmd eval "java.util.Arrays.asList(null, \"a\")" 60 jdbFailIfPresent "IllegalArgumentException" 3 61 62 cmd eval "java.util.Arrays.asList(\"a\", null)" 63 jdbFailIfPresent "IllegalArgumentException" 3 64 } 65 66 67 mysetup() 68 { 69 if [ -z "$TESTSRC" ] ; then 70 TESTSRC=. 71 fi 72 73 for ii in . $TESTSRC $TESTSRC/.. ; do 74 if [ -r "$ii/ShellScaffold.sh" ] ; then 75 . $ii/ShellScaffold.sh 76 break 77 fi 78 done 79 } 80 81 # You could replace this next line with the contents 82 # of ShellScaffold.sh and this script will run just the same. 83 mysetup 84 85 runit 86 pass