blob: 00bec2a7cc084f0b6dd9717ee4190cc74f1ff822 [file] [log] [blame]
Denis Vnukov87d7f6c2017-05-23 16:26:41 -07001// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4package nestedtrycatches;
5
6public class NestedTryCatches {
7 private static void throwException() {
8 throw new RuntimeException("IGNORED");
9 }
10
11 private static void test() throws Throwable {
12 RuntimeException _primaryExc = null;
13 try {
14 throw new RuntimeException("PRIMARY");
15 } catch (RuntimeException _t) {
16 _primaryExc = _t;
17 throw _t;
18 } finally {
19 // Keep the two calls to throwException() the same line
20 if(_primaryExc!=null) {
21 try {
22 throwException();
23 } catch(Throwable _suppressed) {
24 }
25 } else {
26 throwException();
27 }
28 }
29 }
30
31 public static void main(String[] args) throws Exception {
32 try {
33 test();
34 } catch (Throwable e) {
35 System.out.println("EXCEPTION: " + e.getMessage());
36 }
37 }
38}