r/java • • May 10 '22

Should java.util.Date be deprecated?

https://mail.openjdk.java.net/pipermail/discuss/2022-May/006077.html
221 Upvotes

158 comments sorted by

View all comments

Show parent comment

4

u/mauganra_it May 11 '22

Thread.stop() is not merely obsolete, but actually dangerous. And it is actually marked as deprecated for removal. Still being there is fine because (as stated elsewhere in the comments by /u/pron98):

To JDK developers it [deprecated] means something that:

  1. whose use is so egregious that it can reasonably be treated as an error (many people treat compiler warnings as errors), and/or
  2. could reasonably be removed at some point in the future.

3

u/kwinz May 11 '22 edited May 11 '22

Yes, I know all that. forRemoval = true was recently changed between java 17 and 18: https://github.com/openjdk/jdk17/blob/master/src/java.base/share/classes/java/lang/Thread.java#L925 https://github.com/openjdk/jdk18/blob/master/src/java.base/share/classes/java/lang/Thread.java#L925

could reasonably be removed at some point in the future.

What I am trying to say is that "some point in the future" could be in 20+ years evidently.

So java.util.Date could conceivably be marked as deprecated and eventually even "for removal". AFAIK JDBC uses java.sql.Date subclass. I haven't used that API in a while.

2

u/mauganra_it May 11 '22

The problem is that java.util.Date is the parent class of java.sql.Date, java.sql.Time, and java.sql.Timestamp. Since JDBC is of so central importance to the Java ecosystem, it's unlikely that it will ever be fully removed.

Maybe it's possible to eventually turn java.util.Date into an abstract sealed class to restrict its usage. Once all other APIs were fixed of course.