Consider this code from the official OpenJDK source of java.awt.font.TextLayout:
public final class TextLayout {
/* ... */
protected void handleJustify(float justificationWidth) {
// never called
}
}
What’s the use case here and why might it make sense to write code like that in general?
protectedmembers can still be accessed by code from the same package. My guess is that the class used to be non-final in some earlier (perhaps not even public) version, was then made final, and the protected method kept as such because there might be code in the same package that uses it (and not changed to package private simply because nobody saw a benefit from doing so).