On Tue, Aug 28, 2001 at 05:23:46PM -0700, David Whipp wrote:
> 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.

And a very good reason it is, too.  While an optimizing JIT can play
tricks to achieve similar results, this won't work for something like
gcj which compiles directly to native code.

The fact that C++ is usually compiled to native code, while Java is
not, may explain why C++ methods are (in Java parlance) final unless
explicitly declared "virtual".

                      - Damien

Reply via email to