Class MethodFinder

java.lang.Object
madkit.reflection.MethodFinder

public class MethodFinder extends Object
Utilities for finding method references in Agent classes. Provides methods to find and retrieve methods from agent classes, including private and inherited methods.
Since:
6.0
  • Method Details

    • getMethodFromTypes

      public static Method getMethodFromTypes(Class<?> agentClass, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException
      Returns the agent's method named methodName considering a given agentClass. This also works for private and inherited methods.
      Parameters:
      agentClass - the class wherein the search has to be started
      methodName - the name of the method
      parameterTypes - the parameter types of the targeted method
      Returns:
      the agent's method named methodName
      Throws:
      NoSuchMethodException - if the method cannot be found
    • getMethodOn

      public static Method getMethodOn(Class<?> agentClass, String methodName, Object... argsSample) throws NoSuchMethodException
      Returns the agent's method named methodName considering a given agentClass and a sample of the arguments which could be passed to it. The purpose of this method is restricted to a limited number of use cases since getMethodFromTypes(Class, String, Class...) should be preferred if the exact signature of the searched method is known. A typical use case of this method is when the only information available is the arguments which are passed, for instance when overriding the Activator.execute(Object...) method and the like in Activator subclasses. This also works for private and inherited methods.
      Parameters:
      agentClass - the class wherein the search has to be made
      methodName - the name of the method
      argsSample - a sample of the args which can be passed to the method
      Returns:
      the agent's method named methodName
      Throws:
      NoSuchMethodException - if a matching method cannot be found