Using java.lang.reflect.getMethod with polymorphic methods

前端 未结 3 2112
既然无缘
既然无缘 2020-12-19 05:15

Consider the following snippet:

public class ReflectionTest {

    public static void main(String[] args) {

        ReflectionTest test = new ReflectionTest         


        
3条回答
  •  伪装坚强ぢ
    2020-12-19 06:04

    The easy way to do this is via java.beans.Statement or java.beans.Expression. Does all these hard yards for you.

    getMethod() is obviously unaware that a String could be fed to a method that expects an Object

    'Unaware' is a strange way to put it. getMethod() adheres to its specification. You have to supply the formal parameters, not the types of the actual arguments.

提交回复
热议问题