paperbot · PL 论文追踪

全部论文 待读 收藏

P1 Practical Inference of Nullability Types

可空性类型的实用推断
FSE Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering2023匹配度 5/10 · 论文属于静态分析与类型系统方向,提出可空性类型限定符推断并在工业界大规模落地,符合用户对工程实现和工业案例的偏好;但它不涉及用户核心关注的 LLM/Agent 与静态分析交叉、浮点程序分析或贝叶斯程序分析。引用 7 inbox
Nima Karimipour, Justin Pham, Lazaro Clapp, Manu Sridharan
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出以类型检查器为黑盒 oracle 的可空性类型限定符自动推断方法,并实现 NullAwayAnnotator,平均减少 69.5% 的 NullAway 错误。

Java 中空指针解引用引发的 NPE 常导致崩溃,而可插拔类型检查虽能预防,却需在大型遗留代码库中手动标注大量可空性限定符。本文提出实用的 Java 可空性类型限定符自动推断方法:将类型检查器作为黑盒 oracle,搜索能最大化通过类型检查代码量的限定符集合;并通过在一次检查器运行中安全评估多个限定符来降低开销,同时加入面向真实部署的扩展。该工作实现为 NullAwayAnnotator,与 NullAway 配合。在开源与商业代码上,它平均减少 69.5% 的 NullAway 错误,可扩展到大型 Java 程序;生产部署已为 160 个模块、超过 130 万行代码启用 NullAway 检查。

问题
大型 Java 代码库引入可插拔空指针类型检查时,需要手动插入大量可空性限定符,难以推广。
方法
将类型检查器作为黑盒 oracle,搜索能最大化成功通过类型检查代码量的可空性限定符集合,并优化为一次检查器运行可安全评估多个限定符;实现 NullAwayAnnotator。
评估
在开源项目与商业代码上评估,平均减少 69.5% 的 NullAway 错误,可扩展至大型 Java 程序,并在生产环境 160 个模块、超 130 万行代码中部署。
原文摘要(Abstract)

NullPointerExceptions (NPEs), caused by dereferencing null, fre- quently cause crashes in Java programs. Pluggable type checking is highly effective in preventing Java NPEs. However, this approach is difficult to adopt for large, existing code bases, as it requires manually inserting a significant number of type qualifiers into the code. Hence, a tool to automatically infer these qualifiers could make adoption of type-based NPE prevention significantly easier. We present a novel and practical approach to automatic inference of nullability type qualifiers for Java. Our technique searches for a set of qualifiers that maximizes the amount of code that can be successfully type checked. The search uses the type checker as a black box oracle, easing compatibility with existing tools. However, this approach can be costly, as evaluating the impact of a qualifier requires re-running the checker. We present a technique for safely evaluating many qualifiers in a single checker run, dramatically reducing running times. We also describe extensions to make the approach practical in a real-world deployment. We implemented our approach in an open-source tool Null- AwayAnnotator, designed to work with the NullAway type checker. We evaluated NullAwayAnnotator’s effectiveness on both open- source projects and commercial code. NullAwayAnnotator re- duces the number of reported NullAway errors by 69.5% on average. Further, our optimizations enable NullAwayAnnotator to scale to large Java programs. NullAwayAnnotator has been highly effective in practice: in a production deployment, it has already been used to add NullAway checking to 160 production modules totaling over 1.3 million lines of Java code.

链接与引用

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

BibTeX
@inproceedings{KarimipourPCS23,
  title = {Practical Inference of Nullability Types},
  author = {Nima Karimipour and Justin Pham and Lazaro Clapp and Manu Sridharan},
  booktitle = {FSE},
  year = {2023},
  doi = {10.1145/3611643.3616326}
}