fix: make isExtensionUpdateRequired uniformly public (widen over narrow)#1460
Merged
joaodinissf merged 1 commit intoJul 13, 2026
Merged
Conversation
…r hierarchy AbstractCheckExtensionHelper declares isExtensionUpdateRequired as a protected hook, but five of its six subclasses have overridden it as public since the initial Check contribution, and CheckTocExtensionTest and CheckContextsExtensionTest unit-test the hook directly on injected helper instances. Widen the parent declaration and the one remaining protected override (CheckMarkerHelpExtensionHelper) so the whole hierarchy carries one visibility. Widening was chosen over narrowing deliberately: narrowing the public outliers would break the tests' direct calls and force test-only re-widening subclasses, whereas public matches how the hierarchy has actually been used since 2016. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ANGM7L3BaEGfGUmPVKRt4
rubenporras
approved these changes
Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AbstractCheckExtensionHelper.isExtensionUpdateRequiredis declaredprotected(a template-method hook, called only from the helper's own update flow), but five of its six subclasses have overridden it aspublicsince the initial Check contribution (2016,e78f8113a) — Java permits an override to widen visibility, so the mismatch compiles silently.CheckMarkerHelpExtensionHelperis the loneprotectedoverride. The hierarchy carries two visibilities for one contract.The trade-off, and the choice made
Two consistent end states were possible:
publicoutliers toprotected, matching the parent declaration. This is the textbook template-method shape — butCheckTocExtensionTestandCheckContextsExtensionTesthave unit-tested the hook directly on injected helper instances since 2017, from a different bundle and package. Narrowing breaks those calls and forces test-only re-widening subclasses (~24 lines of scaffolding whose sole job is to undo the narrowing for tests).protectedoverride topublic. Two lines, no scaffolding, and it ratifies how the hierarchy has actually been designed and used for nine years: the predicate was evidently meant to be white-box testable from day one.Widening was chosen — direct testability of the hook is a long-standing, deliberate part of this hierarchy's design, and the project generally accepts
publicwhere tests require it.What this does
AbstractCheckExtensionHelper.isExtensionUpdateRequired:protected→public.CheckMarkerHelpExtensionHelper.isExtensionUpdateRequired:protected→public(an override may not be narrower than its parent, so this follows necessarily).Coordination note: #1397's helper refactor originally declared the two delegating overrides (
CheckValidatorExtensionHelper,CheckQuickfixExtensionHelper)protected; it has been amended to keep thempublicso the build stays green in either merge order.Verification
isExtensionUpdateRequiredare the parent's own update flow,CheckMarkerHelpExtensionHelper'ssupercall, and the two tests — no behavior change is possible; this is a visibility-only change.clean verify checkstyle:check pmd:pmd pmd:cpd pmd:check pmd:cpd-check spotbugs:check): BUILD SUCCESS.🤖 Generated with Claude Code