Finding a Method Overload Value in Java

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

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

+4
source share
1 answer

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

+5
source

All Articles