jdk/test/com/sun/jdi/RedefineException.sh
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 5506 202f599c92aa
child 23046 0b0407b1e2a5
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#!/bin/sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     4
# Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
# published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
# questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#  @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#  @bug 4559100
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#  @summary The VM crashes when a method in a redefined class throws an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#  @author Jim Holmlund
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#  @run shell RedefineException.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
# This is another symptomm of 4559100
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
# This causes a bus error on solsparc:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#  ---- called from signal handler with signal 10 (SIGBUS) ------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#  [11] constantPoolOopDesc::klass_at_if_loaded(0xffbed4d8, 0x16, 0xffbed5cc, 0x0, 0x1, 0xfa40b330), at 0xfe11568c
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#  [12] methodOopDesc::fast_exception_handler_bci_for(0x6, 0x1, 0xfe400a0c, 0x0, 0x2d1f0, 0x0), at 0xfe12e620
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#  [13] jvmdi::post_exception_throw_event(0x2d1f0, 0xf61036f8, 0xf6103752, 0xf20414a8, 0x2e2928, 0xfe12e190), at 0xfe2a4fa4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
# These are variables that can be set to control execution
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
createJavaFile()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    cat <<EOF > $1.java.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
public class $1 {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    String str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    int ii;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    static public void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
       System.out.println("In Main");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
       $1 mine = new $1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
       mine.a1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    public void a1() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
      int a1local = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
      String a1string = "a1";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
      ii = 89;                                 // @1 delete this line
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
      str = "foo";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
      System.out.println("a1: Calling the original a2/a3.  'The @@@ deleted lines should appear");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
      System.out.println("ii = " + ii);        // @1 delete this line
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
      a2();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    public void a2() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
      int a2local = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
      String a2string = "a2";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
      //System.out.println("a2: @ @@delete this line");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
      try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        a3();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
      } catch (Exception ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        System.out.println("a2: Exception caught");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
      System.out.println("a2: done");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
  
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public void a3() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
      int a3local = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
      String a3string = "a3";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
      System.out.println("a3: @@ delete this line");   // If this line is deleted, the test passes!
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
      System.out.println("a3: @1 breakpoint here a3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
      throw new Exception("This is the exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
dojdbCmds()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    setBkpts @1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    runToBkpt
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    redefineClass @1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    cmd pop
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    cmd cont
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    cmd quit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
mysetup()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    if [ -z "$TESTSRC" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        TESTSRC=.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    for ii in . $TESTSRC $TESTSRC/.. ; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        if [ -r "$ii/ShellScaffold.sh" ] ; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            . $ii/ShellScaffold.sh 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
# You could replace this next line with the contents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
# of ShellScaffold.sh and this script will run just the same.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
mysetup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
runit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
pass