是否可以弃用枚举常量?

Possibility to deprecate enum constants?

是否可以在枚举常量上使用 @Deprecated 注释?

是的,给它们加上 @Deprecated 注释(大写)。例如:

public enum Status {
OK,
ERROR,

@Deprecated
PROBLEM
}

@Deprecated is an annotation that is read by the compiler, used to mark a method as deprecated to the compiler and will generate a deprecation compile-time warning if the method is used.

@deprecated is a javadoc tag used to provide documentation about the deprecation. You can use it to explain why the method was deprecated and to suggest an alternative. It only makes sense to use this tag in conjunction to the @Deprecated annotation.

如果您检查 javadoc,您将看到声明:

@Target(value={CONSTRUCTOR,FIELD,LOCAL_VARIABLE,METHOD,PACKAGE,PARAMETER,TYPE})

其中包括 FIELD。如果您单击 FIELD,您会看到它的 javadoc,其中说明:

Field declaration (includes enum constants)

所以答案是:是的,它应该可以正常工作。