Verifying the Option Type with Rely-Guarantee Reasoning
James Yoo, Michael D. Ernst, René Just
Abstract
Many programming languages include an implementation of the option type, which encodes the absence or presence of values. Incorrect use of the option type results in run-time errors, and unstylistic use results in unnecessary code. Researchers and practitioners have tried to mitigate the pitfalls of the option type, but have yet to evaluate tools for enforcing correctness and good style. To address problems of correctness, we developed two modular verifiers that cooperate via a novel form of rely-guarantee reasoning; together, they verify use of the option type. We implemented them in the Optional Checker, an open-source static verifier. The Optional Checker is the first verifier for the option type based on a sound theory -that is, it issues a compile-time guarantee of the absence of run-time errors related to misuse of the option type. We then conducted the first mechanized study of tools that aim to prevent run-time errors related to the option type. We compared the performance of the Optional Checker, SpotBugs, Error Prone, and IntelliJ IDEA over 1M non-comment, non-blank lines of code. The Optional Checker found 13 previously-undiscovered bugs (a superset of those found by all other tools) and had the highest precision at 93%. To address problems of style, we conducted a literature review of best practices for the option type. We discovered widely varying opinions about proper style. We implemented linting rules in the Optional Checker and discovered hundreds of violations of the style recommended by Oracle, including in 11% of JDK files that use Optional. Some of these were objectively bad code, and others reflected different styles. CCS CONCEPTS • Software and its engineering → Software verification and validation.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext cf35cd1f-976b-4c70-a97e-e3d48147daafBuilds on3
- Finding real bugs in big programs with incorrectness logicQuang Loc Le, Azalea Raad, Jules Villard, Josh Berdine et al.OOPSLA 2022 · 52 citations
- Continuous ComplianceMartin Kellogg, Martin Schäf, Serdar Tasiran, Michael D. ErnstASE 2020 · 16 citations
- Verifying object constructionMartin Kellogg, Manli Ran, Manu Sridharan, Martin Schäf et al.ICSE 2020 · 10 citations
Related papers
- Practical Inference of Nullability TypesNima Karimipour, Justin Pham, Lazaro Clapp, Manu SridharanFSE 2023 · 6 citations
- Memory-Safety Verification of Open Programs with Angelic AssumptionsGourav Takhar, Baldip Bijlani, Prantik Chatterjee, Akash Lal et al.OOPSLA 2025 · 2 citations
- Usability-Oriented Design of Liquid Types for JavaCatarina Gamboa, Paulo Canelas, Christopher Steven Timperley, Alcides FonsecaICSE 2023 · 9 citations
- JavaDL: automatically incrementalizing Java bug pattern detectionAlexandru Dura, Christoph Reichenbach, Emma SöderbergOOPSLA 2021 · 13 citations
- Scalability and precision by combining expressive type systems and deductive verificationFlorian Lanzinger, Alexander Weigl, Mattias Ulbrich, Werner DietlOOPSLA 2021 · 6 citations
