paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Transitive, Abstract, and Class Polymorphic Immutability

传递、抽象与类多态的不可变性
OOPSLA 10(OOPSLA2)2026匹配度 2/10 · 论文属于类型系统与形式化验证领域,有 Rocq 证明和 Checker Framework 工程实现,但不涉及 LLM/Agent、机器学习系统、浮点程序分析或贝叶斯程序分析,与用户画像的核心交叉方向关系很弱。引用 0 inbox
Aosen Xiong, Yudi Bai, Haifeng Shi, Lian Sun, Mier Ta, Werner Dietl
crossref: 2026-10-02

AI 速览

一句话:提出 PICO 类型系统,用 readonly 引用与 viewpoint adaptation 支持传递、抽象及类多态不可变性,并证明类型可靠性与状态保持保证。

状态突变易导致不变量破坏与安全漏洞,而传递/抽象不可变性、readonly 引用、子类型多态及可变/不可变类变体重复难以兼顾。本文提出 PICO 类型系统,用新的 viewpoint adaptation 规则实现传递抽象不可变性,避免可变与不可变跨类型别名的不可靠,并定义抽象状态以允许对象图局部可变。PICO 在单一系统中提供抽象、具体、readonly 与传递四类状态保持保证,支持类可变性多态,避免重复变体且可改造既有层次。作者在 Rocq 中证明类型可靠性与四类保证,基于 Checker Framework 实现 Java 检查器,在 OpenJDK 17 集合框架等约 26,000 行代码上评估,表明能有效实施不可变性且无需复制代码。

问题
如何在不破坏类型可靠性的前提下,统一支持传递不可变性、抽象不可变性、readonly 引用与子类型/类多态,并避免可变与不可变类变体的代码重复。
方法
提出 PICO 类型系统,引入 viewpoint adaptation 规则实现传递性与别名安全,定义抽象状态,提供四类状态保持保证,并在 Rocq 中形式化证明、用 Checker Framework 实现 Java 检查器。
评估
在 OpenJDK 17 Java 集合框架等约 26,000 行非注释代码上运行实现的类型检查器,验证不可变性保证可被有效实施且现有库可无复制改造。
原文摘要(Abstract)

State mutations can often lead to silent program errors, including broken invariants and security vulnerabilities. Object-oriented languages offer basic mechanisms to prevent mutation; however, enforcing desired guarantees remains challenging. Two such guarantees are transitive immutability, which disallows mutation of all objects reachable from a reference, and abstract immutability, which permits controlled mutation of otherwise immutable objects. Furthermore, introducing readonly references to support subtype polymorphism often complicates the soundness of the type system. The integration of immutability into a class hierarchy introduces challenges, primarily manifesting as duplicated code between mutable and immutable variants. We present Precise Immutability for Classes and Objects (PICO), a type system that enforces transitive abstract immutability with readonly references. PICO introduces novel viewpoint adaptation rules to achieve transitivity. These rules prevent unsoundness caused by mutable and immutable cross-type aliasing, a long-standing issue for systems combining immutability and assignability. Additionally, PICO formally defines the abstract state, which allows developers to permit mutation for selected parts of the object graph. PICO provides four state-preservation guarantees within a single system by selecting corresponding viewpoint adaptation rules: abstract-, concrete-, readonly-, and transitive-state preservation. Finally, the system supports safe class mutability polymorphism: one class can express both mutable and immutable uses, avoiding duplicate mutable/immutable class variants while also enabling backward-compatible retrofitting of existing hierarchies. We formalize PICO and prove its type soundness and four state-preservation guarantees in the Rocq proof assistant. We also implement a type checker for Java using the Checker Framework. We evaluate this implementation on the Java Collections Framework in OpenJDK 17 and other benchmarks, covering approximately 26,000 non-comment lines of code. The results demonstrate that PICO effectively enforces immutability guarantees and can successfully retrofit existing libraries without duplicating code.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot12140,
  title = {Transitive, Abstract, and Class Polymorphic Immutability},
  author = {Aosen Xiong and Yudi Bai and Haifeng Shi and Lian Sun and Mier Ta and Werner Dietl},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  number = {OOPSLA2},
  year = {2026},
  doi = {10.1145/3839491}
}