1 /* 2 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 4070747 4486859 27 * @summary Compiler fails to generate local var tbl entry for exception passed to catch 28 * @comment converted from test/jdk/com/sun/jdi/GetLocalVariables4Test.sh 29 * 30 * @library /test/lib 31 * @compile -g GetLocalVariables4Test.java 32 * @run main/othervm GetLocalVariables4Test 33 */ 34 35 import jdk.test.lib.process.OutputAnalyzer; 36 import lib.jdb.JdbCommand; 37 import lib.jdb.JdbTest; 38 39 class GetLocalVariables4Targ { main(String[] args)40 public static void main(String[] args) { 41 System.out.println("Howdy!"); 42 int i = 0; 43 try { 44 i = 16 / i; 45 } catch(Exception e) { 46 System.out.println("e should be visible"); // @1 breakpoint 47 } 48 System.out.println("Goodbye from GetLocalVariables4Targ!"); 49 } 50 } 51 52 public class GetLocalVariables4Test extends JdbTest { main(String argv[])53 public static void main(String argv[]) { 54 new GetLocalVariables4Test().run(); 55 } 56 GetLocalVariables4Test()57 private GetLocalVariables4Test() { 58 super(DEBUGGEE_CLASS); 59 } 60 61 private static final String DEBUGGEE_CLASS = GetLocalVariables4Targ.class.getName(); 62 63 @Override runCases()64 protected void runCases() { 65 setBreakpointsFromTestSource("GetLocalVariables4Test.java", 1); 66 // Run to breakpoint #1 67 jdb.command(JdbCommand.run()); 68 jdb.command(JdbCommand.locals()); 69 jdb.contToExit(1); 70 71 new OutputAnalyzer(getJdbOutput()) 72 .shouldContain("e = instance of java.lang.ArithmeticException"); 73 new OutputAnalyzer(getDebuggeeOutput()) 74 .shouldContain("Howdy") 75 .shouldContain("Goodbye from GetLocalVariables4Targ"); 76 } 77 } 78