4

In some projects I am currently working on, method overloading is being misused in many classes: methods with the same name are being overloaded for many times just with the difference of a parameter's presence or absence. And I want to change that.

Is there any existing tool that can count how many times a method is being overloaded in a Java class? Thanks.

Ryan Li
  • 9,020
  • 7
  • 33
  • 62

1 Answers1

5

Use reflection to get the List<Method> getDeclaredMethods() for a class and check for same name (getName()) different signature methods (getParameterTypes())

jmj
  • 237,923
  • 42
  • 401
  • 438
  • Seems like a viable option, but still have to code something. I thought about writing a similar tool with BCEL. :-) – Ryan Li Aug 09 '12 at 06:03