test/jdk/com/sun/jdi/JdbMissStep.java
author iignatyev
Fri, 14 Sep 2018 14:02:57 -0700
changeset 51754 594919232b8f
parent 51648 b7b69bc93a2d
permissions -rw-r--r--
8210732: remove jdk.testlibrary.Utils Reviewed-by: alanb, jcbeyler
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51648
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
     1
/*
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
     2
 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
     4
 *
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
     8
 *
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    13
 * accompanied this code).
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    14
 *
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    18
 *
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    21
 * questions.
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    22
 */
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    23
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    24
/*
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    25
 * @test
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    26
 * @bug 4762765
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    27
 * @summary REGRESSION: jdb / jdi not stopping at some breakpoints and steps in j2sdk1.4.
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    28
 * @comment converted from test/jdk/com/sun/jdi/JdbMissStep.sh
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    29
 *
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    30
 * @library /test/lib
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    31
 * @compile -g JdbMissStep.java
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    32
 * @run main/othervm JdbMissStep
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    33
 */
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    34
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    35
import jdk.test.lib.process.OutputAnalyzer;
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    36
import lib.jdb.JdbCommand;
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    37
import lib.jdb.JdbTest;
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    38
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    39
class JdbMissStepTarg {
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    40
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    41
    public static void main(String args[]) {
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    42
        JdbMissStepTarg dbb = new JdbMissStepTarg();
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    43
        System.out.println("ANSWER IS: " + dbb.getIntVal());
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    44
        jj2 gus = new jj2();
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    45
        System.out.println("ANSWER2 IS: " + gus.getIntVal());
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    46
    }
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    47
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    48
    static int statVal;
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    49
    int intVal = 89;
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    50
    public int getIntVal() {
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    51
        return intVal;  //@ 1 breakpoint
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    52
    }
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    53
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    54
    static class jj2 {
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    55
        static int statVal;
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    56
        int intVal = 89;
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    57
        public int getIntVal() {
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    58
            return intVal;  //@1 breakpoint  line 20
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    59
        }
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    60
    }
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    61
}
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    62
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    63
public class JdbMissStep extends JdbTest {
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    64
    public static void main(String argv[]) {
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    65
        new JdbMissStep().run();
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    66
    }
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    67
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    68
    private JdbMissStep() {
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    69
        super(DEBUGGEE_CLASS);
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    70
    }
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    71
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    72
    private static final String DEBUGGEE_CLASS = JdbMissStepTarg.class.getName();
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    73
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    74
    @Override
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    75
    protected void runCases() {
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    76
        setBreakpoints(jdb, DEBUGGEE_CLASS + "$jj2", System.getProperty("test.src") + "/JdbMissStep.java", 1);
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    77
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    78
        jdb.command(JdbCommand.run());
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    79
        jdb.command(JdbCommand.step());
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    80
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    81
        new OutputAnalyzer(jdb.getJdbOutput())
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    82
                .shouldContain("Breakpoint hit");
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    83
    }
b7b69bc93a2d 8210243: [TEST] rewrite com/sun/jdi shell tests to java version - step3
amenkov
parents:
diff changeset
    84
}