Repository navigation
Support external library contracts in Latte and LiquidTypeChecking - #35
Merged
alcides merged 1 commit intoDec 2, 2026
Merged
Conversation
4 tasks done
alcides
added a commit
that referenced
this pull request
Dec 2, 2026
## Description Library calls previously lost local ownership and refinement facts when their mutation effects or returned aliases were unknown. Add `@Modifies` footprints and `@ReturnsView` relationships shared through Spoon's AST, and use them in Latte and LiquidTypeChecking. Local array copies, borrowed constructor inputs and ArrayList views retain the information needed by later checks. Target Java 21 in the build and CI. Add an opt-in, package-selectable Java SE 21 catalog covering all 178 packages, 4,055 API types and 47,030 member entries: 501 stronger declarations across 190 types, including 443 mutation footprints, with explicit conservative policies elsewhere. Generated inventories and audit reports are marked for GitHub's generated-file handling. Also fix the array-constructor metadata null dereference and deep solver-translation stack overflow. Include checked examples, catalog generation/validation tools, runtime witnesses, documentation and a replay of the original 1,481 OpenJDK test sources. The follow-up in [docs/jdk21-effects-followup.md](docs/jdk21-effects-followup.md) records specific improvements and remaining limitations. Branch-dependent aliases and repeated allocation summaries remain imprecise. Read-only calls still reject overlapping borrowed arguments such as `Arrays.equals(values, values)`; this PR documents that gap rather than claiming it is fixed. ## Example With `--jdk all`, this now verifies because the local view captures its backing list without making it shared: ```java var root = new java.util.ArrayList<Integer>(); var view = root.subList(0, 0); root.add(42); ``` The backing-list mutation invalidates the view for subsequent checked operations. Footprints do not imply freshness; ownership and return-view guarantees remain separate annotations. ## Related Issue Stacked on #35, targeting `feat/external-library-refinements`. The diff contains the Java 21 catalog, effect/view support and follow-up fixes and audits. CI is enabled for this PR base. ## Type of change - [x] Bug fix - [x] New feature - [x] Documentation update - [x] Code refactoring ## How Has This Been Tested? - Java 21 Maven verification and compatibility profile: **616 tests, zero failures/errors/skips**, Spotless passes, **180/311 exact upstream compatibility matches**. The remaining mismatches are documented, not counted as successes. - The tested source/catalog files are unchanged since the verified build; subsequent edits are documentation and the CI branch trigger. - Replayed exactly **1,481 unchanged OpenJDK sources**, with and without the catalog: **1,460 completed pairs**, 20 catalog timeouts and one existing Spoon type-erasure failure. These are source analyses, not execution or proof of the complete jtreg suite. - On the same **1,389 previously completed files**, after reviewed expected-exception exclusions, ownership/state diagnostics increase from **1,052 to 1,168** as additional calls are checked. `Arrays/FloatDoubleOrder.java` becomes diagnostic-free; 14 previous diagnostics disappear from now-clear lines. The report does not claim an overall reduction. - Recorded **17 focused reproductions**, including four controlled comparisons with only the effect/view annotations removed. - Validated audit hashes/counts, documentation links, Java 21 workflow configuration and staged whitespace.
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.
External library specifications were previously rejected as unsupported. This change lets application code refine JDK and third-party library methods, constructors and fields through
@ExternalRefinementsFor, using the same contracts in Latte and LiquidTypeChecking. For example, an ArrayList transition through a local alias is visible when checking the original variable's size.@Freetransfers.Validation:
mvn -B spotless:apply clean verify -Pcompatibilitypasses with 522 tests, zero failures/errors, and 180/311 exact upstream matches (previously 165), with zero analysis crashes. The compatibility gate still checks every imported input and rejects newly accepted negative cases.Library specifications are trusted contracts. Container-size specifications do not infer element ownership or return aliases. Expanded varargs calls require explicit arrays; varargs method references require an explicit-array lambda. These boundaries are documented and unsupported adapters are diagnosed explicitly.
This PR is stacked on
feat/latte-liquid-typechecking, whose completed implementation was pushed as1eb2448. Its diff contains only external-library support and related integration fixes. CI also runs for PRs targeting that base.