goja-core/src/main/java/goja/core/kits/reflect/ReflectionKit.java
public static boolean declaresException(Method method, Class<?> exceptionType) {
        Preconditions.checkNotNull(method, "Method must not be null");
        Class<?>[] declaredExceptions = method.getExceptionTypes();
        for (Class<?> declaredException : declaredExceptions) {
            if (declaredException.isAssignableFrom(exceptionType)) {
                return true;
            }
        }
        return false;
    }
public static boolean declaresException(Method method, Class<?> exceptionType) {
        Preconditions.checkNotNull(method, "Method must not be null");
        Class<?>[] declaredExceptions = method.getExceptionTypes();
        for (Class<?> declaredException : declaredExceptions) {
            if (declaredException.isAssignableFrom(exceptionType)) {
                return true;
            }
        }
        return false;
    }
Determine whether the given method explicitly declares the given
exception or one of its superclasses, which means that an exception of
that type can be propagated as-is within a reflective invocation.

@param method        the declaring method
@param exceptionType the exception to throw
@return {@code true} if the exception can be thrown as-is;
{@code false} if it needs to be wrapped