Antwerkz, Inc.
7Aug/09Off

Re: Deprecation in the JDK

Everyone hates the deprecation policies of the JDK team but it's certainly an understandable policy.  Millions and millions of lines of code exist out in the wild and there's no telling what calamity would befall us if methods were actually removed the JRE libs.  On the other hand, people still use those deprecated methods despite their failings and the presence of better options.  I was reading Joseph Darcy's blog entry on this policy and ran across an interesting comment.

The idea is pretty simple:  make compiling fail against the deprecated methods without actually removing them from code.  This preserves binary compatibility while preventing any new code from compiling against these methods.  This would actually include new releases of applications written before the method was deprecated as these new versions would no longer compile while the previous releases would still run.

This seems to be the best of both worlds.  Building on the idea from comment, I'd offer this enhancement:  Introduce an @Obsolete annotation.  This would supplant the @Deprecated annotation on these methods.  Any usage of a method or class (or field?) with this annotation would return an error at compile time.  Reflective access to these items would also be disallowed just to drive the point home.  Of course, the annotations would need to include facilities to describe the alternatives to use for these old methods to provide the same functionality as the javadoc comment.  Given this simple addition, I think we'd finally start to make some progress on modernizing our code.

Technorati Tags: ,

Posted by admin

Comments (1) Trackbacks (0)
  1. “Everyone hates the deprecation policies of the JDK team but it’s certainly an understandable policy.”

    No everyone doesn’t. Code written from JDK 1.0 still works today. Just like Cobol, just like Fortran. Unlike Visual Basic (which is a product, not really a language.

    If you get rid of things that programmers abuse, you’d have to get rid of more than just the deprecated methods. No matter what you do, there will still be stupid programmers.


Trackbacks are disabled.