クラスから廃止されたメソッドのリストを取得するにはどうすればよいですか。
クラスがドキュメントに渡すために非推奨としてマークされたメソッドをリストする必要があります。
各メソッドとその javadoc を個別のファイルにコピー アンド ペーストしたくありません。javadoc ツールまたは eclipse を使用してこれを行うことは可能ですか?
これは、指定されたクラスのすべてのメソッドを取得します。
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);
}
}
}
非推奨のメソッドを取得するには、メソッドごとに次のようにします。
Method method = ... //obtain method object
Annotation[] annotations = method.getDeclaredAnnotations();
for(Annotation annotation : annotations){
if(annotation instanceof DeprecatedAnnotation){
// It's deprecated.
}
}
実際には、javadoc は deprecated-list.html ページを自動的に生成します。javadoc を実行して、それが必要かどうかを確認してください。