Class ReflectionService
- java.lang.Object
-
- com.kraken.api.service.util.reflect.ReflectionService
-
public class ReflectionService extends java.lang.ObjectService for handling reflection operations, including field access and method invocation.This service maintains a cache of reflected fields and methods to improve performance for repeated accesses. It supports accessing obfuscated members via
FieldHookandMethodHookdefinitions.
-
-
Constructor Summary
Constructors Constructor Description ReflectionService(net.runelite.api.Client client)Constructs a new ReflectionService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TgetFieldValue(FieldHook hook, java.lang.Object instance)Retrieves the value of a field specified by the given hook.java.lang.Objectinvoke(MethodHook hook, java.lang.Object instance, java.lang.Object... args)Invokes a method specified by the given hook.voidsetFieldValue(FieldHook hook, java.lang.Object instance, java.lang.Object value)Sets the value of a field specified by the given hook.
-
-
-
Method Detail
-
getFieldValue
public <T> T getFieldValue(FieldHook hook, java.lang.Object instance)
Retrieves the value of a field specified by the given hook.- Type Parameters:
T- The expected type of the field value.- Parameters:
hook- TheFieldHookdefining the class and field name.instance- The object instance to retrieve the field value from.- Returns:
- The value of the field, or null if an error occurs.
-
setFieldValue
public void setFieldValue(FieldHook hook, java.lang.Object instance, java.lang.Object value)
Sets the value of a field specified by the given hook.- Parameters:
hook- TheFieldHookdefining the class and field name.instance- The object instance to set the field value on.value- The new value to set.
-
invoke
public java.lang.Object invoke(MethodHook hook, java.lang.Object instance, java.lang.Object... args)
Invokes a method specified by the given hook.This method automatically handles garbage values if the hook specifies one, appending it to the arguments list.
- Parameters:
hook- TheMethodHookdefining the class and method name.instance- The object instance to invoke the method on.args- The arguments to pass to the method.- Returns:
- The result of the method invocation, or null if an error occurs.
-
-