test/jdk/com/sun/jdi/RedefineException.java
author amenkov
Fri, 21 Sep 2018 11:28:14 -0700
changeset 51837 46ca82c15f6c
parent 47216 test/jdk/com/sun/jdi/RedefineException.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 4559100
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    27
 * @summary The VM crashes when a method in a redefined class throws an exception.
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/RedefineException.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
 * @run main/othervm RedefineException
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    32
 */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    34
/* This is another symptomm of 4559100
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    35
 * This causes a bus error on solsparc:
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    36
 *  ---- called from signal handler with signal 10 (SIGBUS) ------
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    37
 *    [11] constantPoolOopDesc::klass_at_if_loaded(0xffbed4d8, 0x16, 0xffbed5cc, 0x0, 0x1, 0xfa40b330), at 0xfe11568c
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    38
 *    [12] methodOopDesc::fast_exception_handler_bci_for(0x6, 0x1, 0xfe400a0c, 0x0, 0x2d1f0, 0x0), at 0xfe12e620
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    39
 *    [13] jvmdi::post_exception_throw_event(0x2d1f0, 0xf61036f8, 0xf6103752, 0xf20414a8, 0x2e2928, 0xfe12e190), at 0xfe2a4fa4
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    40
 */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    42
import lib.jdb.JdbCommand;
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    43
import lib.jdb.JdbTest;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    45
class RedefineExceptionTarg {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    String str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    int ii;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    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
    49
        System.out.println("In Main");
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    50
        RedefineExceptionTarg mine = new RedefineExceptionTarg();
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    51
        mine.a1();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    public void a1() {
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    55
        int a1local = 1;
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    56
        String a1string = "a1";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    58
        ii = 89;                                 // @1 delete this line
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    59
        str = "foo";
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    60
        System.out.println("a1: Calling the original a2/a3.  'The @@@ deleted lines should appear");
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    61
        System.out.println("ii = " + ii);        // @1 delete this line
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    62
        a2();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public void a2() {
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    66
        int a2local = 2;
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    67
        String a2string = "a2";
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    68
        //System.out.println("a2: @ @@delete this line");
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    69
        try {
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    70
            a3();
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    71
        } catch (Exception ee) {
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    72
            System.out.println("a2: Exception caught");
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    73
        }
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    74
        System.out.println("a2: done");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
45028
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 32018
diff changeset
    76
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public void a3() throws Exception {
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    78
        int a3local = 3;
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    79
        String a3string = "a3";
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    80
        System.out.println("a3: @@ delete this line");   // If this line is deleted, the test passes!
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    81
        System.out.println("a3: @1 breakpoint here a3");
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    82
        throw new Exception("This is the exception");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    86
public class RedefineException extends JdbTest {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    88
    public static void main(String argv[]) {
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    89
        new RedefineException().run();
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    90
    }
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    91
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    92
    private RedefineException() {
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    93
        super(RedefineExceptionTarg.class.getName(), "RedefineException.java");
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    94
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
51837
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    96
    @Override
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    97
    protected void runCases() {
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    98
        setBreakpoints(1);
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
    99
        jdb.command(JdbCommand.run());
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
   100
        redefineClass(1);
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
   101
        jdb.command(JdbCommand.pop());
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
   102
        jdb.contToExit(1);
46ca82c15f6c 8210760: [TEST] rewrite com/sun/jdi shell tests to java version - step4
amenkov
parents: 47216
diff changeset
   103
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
}