#Does a final method serve any purpose in a final class?

3 messages · Page 1 of 1 (latest)

ripe temple
#

I was looking through the OpenJDK source code, and saw that a method is classed as final if the method is final or it's holder (class) is final. Does that means that there is 100% no purpose to making a method final in a final class, maybe apart from making an ultra-micro optimisation where the 2nd check for a final class isn't ran? (the OpenJDK code is return is_final() || holder()->is_final();)

potent pendantBOT
#

This post has been reserved for your question.

Hey @ripe temple! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.