Abstract
Software packages often hide complex multi-object protocols that are difficult to formalize using traditional API definitions. This paper introduces Dynamic Package Interfaces (DPI), a formalism that captures these protocols by representing unbounded heap configurations as finite "nested graphs." By employing a "universal client" to explore package behavior and applying heuristics to generalize rules, the authors generate concise sets of interaction rules. Evaluation on Java libraries like JDBC and ArrayList demonstrates that DPI can effectively pinpoint root causes of bugs and summarize complex state spaces into a handful of actionable rules.
Introduction
In object-oriented programming, Application Programming Interfaces (APIs) typically define the "what"—method names, parameter types, and return values. However, they rarely formalize the "when"—the temporal protocols governing valid call sequences. For instance, in the Java Database Connectivity (JDBC) package, a ResultSet cannot be accessed if its parent Statement or Connection has been closed.
While tools exist to track the state of individual objects, real-world software failures often stem from the interaction of multiple objects across the heap. The challenge lies in the potentially infinite number of heap configurations. Dynamic Package Interfaces address this by summarizing these interactions into a finite set of rules that govern an unbounded number of objects.
The DPI Framework: Nested Object Graphs
The core of the DPI approach is the Nested Object Graph. Unlike standard object graphs, nested graphs use a hierarchical structure where specific subgraphs can be marked as "repeatable" (denoted by a * notation). This allows a single finite representation to account for an infinite variety of concrete heaps, such as a single database connection managing any number of active statements.
Rule Discovery and Generalization
To discover these protocols, the authors developed a "universal client" tool. This tool explores a package's state space by nondeterministically creating objects and invoking methods, effectively stress-testing the library to observe its behavior. Because raw exploration generates thousands of redundant rules, the framework applies three key heuristics for generalization:
- Extrapolation: Identifying patterns (e.g., multiple
ResultSetobjects) and assuming they can repeat $N$ times. - Merging: Combining rules that result in similar heap transitions.
- Exception Isolation: Using ternary logic (True, False, or "Don't Care") to isolate the specific conditions that trigger a failure.
Handling Exceptions and the "Don't Care" State
A significant innovation in DPI is the use of the "Don't Care" state (represented by *) in exception rules. When a method call fails, the tool determines which parts of the heap state are irrelevant to the crash. For example, if a ResultSet is closed, it doesn't matter whether the parent Connection is open or closed; the call will fail regardless. By filtering out this "noise," DPI provides developers with the exact root cause of a bug rather than a confusing full heap dump.
Evaluation and Key Results
The authors evaluated the tool on three widely used Java packages: JDBC (java.sql), ArrayList, and HashSet. The results highlight the efficiency and accuracy of the DPI approach:
- JDBC: The tool reduced a massive potential state space to just 26 rules, correctly capturing the hierarchical dependencies between Connections, Statements, and ResultSets.
- ArrayList/HashSet: The tool generated 15 and 16 rules respectively. For
ArrayList, it explored 200,000 states in approximately 10 minutes before pruning them down. - Accuracy: The synthesized rules matched informal documentation and successfully identified the root causes of known bugs discussed in developer forums, such as those found in Apache Derby.
Conclusion and Future Work
Dynamic Package Interfaces provide a powerful way to map the "rules of the road" for complex software libraries. By leveraging monotonicity—the idea that if a call is valid in a small heap, it is likely valid in a larger one—the framework can define rules over maximal abstract configurations.
Current limitations include difficulties with external side effects (like network port binding) and recursive data structures. Future research aims to extend this formalism to stateful web services and distributed systems, where multi-object protocols are even more critical to system stability.
Summary updated