Skip to content

Add Java 21 library contracts and external effect summaries - #36

Open
alcides wants to merge 1 commit into
feat/external-library-refinementsfrom
feat/jdk-library-contracts
Open

alcides wants to merge 1 commit into
feat/external-library-refinementsfrom
feat/jdk-library-contracts

Conversation

@alcides

@alcides alcides commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

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 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:

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

  • Bug fix
  • New feature
  • Documentation update
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant