Java Code Examples for java.lang.reflect.InvocationTargetException#addSuppressed()

The following examples show how to use java.lang.reflect.InvocationTargetException#addSuppressed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventDispatcher.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes component method through
 * {@code SwingUtilities.invokeAndWait(Runnable)}.
 *
 * @param method_name Name of a method to be invoked
 * @param params Method params
 * @param params_classes Method params' classes
 * @return an Object - methods result.
 * @see org.netbeans.jemmy.ClassReference
 * @exception IllegalAccessException
 * @exception NoSuchMethodException
 * @exception IllegalStateException
 * @exception InvocationTargetException
 */
public Object invokeMethod(String method_name, Object[] params, Class<?>[] params_classes)
        throws InvocationTargetException, IllegalStateException, NoSuchMethodException, IllegalAccessException {
    Invoker invk = new Invoker(method_name, params, params_classes);
    try {
        return queueTool.invokeAndWait(invk);
    } catch (JemmyException e) {
        Exception ex = invk.getException();
        if (ex != null) {
            if (ex instanceof InvocationTargetException) {
                InvocationTargetException ite = (InvocationTargetException) ex;
                ite.addSuppressed(e);
                throw ite;
            } else if (ex instanceof IllegalStateException) {
                IllegalStateException ise = (IllegalStateException) ex;
                ise.addSuppressed(e);
                throw ise;
            } else if (ex instanceof NoSuchMethodException) {
                NoSuchMethodException nsme = (NoSuchMethodException) ex;
                nsme.addSuppressed(e);
                throw nsme;
            } else if (ex instanceof IllegalAccessException) {
                IllegalAccessException iae = (IllegalAccessException) ex;
                iae.addSuppressed(e);
                throw iae;
            } else {
                e.addSuppressed(ex);
            }
        }
        throw (e);
    }
}
 
Example 2
Source File: EventDispatcher.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets component field value through
 * {@code SwingUtilities.invokeAndWait(Runnable)}.
 *
 * @param field_name Name of a field
 * @see #setField(String, Object)
 * @see org.netbeans.jemmy.ClassReference
 * @return an Object - field value
 * @exception IllegalAccessException
 * @exception IllegalStateException
 * @exception InvocationTargetException
 * @exception NoSuchFieldException
 */
public Object getField(String field_name)
        throws InvocationTargetException, IllegalStateException, NoSuchFieldException, IllegalAccessException {
    Getter gtr = new Getter(field_name);
    try {
        return queueTool.invokeAndWait(gtr);
    } catch (JemmyException e) {
        Exception ex = gtr.getException();
        if (ex != null) {
            if (ex instanceof InvocationTargetException) {
                InvocationTargetException ite = (InvocationTargetException) ex;
                ite.addSuppressed(e);
                throw ite;
            } else if (ex instanceof IllegalStateException) {
                IllegalStateException ise = (IllegalStateException) ex;
                ise.addSuppressed(e);
                throw ise;
            } else if (ex instanceof NoSuchFieldException) {
                NoSuchFieldException nsfe = (NoSuchFieldException) ex;
                nsfe.addSuppressed(e);
                throw nsfe;
            } else if (ex instanceof IllegalAccessException) {
                IllegalAccessException iae = (IllegalAccessException) ex;
                iae.addSuppressed(e);
                throw iae;
            } else {
                e.addSuppressed(ex);
            }
        }
        throw (e);
    }
}
 
Example 3
Source File: EventDispatcher.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets component field value through
 * {@code SwingUtilities.invokeAndWait(Runnable)}.
 *
 * @param field_name Name of a field
 * @param newValue New field value
 * @see #getField(String)
 * @see org.netbeans.jemmy.ClassReference
 * @exception IllegalAccessException
 * @exception IllegalStateException
 * @exception InvocationTargetException
 * @exception NoSuchFieldException
 */
public void setField(String field_name, Object newValue)
        throws InvocationTargetException, IllegalStateException, NoSuchFieldException, IllegalAccessException {
    Setter str = new Setter(field_name, newValue);
    try {
        queueTool.invokeAndWait(str);
    } catch (JemmyException e) {
        Exception ex = str.getException();
        if (ex != null) {
            if (ex instanceof InvocationTargetException) {
                InvocationTargetException ite = (InvocationTargetException) ex;
                ite.addSuppressed(e);
                throw ite;
            } else if (ex instanceof IllegalStateException) {
                IllegalStateException ise = (IllegalStateException) ex;
                ise.addSuppressed(e);
                throw ise;
            } else if (ex instanceof NoSuchFieldException) {
                NoSuchFieldException nsfe = (NoSuchFieldException) ex;
                nsfe.addSuppressed(e);
                throw nsfe;
            } else if (ex instanceof IllegalAccessException) {
                IllegalAccessException iae = (IllegalAccessException) ex;
                iae.addSuppressed(e);
                throw iae;
            } else {
                e.addSuppressed(ex);
            }
        }
        throw (e);
    }
}