Deprecated API

Deprecated API

When I compile my applets or applications, the compiler often tells me I’d use a “deprecated API” and that I should recompile with the option “-deprecate”. If I do so, the warning does not appear any more, but I haven’t noticed a difference in the behavior of the applications and applets, respectively. What does it mean when the compiler warns me that I have a “deprecated API”?

A deprecated API is a set of methods or classes that have either beensuperseded by new ones or that have simply been discontinued.Deprecated API’s may or may not be supported in future versions ofJava, but will most likely be phased out. The compiler warns youabout the deprecation so that you may gradually update your code touse new API’s. Otherwise your code may not work with a future versionof Java that completely eliminates the deprecated API’s.

The idea behind deprecating an API is to give programmers a chance toupdate their code rather than catch them off guard and force them todo so immediately. Although we have yet to see how Sun is going tohandle deprecation, the implication is that when an API is to bediscontinued it will first become deprecated. Then in the next majorrelease after deprecation it will be completely eliminated.


Share the Post: