All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.junittoolbox.util.TigerThrower Maven / Gradle / Ivy

The newest version!
package com.googlecode.junittoolbox.util;

/**
 * This class provides the method {@link #sneakyThrow(Throwable)} which
 * enables you to throw any checked {@link Exception} from any method,
 * even if its type is not listed in the method signature. Copied from
 * Java Puzzlers.
 */
public class TigerThrower {

    /**
     * Will throw the given {@link Throwable}.
     */
    public static void sneakyThrow(Throwable t) {
        new TigerThrower().sneakyThrow2(t);
    }

    private void sneakyThrow2(Throwable t) throws T {
        throw (T) t;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy