沐鳴代理:_Java 9 will finally give the term ‘deprecated’ meaning

I’m not sure if I’m alone on this opinion, but it sure seems to me that the deprecation of the finalize method has been given way too much press. I can’t recall this much fervor over method deprecation since they blacklisted the java.util.Date() constructor and told everyone to start using a GregorianCalendar instead.

One does not simply stop calling deprecated methods

Giving the term ‘deprecated’ meaning

Whenever deprecated Java methods become news, I always like to troll the language gods over the fact that even though methods get deprecated, the underlying code never actually gets removed from the API, and as a result, lazy developers just keep using it, deprecation warnings be damned.

Previous rantings from TheServerSide about deprecated meaning nothing 

In a recent blog post, entitled Deprecation of Object.finalize(), Oracle Technical Staff Principal Stuart Marks set the record straight not only on what was being deprecated in Java 9, but which deprecated methods were actually being pruned from the API as well. Here’s the pertinent excerpt from his article:

The following six APIs were deprecated in Java SE 8, and they have been removed from Java SE 9:

  1. java.util.jar.Pack200.Packer.addPropertyChangeListener
  2. java.util.jar.Pack200.Unpacker.addPropertyChangeListener
  3. java.util.logging.LogManager.addPropertyChangeListener
  4. java.util.jar.Pack200.Packer.removePropertyChangeListener
  5. java.util.jar.Pack200.Unpacker.removePropertyChangeListener
  6. java.util.logging.LogManager.removePropertyChangeListener

In addition, in Java SE 9, about 20 methods and six modules have been deprecated with forRemoval=true, indicating our intent to remove them from the next major Java SE release. Some of the classes and methods to be removed include:

  • java.lang.Compiler
  • Thread.destroy
  • System.runFinalizersOnExit
  • Thread.stop(Throwable)

The modules deprecated for removal are the following:

  1. java.activation
  2. java.corba
  3. java.transaction
  4. java.xml.bind
  5. java.xml.ws
  6. java.xml.ws.annotation

So yes, we are getting serious about removing stuff!

Deprecated value != deprecated meaning

So I guess that will shut me up for a while. They’re getting around to pruning the API and getting rid of the deprecated methods. All I ask is that they don’t prune away that deprecated java.util.Date constructor. I’m still writing code that uses it.

You can follow Stuart Marks on Twitter: @stuartmarks
You can follow Cameron McKenzie too: @cameronmckenzie

Tweet this article!