Class CallingClassUtils


  • public final class CallingClassUtils
    extends Object
    Utility class for getting the calling class of a method.
    Author:
    Matthias Arzt
    • Method Detail

      • getCallingClassName

        public static String getCallingClassName()
        Inspects the stack trace to return the name of the class that calls this method, but ignores every class annotated with @IgnoreAsCallingClass.

        If every class on the stack trace is annotated, then the class at the root of the stack trace is returned.

      • getCallingClass

        @Deprecated
        public static Class<?> getCallingClass()
        Deprecated.
        Use getCallingClassName() instead. Warning: This method throws a IllegalStateException as soon as it comes across a class that can't be loaded with the default class loader. Inspects the stack trace to return the class that calls this method, but ignores every class annotated with @IgnoreAsCallingClass.
        Throws:
        IllegalStateException - if every method on the stack, is in a class annotated with @IgnoreAsCallingClass.