paperbot · PL 论文追踪

全部论文 待读 收藏

P2 NullAway: practical type-based null safety for Java

NullAway:面向 Java 的实用型基于类型的空安全
FSE Proceedings of the 2019 27th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering2019匹配度 4/10 · 该论文属于静态分析与类型系统,且具有优秀的工业落地与低开销工程实践,符合用户对理论+工程、工业案例的部分兴趣;但它面向 Java 空安全,不涉及 LLM/Agent、ML 系统程序分析、浮点程序分析或贝叶斯程序分析,与用户当前核心的 PL↔AI 交叉方向距离较远。引用 2 inbox
Subarno Banerjee, Lazaro Clapp, Manu Sridharan
crossref: 2026-09-12

AI 速览

一句话:提出 NullAway,一个构建开销低、注解负担小的 Java 空安全类型检查器,可在每次构建中运行。

NullPointerException 是现代 Java 程序崩溃的主要来源之一。已有工作表明可通过代码注解与可插拔类型检查在编译期预防此类错误,但这类系统因构建期开销大或注解负担重,难以在大型项目中落地。本文提出 NullAway,一个面向 Java 的基于类型的空安全检查器:它经过精心工程化以实现低开销,可作为每次构建的一部分运行;同时通过有针对性的非可靠假设(unsound assumptions)降低注解负担,目标是在被检查代码上不产生漏报。评估显示,NullAway 的构建时间开销仅为 1.15×,远低于同类工具的 2.8–5.1×。在若干广泛使用且已采用 NullAway 的 Android 应用的生产崩溃数据语料上,残余 NPE 分别来自未检查的第三方库(64%)、人为错误抑制(17%)、反射及其他检查后代码修改(17%),没有一例源于 NullAway 对被检查代码的非可靠假设。

问题
Java 中的 NullPointerException 是崩溃主因,而现有的基于注解与可插拔类型检查的空安全方案因构建开销高或注解负担重,难以在大型软件项目中部署。
方法
设计并实现 NullAway:一个工程化优化、开销极低的 Java 空安全类型检查器,可在每次构建中运行;并通过有针对性的非可靠假设来减少所需注解,力求在被检查代码上无漏报。
评估
与同类工具对比构建期开销(NullAway 为 1.15×,对比工具为 2.8–5.1×),并在广泛使用的 Android 应用生产崩溃数据语料上统计残余 NPE 的来源,验证其非可靠假设未导致漏报。
原文摘要(Abstract)

NullPointerExceptions (NPEs) are a key source of crashes in modern Java programs. Previous work has shown how such errors can be prevented at compile time via code annotations and pluggable type checking. However, such systems have been difficult to deploy on large-scale software projects, due to significant build-time overhead and / or a high annotation burden. This paper presents NullAway, a new type-based null safety checker for Java that overcomes these issues. NullAway has been carefully engineered for low overhead, so it can run as part of every build. Further, NullAway reduces annotation burden through targeted unsound assumptions, aiming for no false negatives in practice on checked code. Our evaluation shows that NullAway has significantly lower build-time overhead (1.15×) than comparable tools (2.8-5.1×). Further, on a corpus of production crash data for widely-used Android apps built with NullAway, remaining NPEs were due to unchecked third-party libraries (64%), deliberate error suppressions (17%), or reflection and other forms of post-checking code modification (17%), never due to NullAway’s unsound assumptions for checked code.

链接与引用

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

BibTeX
@inproceedings{paperbot5096,
  title = {NullAway: practical type-based null safety for Java},
  author = {Subarno Banerjee and Lazaro Clapp and Manu Sridharan},
  booktitle = {FSE},
  year = {2019},
  doi = {10.1145/3338906.3338919}
}