1 /* 2 * Copyright (c) 2014, 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 8059299 27 * @summary assert(adr_type != NULL) failed: expecting TypeKlassPtr 28 * @run main/othervm -Xbatch CatchInlineExceptions 29 */ 30 31 class Exception1 extends Exception {}; 32 class Exception2 extends Exception {}; 33 34 public class CatchInlineExceptions { 35 private static int counter0; 36 private static int counter1; 37 private static int counter2; 38 private static int counter; 39 40 static void foo(int i) throws Exception { 41 if ((i & 1023) == 2) { 42 counter0++; 43 throw new Exception2(); 44 } 45 } 46 47 static void test(int i) throws Exception { 48 try { 49 foo(i); 50 } 51 catch (Exception e) { 52 if (e instanceof Exception1) { 53 counter1++; 54 } else if (e instanceof Exception2) { 55 counter2++; 56 } 57 counter++; 58 throw e; 59 } 60 } 61 62 public static void main(String[] args) throws Throwable { 63 for (int i = 0; i < 15000; i++) { 64 try { 65 test(i); 66 } catch (Exception e) { 67 // expected 68 } 69 } 70 if (counter1 != 0) { 71 throw new RuntimeException("Failed: counter1(" + counter1 + ") != 0"); 72 } 73 if (counter2 != counter) { 74 throw new RuntimeException("Failed: counter2(" + counter2 + ") != counter0(" + counter0 + ")"); 75 } 76 if (counter2 != counter) { 77 throw new RuntimeException("Failed: counter2(" + counter2 + ") != counter(" + counter + ")"); 78 } 79 System.out.println("TEST PASSED"); 80 } 81 }