Search code examples
javareflectionpurely-functional

Determine if a static method is purely functional


Given a java.lang.reflect.Method object, is there anyway to determine whether the method is purely functional (i.e., given the same input, it will always produce the same output and it is stateless. In other words, the function does not depend on its environment)?


Solution

  • No, there's no way to do it.

    Reflection does not allow you to inspect the actual code behind the method.

    And even if that where possible, the actual analysis would probably be ... tricky, to say the least.