> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Gene Chuang
> How can any ejb-compiler check for immutability of a (primary key) class,
> though?
I think the right question should be: where is the limit?
What if a user changes the persistence type at runtime? What if they access
our internal MBeans through the JMX infrastructure and start tweaking values
of running EJB's?
There is no clear answer there, we just need to use common sense. It is a
matter of how likely the user is to make a specific mistake versus the cost
of ensuring that they don't. All the while remembering that this overhead
is going to be paid by *all* users of the container. Even well-behaved
ones.
To me, preventing them from modifying the Primary Key after a bean has been
created is way off the scale, on the side of "it costs too much and hardly
anybody will do that".
> Wouldn't it be nice for java to have a 'const' or 'immutable' declaration,
> for methods as well as classes? This is something I missed from my C++
> days...
Well, this is an entirely different debate (besides, they can still use
const_cast<> if they are knowledgeable or static casts if they are not).
There is only so much you can do to prevent users from shooting themselves
in the foot. Most of the time, it's something I don't want to do, but I'll
gladly provide band aids.
--
Cedric
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".