core classes still need to be declared final?
cowwoc at bbs.darktech.org
Mon Jan 7 21:35:32 UTC 2008
My understanding is that this has nothing to do with performance.
Certain classes, such as String, as declared final for security reasons.
In the case of Integer I would suggest using composition. It's not as
nice but it'll work.
Nick Radov wrote:
> Is it still necessary for the core Java classes such as
> java.lang.Integer to be declared final? I understand that may have been
> necessary in the early days for performance reasons, but modern JVMs no
> longer provide much of a performance benefit for final classes. For
> certain applications it would really be helpful to be able to subclass
> some of those core classes.
> For example, one application I'm working on deals with integer values
> that must be between 0 and 9999 inclusive. I would like to be able to
> create a custom Integer subclass which enforces that limit in the
> constructor, but currently that isn't possible. While I could create a
> new class that acts as a wrapper around Integer, the syntax would be
> much more awkward and that would also make it much more difficult to
> interface with other third-party classes.
> *Nick Radov | Research and Development Manager | Axolotl Corp*
> www.axolotl.com <http://www.axolotl.com/>, d: 408.920.0800 x116, f:
> 160 West Santa Clara St., Suite 1000, San Jose, CA, 95113
> THE MARKET LEADER IN HEALTH INFORMATION EXCHANGE – PROVIDING PATIENT
> INFORMATION WHEN AND WHERE IT IS NEEDED.
> /The information contained in this e-mail transmission may contain
> confidential information. It is intended for the use of the addressee.
> If you are not the intended recipient, any disclosure, copying, or
> distribution of this information is strictly prohibited. If you receive
> this message in error, please inform the sender immediately and remove
> any record of this message./
More information about the core-libs-dev