ChatGPT解决这个技术问题 Extra ChatGPT

Android Deprecated Annotation is deprecated, what's the replacement?

https://i.stack.imgur.com/U2JFj.png

Edit: Added web archive link for historical reference.

quite ironic, i wonder if they used the annotation on itself
@assylias Based on the list "level S" will be API 31 aka Android 12 which will be released this year (API 30 is "R" and "S" is next in alphabet).
@Robert How can something being deprecated in an API level which is still not released?
According to the time table of Android 12 the first developer preview versions should be available. Most likely those versions are not yet public and only available for Android device manufacturer. Therefore "not released" may be wrong, it is just not released publicly.
looks like it was a mistake , issuetracker.google.com/issues/180705308

S
Stephen C

It was a documentation bug. (And it has been fixed!)

The Deprecated annotation is not really deprecated.

Apparently what happened is that the source code for Deprecated contained this in its javadoc comments:

 * @apiNote
 * It is strongly recommended that the reason for deprecating a program element
 * be explained in the documentation, using the {@code @deprecated}
 * javadoc tag. 

Apparently, the {@code @deprecated} was interpreted as an @deprecated javadoc tag by the metalava tool. This caused metalava to inject the "missing" @Deprecated annotations into the ".class" files in the Android JAR file. Presumably, the injected annotation was then incorporated into the generated javadocs on the website.

Kudos to Manohar Reddy for finding the bug in the issue tracker.

You can find the fix that they made here.

For what it is worth, java.lang.Deprecated is a class that originates in the Oracle / OpenJDK Java (i.e. standard Java) class libraries. Android wouldn't / shouldn't deliberately deprecate it without a very good reason. It would create another hurdle to Java <-> Android portability.


kudos to this reddit comment reddit.com/r/mAndroidDev/comments/lr1w8s/…
that would have been hilarious, though :)