@PerformanceSensitive
    public Class<?> getCallerClass(final int depth) {
        if (depth < 0) {
            throw new IndexOutOfBoundsException(Integer.toString(depth));
        }
        // note that we need to add 1 to the depth value to compensate for this method, but not for the Method.invoke
        // since Reflection.getCallerClass ignores the call to Method.invoke()
        try {
            return (Class<?>) GET_CALLER_CLASS.invoke(null, depth + 1 + JDK_7u25_OFFSET);
        } catch (final Exception e) {
            // theoretically this could happen if the caller class were native code
            // TODO: return Object.class
            return null;
        }
    }
@ PerformanceSensitive public Class < ? > getCallerClass ( final int depth ) { if ( depth < 0 ) { throw new IndexOutOfBoundsException ( Integer . toString ( depth ) ) ; } try { return ( Class < ? > ) GET_CALLER_CLASS . invoke ( null , depth + 1 + JDK_7u25_OFFSET ) ; } catch ( final Exception e ) { return null ; } }
migrated from ReflectiveCallerClassUtility