JBMC: Bounded Model Checking for Java Bytecode - (Competition Contribution)

Lucas C. Cordeiro, Daniel Kroening, Peter Schrammel

Abstract

JBMC is a bounded model checking tool for Java bytecode built on the CPROVER framework. It translates Java bytecode into logical formulas to detect common programming errors such as array out-of-bounds, arithmetic overflows, and assertion violations. This paper describes the architecture of JBMC, including its use of a Java Operational Model (JOM) and symbolic execution, and reports its performance in the SV-COMP 2019 competition.

Introduction

Ensuring the reliability of Java applications is a significant challenge in modern software engineering. While Java’s managed environment prevents many low-level memory errors common in languages like C, it remains susceptible to logical errors, uncaught exceptions, and complex state-space bugs. Traditional testing often misses edge cases, and full formal verification is frequently too computationally expensive for large-scale software.

JBMC addresses this gap by providing a "bounded" approach—exhaustively checking all possible program paths up to a certain depth, such as loop iterations or recursion levels. This allows it to find bugs that testing might miss without the overhead of a full mathematical proof of correctness for infinite states. JBMC was specifically designed to participate in the SV-COMP (Competition on Software Verification), aiming to bring rigorous verification to the Java ecosystem.

System Architecture

JBMC is built on the established CPROVER framework, the same engine behind the CBMC tool for C/C++. Its pipeline consists of several sophisticated stages designed to transform high-level Java constructs into solvable logical formulas.

Overview of the JBMC verification pipeline

The process begins with Bytecode Parsing, where JBMC operates directly on compiled bytecode. This ensures it verifies the actual code running on the JVM, avoiding discrepancies introduced by the compiler. This is followed by GOTO Conversion, which translates bytecode into an intermediate representation called a "GOTO program," simplifying complex Java constructs into basic control-flow graphs.

A critical component is the Java Operational Model (JOM). Because the standard Java library is too large for direct verification, the JOM provides a "verification-friendly" version that models essential behavior while stripping away performance optimizations that would otherwise bog down the solver.

The Symbolic Execution (GOTO Symex) engine then unrolls loops and recursions up to a bound $k$, generating a set of constraints ($C$) representing the program logic and properties ($P$) representing safety checks. Finally, a SAT/SMT Solver (such as MiniSAT) checks the verification condition ($C \land \neg P$). If the formula is satisfiable, a property violation exists, and JBMC produces a counterexample trace showing exactly how the bug occurs.

Experimental Evaluation

The tool was evaluated using the SV-COMP 2019 Java benchmarks, a standardized suite of challenging verification tasks used by the research community to compare the effectiveness, speed, and accuracy of software model checkers.

In the competition, JBMC demonstrated high reliability and accuracy:

  • Accuracy: It produced zero incorrect results, meaning it never falsely claimed a buggy program was safe or vice versa.
  • Performance: It correctly verified 139 benchmarks as safe and identified existing errors in 192 benchmarks.
  • Robustness: It only failed (returned "unknown") in 37 cases, primarily due to memory or time exhaustion or missing models for specific library functions.

Key Insights

  • Bytecode-Level Analysis: By targeting bytecode, JBMC can verify programs regardless of the original source language (as long as it compiles to the JVM) and avoids compiler-introduced discrepancies.
  • Declarative Modeling: The use of the JOM allows for efficient processing of library behavior by providing specifications rather than verifying highly-optimized implementation code.
  • Specialized String Solving: Java is string-heavy; JBMC includes a specialized string solver using incremental SAT solving to handle complex operations like concatenation and searching.
  • Unwinding Assertions: To address the "bounded" limitation, JBMC can insert "unwinding assertions." If the tool can prove that a loop never exceeds the bound $k$, the bounded proof effectively becomes a total proof of correctness for that loop.

Conclusion and Future Work

JBMC successfully brings rigorous verification to the Java ecosystem, providing a robust tool for identifying deep logical errors. Despite its strengths, several areas for growth remain, including support for Java 8 lambdas, reflection, and the Java Native Interface (JNI). Future work focuses on improving multi-threading support and integrating more solvers via the SMT-LIB format to enhance performance and coverage.

Summary updated

BibTeX
@inproceedings{cordeiro2019jbmc,
  author = {Lucas C. Cordeiro and Daniel Kroening and Peter Schrammel},
  title = {{JBMC: Bounded Model Checking for Java Bytecode - (Competition Contribution)}},
  booktitle = {TACAS},
  year = {2019},
  doi = {10.1007/978-3-030-17502-3\_17},
}
Figure