> >The only good justification I've heard for "final" is as a directive > >for optimization. If you declare a variable to be of a final type, then > >the compiler (JIT, or whatever) can resolve method dispatch at > >compile-time. If it is not final, then the compiler can make no such > >assumption because java code can load in extra classes later. > > This is the only real reason I've seen to allow final. (And it's not a bad > reason, honestly, though not necessarily one appropriate in all cases) It > does allow a fair amount of optimization to be done, which can be > especially important when you can't see all the source. (Pretty much the > case in all languages that compile down to object modules you > link together later) If our intention is only for optimization, I prefer to use word "inline" instead of "final". The word "final" already has been abused. It is very awkward to use it for this purpose. HongThread Previous | Thread Next