I thought a final method can not be overridden and thus it would make no sense to write a method with the final and protected modifiers at the same time.
But I stumbled on this code from "Java concurrency in practice" :
Does anyone one what does this mean? I doubt it's a mistake as it did not occur just once.
A protected method is inherited, and can be invoked from, a subclass. The way I see it, the design decision behind making a method both protected and final is: final, so the implementation cannot be changed, and protected, so that it cannot be called from anywhere outside the inheritance hierarchy.
There are protected final methods in the JDK classes. An example: the defineClass overloads in SecureClassLoader and ClassLoader
There are no new questions, but there may be new answers.
Joined: Jan 28, 2010
It makes sense, thank you.
subject: final and protected method at the same time