为什么 java.util.Stack 没有标记为已弃用?

Why is java.util.Stack not marked as deprecated?

有很多针对陈旧的 java.util.Stack class 的批评,例如 this one,说应该避免使用它,因为它不太安全且速度较慢。 我可以理解出于兼容性原因将其保留在 rt.jar 中(即使我们将永远保留它),但为什么不将其标记为已弃用?

人们被 class 这个名字所欺骗,到处都在使用它。 如果他们能在编译时看到一条警告,表明他们使用的 class 已过时,那就更好了。

根据 Java SE 14 java.util.Stack 的 Javadoc class 文档确实附带此指南:

A more complete and consistent set of LIFO stack operations is provided by the Deque interface and its implementations, which should be used in preference to this class. For example:

  Deque<Integer> stack = new ArrayDeque<Integer>();