On Oct 12, 12:43 am, Miroslav Pokorny <[email protected]> wrote:
> dumb because immutability is concept that exists at higher level that a > compiler can never fully appreicate or understand. At best immutability can > only be a tag rather than actual verifiable construct. Imjutability is more > than just having all fields being final, in the end when one gets away from > more toy examples what exactly can it verify. If you want to document > something as immutable then write some real javadoc. Personally i think all > these discussions are kind of pointless, when we would do better if people > just spent the time writing up some proper javadoc. You're right, the compiler (or static analysis tools) may not be able to be 100% correct for every situation, and they could probably always be fooled deliberately by crafty developers enjoying the challenge. But /if/ they're reliable enough to detect an @Immutable-annotated class is definitely not, maybe 95% of the time, then would that be worth it? Especially given the kind of subtle, hard-to-detect, multi- threaded bugs that can arise if you get it wrong. Say for instance, another developer comes along and adds a setter method to your @Immutable class, not realising the class is used in multithreaded code, wouldn't it be nice for an automated build tool to tell you that's happened, just like a unit test? Regards, Graham -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
