Spot the bug in reflective method lookup

from Reflection
Java 25 LTS intermediate 4 min 1 issue to find

Find why this helper cannot reliably invoke methods selected by name.

Java
import java.lang.reflect.Method;

public class Main {
    static Object call(Object target, String name, Object argument)
            throws Exception {
        Method method = target.getClass().getDeclaredMethod(
                name, argument.getClass());
        method.setAccessible(true);
        return method.invoke(target, argument);
    }
}
Open in playground
Report an error