2016-02-05 26 views
7

所以,人們對已棄用的API使用@Deprecated註釋。什麼是@deprecated in java的反向

是否有任何註釋可以通知用戶該方法是否正在發展並且不穩定?

+2

不是內置的,但你可以自己做。像'@ Beta'一樣。 – Tunaki

+2

您可以使用[番石榴中的'@ Beta'註釋](http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/annotations/Beta.html)。 – azurefrog

+1

另請參閱:http://stackoverflow.com/questions/32555597/annotating-unstable-classes-methods-for-javadoc – assylias

回答

4

Afaik,它還不存在,你必須創建自己的。

JEP277定義@Deprecated(EXPERIMENTAL),但它只是一個命題。

2

在hadoop中有InterfaceStability註釋用於這些目的。有趣的是這個註釋並不穩定。我懷疑JDK中會出現這樣的事情。

@InterfaceAudience.Public 
@InterfaceStability.Evolving 
public class InterfaceStability { 
    /** 
    * Can evolve while retaining compatibility for minor release boundaries.; 
    * can break compatibility only at major release (ie. at m.0). 
    */ 
    @Documented 
    public @interface Stable {}; 

    /** 
    * Evolving, but can break compatibility at minor release (i.e. m.x) 
    */ 
    @Documented 
    public @interface Evolving {}; 

    /** 
    * No guarantee is provided as to reliability or stability across any 
    * level of release granularity. 
    */ 
    @Documented 
    public @interface Unstable {}; 
}