According to Cannot Create, Catch, or Throw Objects of Parameterized Types (Java Tutorials):
You can, however, use a type parameter in a
throws
clause:class Parser<T extends Exception> { public void parse(File file) throws T { // OK // ... } }
But why would you want to? You can't construct T
here. If you inject T
after building it outside, isn't its stack trace going to be all wrong? Were they simply documenting a feature that happened to work regardless of it's usefulness?