Skip to main content
deleted 17 characters in body
Source Link
Servy
  • 2k
  • 14
  • 12

Aren't there any performance benefits if the class would be final itself?

For instance methods, potentially. For static methods, no. Knowing that a non-overridden instance method is in a final class would potentially allow the method to be statically bound when called, rather than going through virtual dispatch, but static methods are already statically bound (hence the name). It doesn't matter whether the class defining the static method is final or not, the call must be bound statically for all static methods.

Aren't there any performance benefits if the class would be final itself?

For instance methods, potentially. For static methods, no. Knowing that a non-overridden instance method is in a final class would potentially allow the method to be statically bound when called, rather than going through virtual dispatch, but static methods are already statically bound (hence the name). It doesn't matter whether the class defining the static method is final or not, the call must be bound statically for all static methods.

Aren't there any performance benefits if the class would be final itself?

For instance methods, potentially. For static methods, no. Knowing that a non-overridden instance method is in a final class would potentially allow the method to be statically bound when called, rather than going through virtual dispatch, but static methods are already statically bound. It doesn't matter whether the class defining the static method is final or not, the call must be bound statically for all static methods.

Source Link
Servy
  • 2k
  • 14
  • 12

Aren't there any performance benefits if the class would be final itself?

For instance methods, potentially. For static methods, no. Knowing that a non-overridden instance method is in a final class would potentially allow the method to be statically bound when called, rather than going through virtual dispatch, but static methods are already statically bound (hence the name). It doesn't matter whether the class defining the static method is final or not, the call must be bound statically for all static methods.