| // Copyright (c) 2022, the R8 project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| package twraddsuppressed; |
| import java.io.Closeable; |
| public static class MyClosable implements Closeable { |
| throw new RuntimeException("CLOSE"); |
| public static void foo() { |
| throw new RuntimeException("FOO"); |
| public static void bar() { |
| // NOTE: The $closeResource helper is _only_ generated by the JDK-9 compiler. |
| // Use twr twice to have javac generate a shared $closeResource helper. |
| try (MyClosable closable = new MyClosable()) { |
| try (MyClosable closable = new MyClosable()) { |
| public static void main(String[] args) { |
| Throwable[] suppressed = e.getSuppressed(); |
| if (suppressed.length == 0) { |
| System.out.println("NONE"); |
| for (Throwable throwable : suppressed) { |
| System.out.println(throwable.getMessage()); |