Repository navigation
Preserve Mockito initialization for unmanaged targets and shared handles - #1249
Merged
jkschneider merged 12 commits intoOct 26, 2026
Merged
Conversation
Prove unmanaged helper initialization and close bookkeeping, and ordinary static fixture constructor initialization, survive Mockito cleanup. Co-authored-by: Moderne Factory <factory@moderne.io>
Co-authored-by: Moderne Factory <factory@moderne.io>
Only remove literal this initialization in runner or extension-managed classes. Keep shared and escaping handles intact and preserve foreign resources and declaration siblings. Co-authored-by: Moderne Factory <factory@moderne.io>
Preserve all 32 existing expectations. Both peer controls fail on unchanged production, and actual interim 246 emitted code fails javac for arity and unresolved-resource errors. Co-authored-by: Moderne Factory <factory@moderne.io>
Keep non-block variable declarations, including method parameters, when redundant managed initialization is removed. Check other resource declarations before dropping a managed resource referenced by their initializers. Co-authored-by: Moderne Factory <factory@moderne.io>
Cover sibling and enclosing private reads, other-source reads and declarations, and a distinct same-name symbol positive. Preserve all 34 prior expectations. Co-authored-by: Moderne Factory <factory@moderne.io>
Correct only the new expected blank line. Native 39-case baseline now has exactly four semantic scope failures; all prior 34 and the new distinct-owner positive pass. Co-authored-by: Moderne Factory <factory@moderne.io>
Classify uses across the full source file. Index resolved field declarations and references across input files, retaining externally observed handles and declarations unavailable in the current file. Keep method-local handling and the existing 34 controls. Co-authored-by: Moderne Factory <factory@moderne.io>
Co-authored-by: Moderne Factory <factory@moderne.io>
Co-authored-by: Moderne Factory <factory@moderne.io>
23 of 76 tasks
Add nonregression controls for cleanup and external/inherited/imported handles, including source order and different declaring owners. Unchanged f52 production passes all 50 focused tests; no RED is claimed for these admission controls. Co-authored-by: Moderne Factory <factory@moderne.io>
Apply the same conservative admission predicate to declarations, references and explicit static imports. Keep Object, incomplete types and generic variables; leave resolved-symbol, cross-source and escaping-use guards unchanged. This bounds irrelevant field bookkeeping; remote OOM causality is unestablished. All 50 focused controls pass, including 43 unchanged expectations. Co-authored-by: Moderne Factory <factory@moderne.io>
jkschneider
deleted the
factory/testing1211-f7-managed-mockito-targets
branch
October 26, 2026 21:55
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.
RemoveInitMocksIfRunnersSpecifiedcan remove initialization of a helper or another object that the enclosing Mockito runner/extension does not initialize. Restrict removal to an attributed literalthisbelonging to a managed test instance. Preserve unmanaged nested/anonymous owners, aliases, casts, null targets, and shared or escaping handles.Keep declarations and cleanup consistent with retained initialization. Scan resolved field references across sources, including inherited reads and explicit static imports. Preserve formal parameters and resources consumed by other resource initializers. Track only field types that could receive the declared
AutoCloseableresult, retaining Object, incomplete, and generic types conservatively; apply that admission rule equally to declarations, references, and imports.Validation:
This deliberately retains uncertain cases; it does not infer alias ownership or redesign unrelated lifecycle timing and integration discovery.
Addresses item F7 of #1211. The aggregate issue remains open.
Co-authored-by: Moderne Factory factory@moderne.io