|
|
|
|
|
by auno
1219 days ago
|
|
> Java isn't generic over exceptions. You can't write a method that takes an instance of Foo and says "my method throws whatever Foo.bar() throws" If you bend over far enough backwards, and squint a bit, you can kind of do that... interface Runner<E extends Throwable> {
public void run() throws E;
}
class Test {
public static <E extends Throwable, T extends Runner<E>> void test(T runner) throws E {
runner.run();
}
}
It compiles. I haven't tried running it though. |
|