Reputation: 23198
How do I retrieve a list of deprecated methods from a class.
I need to list the methods that have been marked as deprecated for a class to pass on to documentation.
I don't really want to copy and paste each method and its javadoc into a seperate file, is it possible to do this through the javadoc tool or through eclipse?
Upvotes: 0
Views: 940
Reputation: 311636
This gets all the methods of the specified class:
public class DumpMethods {
public static void main(String args[])
{
try {
Class c = Class.forName(args[0]);
Method m[] = c.getDeclaredMethods();
for (int i = 0; i < m.length; i++)
System.out.println(m[i].toString());
}
catch (Throwable e) {
System.err.println(e);
}
}
}
To get the deprecated methods, for each method, do something like this:
Method method = ... //obtain method object
Annotation[] annotations = method.getDeclaredAnnotations();
for(Annotation annotation : annotations){
if(annotation instanceof DeprecatedAnnotation){
// It's deprecated.
}
}
Upvotes: 3
Reputation: 16631
Actually javadoc automatically generates a deprecated-list.html page. Just run javadoc, and see if that is what you need.
Upvotes: 3