My thoughts as an enterprise Java developer.

Tuesday, June 11, 2013

Deprecation Plan

Once a method is deprecated, Java seems to have no further plans for removing it before Java 2.0 (if that ever happens).

I suggest the following steps be done by default:

  1. Deprecate the method (Java already does this) and generate info log about using the method
  2. At the next major release, increase the logging level to warning
  3. At the next major release, increase the logging level to severe and remove from compile time libraries
  4. After 2 major releases, throw an exception in the runtime (with useful message)
  5. At the next major release, remove from the runtime

For example, the old Java 1.0 AWT event model was deprecated in 1.1. It this plan was followed, it could not have been used in code compiled in 1.3 (3 years after deprecation) and would have thrown an exception with the 1.5 runtime (7.5 years after deprecation).

Of course the timing of those steps may have to be tweaked (i.e. quick releases, widely used methods, etc) but it can be the default blueprint for getting rid of old code.

Do you prefer the current plan of leaving deprecated methods until Java 2.0 or do you think we should have the above plan or another plan for removing them.

No comments: