jdk/test/com/sun/jdi/EvalInterfaceStatic.sh
author jbachorik
Tue, 29 Apr 2014 11:15:21 +0200
changeset 24125 b85eeaae56c7
permissions -rw-r--r--
8031195: Support default and static interface methods in JDI, JDWP and JDB Reviewed-by: sla, sspitsyn, dcubed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24125
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
     1
#!/bin/sh
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
     2
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
     3
#
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
     4
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
     6
#
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
     9
# published by the Free Software Foundation.
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    10
#
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    15
# accompanied this code).
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    16
#
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    20
#
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    23
# questions.
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    24
#
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    25
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    26
#  @test
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    27
#  @bug 8031195
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    28
#  @summary JDB allows evaluation of calls to static interface methods
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    29
#  @author Jaroslav Bachorik
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    30
#
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    31
#  @run shell/timeout=300 EvalInterfaceStatic.sh
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    32
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    33
#  The test exercises the ability to invoke static methods on interfaces.
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    34
#  Static interface methods are a new feature added in JDK8.
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    35
#
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    36
#  The test makes sure that it is, at all, possible to invoke an interface
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    37
#  static method and that the static methods are not inherited by extending
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    38
#  interfaces.
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    39
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    40
classname=EvalStaticInterfaces
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    41
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    42
createJavaFile()
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    43
{
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    44
    cat <<EOF > $classname.java.1
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    45
public interface $classname {
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    46
    static String staticMethod1() {
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    47
        return "base:staticMethod1";
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    48
    }
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    49
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    50
    static String staticMethod2() {
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    51
        return "base:staticMethod2";
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    52
    }
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    53
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    54
    public static void main(String[] args) {
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    55
        // prove that these work
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    56
        System.out.println("base staticMethod1(): " + $classname.staticMethod1());
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    57
        System.out.println("base staticMethod2(): " + $classname.staticMethod2());
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    58
        System.out.println("overridden staticMethod2(): " + Extended$classname.staticMethod2());
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    59
        System.out.println("base staticMethod3(): " + Extended$classname.staticMethod3());
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    60
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    61
        gus();
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    62
    }
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    63
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    64
    static void gus() {
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    65
        int x = 0;             // @1 breakpoint
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    66
    }
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    67
}
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    68
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    69
interface Extended$classname extends $classname {
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    70
    static String staticMethod2() {
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    71
        return "extended:staticMethod2";
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    72
    }
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    73
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    74
    static String staticMethod3() {
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    75
        return "extended:staticMethod3";
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    76
    }
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    77
}
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    78
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    79
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    80
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    81
EOF
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    82
}
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    83
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    84
# drive jdb by sending cmds to it and examining its output
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    85
dojdbCmds()
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    86
{
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    87
    setBkpts @1
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    88
    runToBkpt @1
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    89
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    90
    cmd eval "$classname.staticMethod1()"
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    91
    jdbFailIfNotPresent "base:staticMethod1" 2
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    92
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    93
    cmd eval "$classname.staticMethod2()"
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    94
    jdbFailIfNotPresent "base:staticMethod2" 2
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    95
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    96
    cmd eval "Extended$classname.staticMethod1()"
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    97
    jdbFailIfPresent "base:staticMethod1" 2
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    98
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
    99
    cmd eval "Extended$classname.staticMethod2()"
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   100
    jdbFailIfNotPresent "extended:staticMethod2" 2
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   101
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   102
    cmd eval "Extended$classname.staticMethod3()"
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   103
    jdbFailIfNotPresent "extended:staticMethod3" 2
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   104
}
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   105
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   106
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   107
mysetup()
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   108
{
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   109
    if [ -z "$TESTSRC" ] ; then
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   110
        TESTSRC=.
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   111
    fi
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   112
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   113
    for ii in . $TESTSRC $TESTSRC/.. ; do
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   114
        if [ -r "$ii/ShellScaffold.sh" ] ; then
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   115
            . $ii/ShellScaffold.sh
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   116
            break
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   117
        fi
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   118
    done
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   119
}
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   120
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   121
# You could replace this next line with the contents
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   122
# of ShellScaffold.sh and this script will run just the same.
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   123
mysetup
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   124
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   125
runit
b85eeaae56c7 8031195: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents:
diff changeset
   126
pass