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 # @run shell RedefineException.sh 32 33 # This is another symptomm of 4559100 34 # This causes a bus error on solsparc: 35 # ---- called from signal handler with signal 10 (SIGBUS) ------ 36 # [11] constantPoolOopDesc::klass_at_if_loaded(0xffbed4d8, 0x16, 0xffbed5cc, 0x0, 0x1, 0xfa40b330), at 0xfe11568c 37 # [12] methodOopDesc::fast_exception_handler_bci_for(0x6, 0x1, 0xfe400a0c, 0x0, 0x2d1f0, 0x0), at 0xfe12e620 38 # [13] jvmdi::post_exception_throw_event(0x2d1f0, 0xf61036f8, 0xf6103752, 0xf20414a8, 0x2e2928, 0xfe12e190), at 0xfe2a4fa4 39 40 # These are variables that can be set to control execution 41 42 createJavaFile() 43 { 44 cat <<EOF > $1.java.1 45 46 public class $1 { 47 String str; 48 int ii; 49 static public void main(String[] args) { 50 System.out.println("In Main"); 51 $1 mine = new $1(); 52 mine.a1(); 53 } 54 55 public void a1() { 56 int a1local = 1; 57 String a1string = "a1"; 58 59 ii = 89; // @1 delete this line 60 str = "foo"; 61 System.out.println("a1: Calling the original a2/a3. 'The @@@ deleted lines should appear"); 62 System.out.println("ii = " + ii); // @1 delete this line 63 a2(); 64 } 65 66 public void a2() { 67 int a2local = 2; 68 String a2string = "a2"; 69 //System.out.println("a2: @ @@delete this line"); 70 try { 71 a3(); 72 } catch (Exception ee) { 73 System.out.println("a2: Exception caught"); 74 } 75 System.out.println("a2: done"); 76 } 77 78 public void a3() throws Exception { 79 int a3local = 3; 80 String a3string = "a3"; 81 System.out.println("a3: @@ delete this line"); // If this line is deleted, the test passes! 82 System.out.println("a3: @1 breakpoint here a3"); 83 throw new Exception("This is the exception"); 84 } 85 } 86 EOF 87 } 88 89 dojdbCmds() 90 { 91 setBkpts @1 92 runToBkpt 93 redefineClass @1 94 cmd pop 95 cmd allowExit cont 96 } 97 98 99 mysetup() 100 { 101 if [ -z "$TESTSRC" ] ; then 102 TESTSRC=. 103 fi 104 105 for ii in . $TESTSRC $TESTSRC/.. ; do 106 if [ -r "$ii/ShellScaffold.sh" ] ; then 107 . $ii/ShellScaffold.sh 108 break 109 fi 110 done 111 } 112 113 # You could replace this next line with the contents 114 # of ShellScaffold.sh and this script will run just the same. 115 mysetup 116 117 runit 118 pass