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

org.infinispan.commons.jdkspecific.CallerId Maven / Gradle / Ivy

There is a newer version: 15.1.0.Dev04
Show newest version
package org.infinispan.commons.jdkspecific;

public class CallerId {
   static private final StackWalker WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);

   public static Class getCallerClass(int n) {
      return WALKER.walk(s ->
            s.map(StackWalker.StackFrame::getDeclaringClass).skip(n).findFirst().orElse(null));
   }

   public static String getCallerMethodName(int n) {
      return WALKER.walk(s ->
            s.map(StackWalker.StackFrame::getMethodName).skip(n).findFirst().orElse(null));
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy