Reflective Method Invocation
Reflection is not limited to reading and writing variables; it can also dynamically invoke methods at runtime. Through TypeInfo's getStaticFunction and getInstanceFunction, you can find methods by name and parameter types, then use apply to invoke them.
Static methods are obtained through getStaticFunction("methodName", parameterTypes...), and instance methods through getInstanceFunction("methodName", parameterTypes...). Parameter types need to pass in corresponding TypeInfo objects. When invoking, static methods pass in type information and an array of parameters, while instance methods also need to pass in the receiver object.
Dynamic method invocation is an important tool for framework development. For example, testing frameworks can scan for test methods with specific annotations and execute them, and serialization frameworks can automatically call getter/setter methods.
The code on the right defines a Calculator class containing instance methods and static methods, then dynamically invokes these methods through reflection. Note how to obtain parameter type information: TypeInfo.of<Int64>().
Try adding a new method and invoking it through reflection.