Alternative suggestion for JEP 277 "Enhanced Deprecation"

Lukas Eder lukas.eder at
Tue Dec 29 14:08:03 UTC 2015


I've recently discovered JEP 277, which is a very good move forward for the
JDK, but in my opinion not really optimal for the Java ecosystem as a whole
- as it responds only to a limited set of requirements that are mostly
beneficial to the development of JDK 9, I assume.

I have suggested an alternative approach in this blog post here:

It essentially consists of adding a more generic @Warning annotation,
roughly like this:

    public @interface Warning {
        String name() default "warning";
        String description() default "";

Which could then be used on JDBC:

    public interface ResultSet {

        InputStream getUnicodeStream(int columnIndex);

Or on the Collections APIs:

    public interface Collection<E> {

        boolean remove(Object o);

Or wherever it may seem suitable. The above are just examples.

The advantage of a generic, String-based approach is that @SuppressWarnings
could be retrofitted to accept any possible @Warning(name):

    Collection<Integer> collection = new ArrayList<>();
    boolean ok = collection.remove(1);

The same is true for IDEs, which could filter out any such warnings based
on user settings.

While still addressing the goals mentioned in JEP 277, this would add much
more substantial value to the whole ecosystem, and to all other library /
API designers as well.

Curious to hear your feedback,
Lukas Eder

More information about the jdk9-dev mailing list