Java NoSuchMethodException when getting constructor

后端 未结 1 1736
南笙
南笙 2021-01-18 09:51

I am trying to use reflections to load an instance of a class. I am getting a no such method exception when I try and do it. I have checked and checked and re-checked. That

相关标签:
1条回答
  • 2021-01-18 10:18

    In StoreCommand.java I see this package private constructor:

    StoreCommand(ItemSave plugin) {
      super(plugin);
    }
    

    from the API docs of getConstructor (emphasis mine):

    Returns a Constructor object that reflects the specified public constructor of the class represented by this Class object.

    Either make the constructor public or use getDeclaredConstructor() and set then do setAccesible(true)

    0 讨论(0)
提交回复
热议问题