0

クラスから廃止されたメソッドのリストを取得するにはどうすればよいですか。

クラスがドキュメントに渡すために非推奨としてマークされたメソッドをリストする必要があります。

各メソッドとその javadoc を個別のファイルにコピー アンド ペーストしたくありません。javadoc ツールまたは eclipse を使用してこれを行うことは可能ですか?

4

2 に答える 2

3

これは、指定されたクラスのすべてのメソッドを取得します。

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.
    }
}
于 2009-03-10T10:23:55.257 に答える
3

実際には、javadoc は deprecated-list.html ページを自動的に生成します。javadoc を実行して、それが必要かどうかを確認してください。

于 2009-03-10T10:17:11.373 に答える