Java examples for java.lang.annotation:Method Annotation
Tests if a method throws a checked exception from enterprise annotation method.
import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import javax.enterprise.inject.spi.Annotated; import javax.enterprise.inject.spi.AnnotatedMethod; import javax.enterprise.inject.spi.AnnotatedParameter; import javax.enterprise.inject.spi.AnnotatedType; public class Main{ /**/*w ww. j av a 2 s . co m*/ * Tests if a method throws a checked exception. */ public static boolean hasException(AnnotatedMethod<?> method, Class<?> exn) { Class<?>[] methodExceptions = method.getJavaMember() .getExceptionTypes(); for (int j = 0; j < methodExceptions.length; j++) { if (methodExceptions[j].isAssignableFrom(exn)) return true; } return false; } }