Ten years ago I created, and have maintained, some commons/library jar files of helper classes specifically for cryptography in Java 8. Our organizations are FINALLY starting to update to Java 11 LTS, in which similar functionality has been added natively.
These commons are used across many groups in my company but as individual groups upgrade to Java 11+ JRE/JVMs, I would like to encourage them to use the new native classes vs. my libraries.
Is there a way to annotate/Javadoc-tag my classes/methods such that they only warn as deprecated when built with a Java 11+ JRE/JVM?
My classes still work perfectly fine in Java 11+, but I’d really like to encourage using the now native classes/methods. If depreciation is not the way to go, are there other annotation/Javadoc methods to discourage use via warning when used beyond a specific version of JRE/JVM?
Advertisement
Answer
There is no way to do that out of the box. I suggest you just include the explanation in the JavaDoc text.
Deprecation is overkill because it sounds like you have no intention of actually removing it. You just want to encourage users targeting a later version to use something else.
You could always write your own annotation and annotation processor, of course.