paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Wildcards need witness protection

通配符需要见证保护
OOPSLA 6(OOPSLA2)2022匹配度 3/10 · 论文属于类型系统与静态分析的形式化及实证工作,仅在“静态分析/形式化验证”这一宽泛 PL 方向上与用户画像弱相关;其核心问题(Java 通配符存在类型见证)不涉及 LLM/Agent、浮点程序分析或贝叶斯程序分析。引用 1 inbox
Kevin Bierhoff
crossref: 2026-09-10

AI 速览

一句话:提出存在类型见证保护机制,形式化核心演算并证明可靠,可避免 Java 通配符不健全性且误报极少。

Java 泛型的通配符(wildcards)曾被 Amin 与 Tate(2016)指出存在不健全性。本文表明,即使没有 nullness-aware 类型系统,该不健全性也可避免。核心洞见是:在通过子类型隐式引入存在类型时,要保持类型系统可靠,必须在引入存在量化类型变量时确保存在合适的见证类型(witness type)。作者为此形式化了一个核心演算并证明其可靠性,同时基于该思路实现静态分析,用于扫描大规模 Java 语料中的潜在问题。分析未发现真实问题,仅有 1 个误报,说明 Java 通配符不健全性在实践中影响很小,而所提方法能以极低误报完全规避它。

问题
Java 泛型通配符被指出存在不健全性(Amin 与 Tate, 2016);论文研究能否在不依赖 nullness-aware 类型系统的情况下避免该问题。
方法
从子类型隐式引入存在类型的角度出发,要求在引入存在量化类型变量时提供合适的见证类型;形式化核心演算并证明其可靠性,并据此实现静态分析。
评估
在大规模 Java 代码语料上运行基于该方法的静态分析,未发现真实问题(仅 1 个误报),表明该不健全性实际影响小且方法误报率低。
原文摘要(Abstract)

In this paper, we show that the unsoundness discovered by Amin and Tate (2016) in Java’s wildcards is avoidable, even in the absence of a nullness-aware type system. The key insight of this paper is that soundness in type systems that implicitly introduce existential types through subtyping hinges on still making sure there are suitable witness types when introducing existentially quantified type variables. To show that this approach is viable, this paper formalizes a core calculus and proves it sound. We used a static analysis based on our approach to look for potential issues in a vast corpus of Java code and found none (with 1 false positive). This confirms both that Java's unsoundness has minimal practical consequence, and that our approach can avoid it entirely with minimal false positives.

链接与引用

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

BibTeX
@article{paperbot1412,
  title = {Wildcards need witness protection},
  author = {Kevin Bierhoff},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {6},
  number = {OOPSLA2},
  year = {2022},
  doi = {10.1145/3563301}
}