Skip to content

Preserve inherited lifecycle method visibility in TestsShouldNotBePublic - #1247

Merged
jkschneider merged 5 commits into
mainfrom
factory/testing1211-c6-inherited-lifecycle-visibility
Oct 26, 2026
Merged

jkschneider merged 5 commits into
mainfrom
factory/testing1211-c6-inherited-lifecycle-visibility

Conversation

@jkschneider

@jkschneider jkschneider commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

TestsShouldNotBePublic can make an inherited lifecycle method package-private while keeping its base class public, breaking subclasses in other packages. Preserve method visibility for classes that the attributed source hierarchy shows are extended.

Track raw class names through generic and binary intermediate superclasses, and include anonymous subclasses. Ordinary instantiation remains eligible for the existing visibility cleanup.

Validation:

  • Original cross-package regressions fail on the baseline. Three anonymous/binary inheritance controls also fail on the initial candidate and pass with this fix.
  • All 19 focused tests pass, including a separate JDK 25 run with no skips. The native module check reports 2,283 tests, zero failures/errors, and nine existing skips.
  • Seven actual emitted multi-source fixtures compile and are idempotent, including a negative control that still removes visibility. Independent review approved this exact source head.
  • Native baseline/candidate bundle class files match their builds; all 71 dependency JAR hashes are identical.
  • Complete paired runs cover 5,652 distinct repositories across three disjoint cohorts (5,321 dependency matches, 171 additional reference matches, and 160 current-index complement matches). Every repository's source-file counts match. Changed-file rows decrease from 157,474 to 155,847; candidate changed-file keys are a subset of baseline keys. There are no new recipe errors; one existing Hadoop cursor error is unchanged.
  • On an actual PIT JUnit 5 plugin consumer, the original source compiles and passes all 22 tests with its CLI-resolved JDK 8/Maven build. Both baseline and this candidate encounter the same 22 compile errors from the separate public-class-reference defect tracked in TestsShouldNotBePublic should reduce visibility if used elsewhere in Javadoc linksย #458. This fix preserves the inherited-method source exactly; it does not claim a passing complete consumer build for that repository.
  • The cgp check passes on exact head 0441a93.

This is bounded by available attributed ancestry and does not establish inheritance from unknown external consumers.

Fixes item C6 of #1211; the aggregate issue remains open.

Co-authored-by: Moderne Factory factory@moderne.io

jkschneider and others added 5 commits October 26, 2026 03:17
Co-authored-by: Moderne Factory <factory@moderne.io>
Co-authored-by: Moderne Factory <factory@moderne.io>
Protect methods declared by classes with known subclasses. Compare raw fully qualified names so parameterized superclass uses match their declarations.

Co-authored-by: Moderne Factory <factory@moderne.io>
Add attributed compiler-backed controls for anonymous and binary-only intermediate subclasses, plus ordinary instantiation.

Co-authored-by: Moderne Factory <factory@moderne.io>
Follow attributed superclass chains, including binary-only intermediates, and scan anonymous class bodies. Ordinary constructor calls do not establish inheritance.

Co-authored-by: Moderne Factory <factory@moderne.io>
@jkschneider jkschneider added the mod-factory Recipe fixes developed and verified by Moderne Factory label Oct 26, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Oct 26, 2026
@jkschneider
jkschneider merged commit a1cf86c into main Oct 26, 2026
1 check passed
@jkschneider
jkschneider deleted the factory/testing1211-c6-inherited-lifecycle-visibility branch October 26, 2026 17:26
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod-factory Recipe fixes developed and verified by Moderne Factory

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant