I can see that because the lifecycles of EJBs are managed by the EJB container and there are lifecycle methods such as ejbCreate and ejbRemove there is no need for the finalize method, but what is the official explanation? Thanks, Walter
I think the restriction on finalize() is to discourage (or in this case forbid) people from using it to cleanup resources since it is not managed by the Container. Those types of resources should be managed in the appropriate lifecycle method (ejbRemove() for Session and Message Driven Beans, unsetEntityContext() for Entity Beans). In a similar fashion, explicitly defining a no-args constructor for your EJBs is discouraged (but not actually forbidden by the spec). Any initialization code should really be placed into the appropriate lifecycle method. These restrictions give the Container make flexibility when it comes to instance pooling.
All that thinking. Doesn't it hurt? What do you think about this tiny ad?
Two software engineers solve most of the world's problems in one K&R sized book