Java Reflection - Object is not an instance of declaring class

后端 未结 2 2007
离开以前
离开以前 2020-12-16 08:54

This question is being asked everywhere on Google but I\'m still having trouble with it. Here is what I\'m trying to do. So like my title states, I\'m getting an \'object

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-16 09:45

    You're invoking the method with the class, but you need an instance of it. Try this:

    serverMethod.invoke(base.newInstance(), new HashMap());
    

提交回复
热议问题