First of all, let me say that I support someone’s poorly designed code, so I am limited in how much I can change it.
Now what happens is that they created a series of methods that are called by reflection. One of these methods takes the map as one of its arguments. At run time, this map is implemented using a Hashtable.
Here's the problem - I get a NoSuchMethodException because it is looking for a method with a Hashtable as an argument, even if the Hashtable implements the Map interface. What confuses me is that if I don’t use reflection (the main design change in this case) and pass the Hashtable, it will refer to the method with the Map parameter - so why doesn’t it work the same when I use reflection
Given that I pretty much have to adhere to reflection, is there a way to get a method with a Map argument to call when I pass it a class that implements this interface?
If you want, I can make fun of the code to demonstrate ...
source
share