Package net.orbyfied.j8.util
Class ReflectionUtil
java.lang.Object
net.orbyfied.j8.util.ReflectionUtil
Utilities for working with reflection
safely.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Class<?>getCallerClass(int off) Get the caller class at the provided offset.static StackTraceElementgetCallerFrame(int off) Get the caller stack trace element at the provided offset.static StackTraceElementgetCallerFrame(int off, Predicate<StackTraceElement> pred) static Class<?>getClassSafe(String name) static Constructor<?>getDeclaredConstructorSafe(Class<?> klass, Class... argTypes) static FieldgetDeclaredFieldSafe(Class<?> klass, String name) static MethodgetDeclaredMethodSafe(Class<?> klass, String name, Class... argTypes) static voidinternalWalkParents(Class<?> klass, Predicate<Class<?>> pred, BiConsumer<Integer, Class<?>> consumer, int depth) static <T> TinvokeSafe(Method m, Object on, Object... args) static <T> TnewInstance(Constructor<?> c, Object... args) static voidstatic voidprintCallTree(int off) static voidprintCallTree(PrintStream out) static voidprintCallTree(PrintStream out, int off) static voidprintParentTree(PrintStream out, Class<?> klass) static voidprintParentTree(Class<?> klass) static <T> TqueryFieldSafe(Object on, Field f) static voidsetFieldSafe(Object on, Field f, Object val) static voidwalkParents(Class<?> klass, Predicate<Class<?>> pred, BiConsumer<Integer, Class<?>> consumer) static void
-
Constructor Details
-
ReflectionUtil
public ReflectionUtil()
-
-
Method Details
-
getCallerClass
Get the caller class at the provided offset.- Parameters:
off- The offset into the call stack.- Returns:
- The caller class.
- See Also:
-
getCallerFrame
Get the caller stack trace element at the provided offset.- Parameters:
off- The offset into the call stack.- Returns:
- The stack trace element.
-
getCallerFrame
-
walkParents
-
walkParents
-
internalWalkParents
-
printParentTree
-
printParentTree
-
printCallTree
-
printCallTree
public static void printCallTree() -
printCallTree
public static void printCallTree(int off) -
printCallTree
-
getClassSafe
-
getDeclaredFieldSafe
-
getDeclaredMethodSafe
-
getDeclaredConstructorSafe
-
queryFieldSafe
-
setFieldSafe
-
invokeSafe
-
newInstance
-