test/jdk/com/sun/jdi/GetLocalVariables4Test.java
author amenkov
Fri, 31 Aug 2018 09:53:37 -0700
changeset 51611 2ef81feac8b8
parent 47216 test/jdk/com/sun/jdi/GetLocalVariables4Test.sh@71c04702a3d5
permissions -rw-r--r--
8067354: com/sun/jdi/GetLocalVariables4Test.sh failed Reviewed-by: jcbeyler, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51611
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
     1
/*
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
     2
 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
     4
 *
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
     7
 * published by the Free Software Foundation.
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
     8
 *
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    13
 * accompanied this code).
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    14
 *
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    18
 *
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    21
 * questions.
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    22
 */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
51611
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    24
/*
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    25
 * @test
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    26
 * @bug 4070747 4486859
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    27
 * @summary Compiler fails to generate local var tbl entry for exception passed to catch
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    28
 * @comment converted from test/jdk/com/sun/jdi/GetLocalVariables4Test.sh
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    29
 *
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    30
 * @library /test/lib
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    31
 * @compile -g GetLocalVariables4Test.java
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    32
 * @run main/othervm GetLocalVariables4Test
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    33
 */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
51611
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    35
import jdk.test.lib.process.OutputAnalyzer;
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    36
import lib.jdb.JdbCommand;
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    37
import lib.jdb.JdbTest;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
51611
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    39
class GetLocalVariables4Targ {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        System.out.println("Howdy!");
23057
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    42
        int i = 0;
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    43
        try {
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    44
            i = 16 / i;
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    45
        } catch(Exception e) {
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    46
            System.out.println("e should be visible");    // @1 breakpoint
c67ddf10398e 8036132: Tab characters in test/com/sun/jdi files
sla
parents: 23046
diff changeset
    47
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        System.out.println("Goodbye from GetLocalVariables4Targ!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
}
51611
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    51
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    52
public class GetLocalVariables4Test extends JdbTest {
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    53
    public static void main(String argv[]) {
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    54
        new GetLocalVariables4Test().run();
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    55
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
51611
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    57
    private GetLocalVariables4Test() {
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    58
        super(DEBUGGEE_CLASS);
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    59
    }
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    60
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    61
    private static final String DEBUGGEE_CLASS = GetLocalVariables4Targ.class.getName();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
51611
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    63
    @Override
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    64
    protected void runCases() {
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    65
        setBreakpointsFromTestSource("GetLocalVariables4Test.java", 1);
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    66
        // Run to breakpoint #1
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    67
        jdb.command(JdbCommand.run());
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    68
        jdb.command(JdbCommand.locals());
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    69
        jdb.contToExit(1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
51611
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    71
        new OutputAnalyzer(getJdbOutput())
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    72
                .shouldContain("e = instance of java.lang.ArithmeticException");
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    73
        new OutputAnalyzer(getDebuggeeOutput())
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    74
                .shouldContain("Howdy")
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    75
                .shouldContain("Goodbye from GetLocalVariables4Targ");
2ef81feac8b8 8067354: com/sun/jdi/GetLocalVariables4Test.sh failed
amenkov
parents: 47216
diff changeset
    76
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
}