jdk/test/com/sun/jdi/EvalArraysAsList.sh
changeset 42676 36fa143f8de8
equal deleted inserted replaced
42675:179cd7a090cd 42676:36fa143f8de8
       
     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 #
       
    29 #  @run shell/timeout=300 EvalArraysAsList.sh
       
    30 #
       
    31 #  The test checks if evaluation of the expression java.util.Arrays.asList(null, "a")
       
    32 #  works normally and does not throw an IllegalArgumentException.
       
    33 
       
    34 classname=EvalArraysAsList
       
    35 
       
    36 createJavaFile()
       
    37 {
       
    38     cat <<EOF > $classname.java.1
       
    39 public class $classname {
       
    40     public static void main(String[] args) {
       
    41         java.util.List<Object> l = java.util.Arrays.asList(null, "a");
       
    42         System.out.println("java.util.Arrays.asList(null, \"a\") returns: " + l);
       
    43         return;    // @1 breakpoint
       
    44     }
       
    45 }
       
    46 EOF
       
    47 }
       
    48 
       
    49 # drive jdb by sending cmds to it and examining its output
       
    50 dojdbCmds()
       
    51 {
       
    52     setBkpts @1
       
    53     runToBkpt @1
       
    54 
       
    55     cmd eval "java.util.Arrays.asList(null, null)"
       
    56     jdbFailIfPresent "IllegalArgumentException" 3
       
    57 
       
    58     cmd eval "java.util.Arrays.asList(null, \"a\")"
       
    59     jdbFailIfPresent "IllegalArgumentException" 3
       
    60 
       
    61     cmd eval "java.util.Arrays.asList(\"a\", null)"
       
    62     jdbFailIfPresent "IllegalArgumentException" 3
       
    63 }
       
    64 
       
    65 
       
    66 mysetup()
       
    67 {
       
    68     if [ -z "$TESTSRC" ] ; then
       
    69         TESTSRC=.
       
    70     fi
       
    71 
       
    72     for ii in . $TESTSRC $TESTSRC/.. ; do
       
    73         if [ -r "$ii/ShellScaffold.sh" ] ; then
       
    74             . $ii/ShellScaffold.sh
       
    75             break
       
    76         fi
       
    77     done
       
    78 }
       
    79 
       
    80 # You could replace this next line with the contents
       
    81 # of ShellScaffold.sh and this script will run just the same.
       
    82 mysetup
       
    83 
       
    84 runit
       
    85 pass