The following Groovy code prints \"it works\"
def printIt(Class extends Exception> clazz) { println \"it works\" } printIt(String.class) <
def printIt(Class extends Exception> clazz) { println \"it works\" } printIt(String.class)
Since you know it's supposed to be an Exception, this works in Java (or Groovy):
// true if the class is a subclass of Exception Exception.class.isAssignableFrom(clazz);
That in no way uses the generic information, but that wouldn't be available in Java either.