test/jdk/com/sun/jdi/RedefineStep.java
author amenkov
Fri, 21 Sep 2018 11:28:14 -0700
changeset 51837 46ca82c15f6c
parent 47216 test/jdk/com/sun/jdi/RedefineStep.sh@71c04702a3d5
permissions -rw-r--r--
8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4 Reviewed-by: jcbeyler, sspitsyn, cjplummer
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
     1
/*
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
     2
 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
     4
 *
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
     7
 * published by the Free Software Foundation.
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
     8
 *
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    13
 * accompanied this code).
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    14
 *
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    18
 *
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    21
 * questions.
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    22
 */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    24
/*
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    25
 * @test
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    26
 * @bug 4689395
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    27
 * @summary "step over" after a class is redefined acts like "step out"
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    28
 * @comment converted from test/jdk/com/sun/jdi/RedefineStep.sh
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    29
 *
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    30
 * @library /test/lib
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    31
 * @compile -g RedefineStep.java
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    32
 * @run main/othervm RedefineStep
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    33
 */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    35
import jdk.test.lib.process.OutputAnalyzer;
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    36
import lib.jdb.JdbCommand;
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    37
import lib.jdb.JdbTest;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    39
class RedefineStepTarg {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    static int counter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    static public void main(String[] args) {
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    42
        RedefineStepTarg mine = new RedefineStepTarg();
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    43
        mine.a1(10);
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    44
        System.out.println("done");  // should not see this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    public void a1(int p1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        System.out.println("jj0");   // @1 breakpoint   line 10
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        a2();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        System.out.println("jj3");    // @1 delete
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    public void a2() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        System.out.println("a2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
}
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    56
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    57
public class RedefineStep extends JdbTest {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    59
    public static void main(String argv[]) {
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    60
        new RedefineStep().run();
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    61
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    63
    private RedefineStep() {
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    64
        super(RedefineStepTarg.class.getName(), "RedefineStep.java");
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    65
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    67
    @Override
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    68
    protected void runCases() {
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    69
        setBreakpoints(1);
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    70
        jdb.command(JdbCommand.run());
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    71
        redefineClass(1, "-g");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    73
        jdb.command(JdbCommand.next());
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    74
        jdb.command(JdbCommand.next());
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    75
        jdb.command(JdbCommand.next());
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    76
        jdb.command(JdbCommand.next());
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    77
        jdb.command(JdbCommand.next());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    79
        new OutputAnalyzer(getJdbOutput())
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    80
                .shouldNotContain("should not see this");
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    81
    }
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    82
}