T8074381b.java revision 2854:42098d16d8f9
1/*
2 * @test /nodynamiccopyright/
3 * @bug 8074381
4 * @summary java.lang.AssertionError during compiling
5 * @compile/fail/ref=T8074381b.out -XDrawDiagnostics T8074381b.java
6 */
7import java.util.function.BiConsumer;
8import java.util.function.Consumer;
9
10class T8074381b {
11
12    @SuppressWarnings("unchecked")
13    public Invocation resolve(Handler handler) {
14        return new Invocation((t) -> handler.handle((String) t));
15    }
16
17    public static class Handler {
18        public void handle(String s) {
19            System.out.println(s);
20        }
21    }
22
23    public static class Invocation<T> {
24        public final ThrowingConsumer<T> consumer;
25
26        public Invocation(final ThrowingConsumer<T> consumer) {
27            this.consumer = consumer;
28        }
29    }
30
31    @FunctionalInterface
32    public interface ThrowingConsumer<T> extends BiConsumer<T,Consumer<Throwable>> {
33        @Override
34        default void accept(final T elem, final Consumer<Throwable> errorHandler) {
35            try {
36                acceptThrows(elem);
37            } catch (final Throwable e) {
38                errorHandler.accept(e);
39            }
40        }
41
42        void acceptThrows(T elem) throws Throwable;
43    }
44}
45