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