Skip to content

Instantly share code, notes, and snippets.

@aldaris
Created October 19, 2017 11:06
Show Gist options
  • Save aldaris/b092af95f47c9f76bc8bb0d97761da7d to your computer and use it in GitHub Desktop.
Save aldaris/b092af95f47c9f76bc8bb0d97761da7d to your computer and use it in GitHub Desktop.
Java 9 compilation error
public class Java9 {
public static void main(String[] args) throws Exception {
hello("foo", () -> doSomething("bad Java9", "test"));
}
public static <E extends Exception> void hello(String text, Foo<E> foo) throws Exception {
foo.run();
}
public static <T, E extends Exception> void hello(String text, Bar<T, E> bar) throws Exception {
bar.run();
}
public static <T extends CharSequence> void doSomething(String hello, T world) throws IllegalStateException {
System.out.println("hello" + world);
}
@FunctionalInterface
interface Foo<E extends Exception> {
void run() throws E;
}
@FunctionalInterface
interface Bar<T, E extends Exception> {
T run() throws E;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment