class Bouncy extends Throwable {
}
// Error: the generic class Bouncy may not subclass java.lang.Throwable
Why doesn\'t Java
Here are a couple of things you can do:
interface Bouncy
{
// ...
}
class BouncyString extends Exception implements Bouncy
{
// ...
}
throws
clause can refer to type parameters, e.g.static
void
throwIfInstanceOf(Throwable ex, Class
clazz) throws X {
if (clazz.isInstance(ex)) throw clazz.cast(ex);
}