Example usage for java.lang.reflect Executable getExceptionTypes

List of usage examples for java.lang.reflect Executable getExceptionTypes

Introduction

In this page you can find the example usage for java.lang.reflect Executable getExceptionTypes.

Prototype

public abstract Class<?>[] getExceptionTypes();

Source Link

Document

Returns an array of Class objects that represent the types of exceptions declared to be thrown by the underlying executable represented by this object.

Usage

From source file:MyClass.java

public static ArrayList<String> getExceptionList(Executable exec) {
    ArrayList<String> exceptionList = new ArrayList<>();
    for (Class<?> c : exec.getExceptionTypes()) {
        exceptionList.add(c.getSimpleName());
    }/*from   w w  w  .ja  v  a  2s.co m*/
    return exceptionList;
}