Object Graph Programming
Aditya Thimmaiah, Leonidas Lampropoulos, Christopher J. Rossbach, Milos Gligoric
TL;DR
This work introduces Object Graph Programming (OGO), a paradigm that treats the JVM's in‑memory object heap as a property graph and exposes declarative querying and updating via Cypher. The authors implement two Java prototypes: an in‑memory engine (OGO^Mem) and a Neo4j-based pipeline (OGO^Neo) that translates object graphs into a graph database for Cypher execution. They formalize OGO with Featherweight Java semantics and demonstrate practical utility by rewriting hundreds of assertions and implementing library methods in OGO, then evaluating performance across open‑source projects. Results indicate that the in‑memory approach delivers strong performance, while the Neo4j variant provides rich tooling and debugging capabilities, with an open-source release enabling broader adoption and experimentation.
Abstract
We introduce Object Graph Programming (OGO), which enables reading and modifying an object graph (i.e., the entire state of the object heap) via declarative queries. OGO models the objects and their relations in the heap as an object graph thereby treating the heap as a graph database: each node in the graph is an object (e.g., an instance of a class or an instance of a metadata class) and each edge is a relation between objects (e.g., a field of one object references another object). We leverage Cypher, the most popular query language for graph databases, as OGO's query language. Unlike LINQ, which uses collections (e.g., List) as a source of data, OGO views the entire object graph as a single "collection". OGO is ideal for querying collections (just like LINQ), introspecting the runtime system state (e.g., finding all instances of a given class or accessing fields via reflection), and writing assertions that have access to the entire program state. We prototyped OGO for Java in two ways: (a) by translating an object graph into a Neo4j database on which we run Cypher queries, and (b) by implementing our own in-memory graph query engine that directly queries the object heap. We used OGO to rewrite hundreds of statements in large open-source projects into OGO queries. We report our experience and performance of our prototypes.
