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

com.netflix.evcache.util.Sneaky Maven / Gradle / Ivy

The newest version!
package com.netflix.evcache.util;

/**
 * Sneaky can be used to sneakily throw checked exceptions without actually declaring this in your method's throws clause.
 * This somewhat contentious ability should be used carefully, of course.
 */
public class Sneaky {
    public static RuntimeException sneakyThrow(Throwable t) {
        if ( t == null ) throw new NullPointerException("t");
        Sneaky.sneakyThrow0(t);
        return null;
    }

    @SuppressWarnings("unchecked")
    private static  void sneakyThrow0(Throwable t) throws T {
        throw (T)t;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy