Skip to content

Neuvem/java2graph

Repository files navigation

Java2Graph

Java2Graph is a high-performance, memory-optimized AST parser and Code Property Graph (CPG) generator for Java codebases. Developed by Neuvem, it is specifically designed to parse massive Java monoliths (e.g., Spring Framework, Apache Kafka) and export heavily deduplicated structural graphs directly into a binary LadybugDB database.

Features

  • Blazing Fast Extraction: Uses a highly optimized Heuristic fastResolve pipeline to deduce call chains and inheritance relationships in seconds, bypassing the crippling GC-overhead of traditional Deep Symbol Solvers.
  • Native Lombok Support: Natively integrates DelombokPass to dynamically proxy source roots and reconstruct missing AST entities (like Getters/Setters generated by @Data) before parsing, with built-in fallbacks.
  • Memory Stable: Sequentially isolated AST streams and aggressive ClassLoader proxying guarantee successful extraction on massive 15,000+ file projects without encountering OutOfMemory errors.
  • Data Integrity: Global Set-based hashing models natively guarantee absolutely zero duplicate edges are written to the database, even when processing highly misconfigured multi-module source roots.
  • Zero-Dependency Native Binary: Ships via jpackage alongside a custom, minified JRE containing only the exact JVM modules required.

Installation

Prerequisites

  • JDK 17
  • Maven 3+

Building from Source

To build a standard Java fat-jar:

mvn clean package -DskipTests

Standalone Binary (Mac/Linux/Windows)

To build a fully encapsulated native operating system application (bundled with a minified JRE):

./build-standalone.sh

Your standalone binary will be available at dist/java2graph.

Installing Ladybug CLI (lbug)

To query the databases generated by Java2Graph, you should install the Ladybug CLI (lbug).

macOS (via Homebrew):

brew install ladybug

Linux / Generic Shell (via Install Script):

curl -s https://install.ladybugdb.com | bash

Manual Installation: You can also download precompiled binaries directly from the Ladybug Releases page. Extract the archive and ensure the lbug binary is in your system PATH.

Usage

If using the compiled .jar:

java -jar target/java2graph-1.0-SNAPSHOT-jar-with-dependencies.jar -s <path_to_source> -d <output_db_dir> [OPTIONS]

If using the Standalone App Image:

./dist/java2graph/java2graph -s <path_to_source> -d <output_db_dir> [OPTIONS]

Options

Flag Name Description Default
-s, --src Source Directory (Required) Path to the Java source code directory. N/A
-j, --jars Dependencies Paths to dependency jars or directories (comma-separated or repeatable). N/A
-d, --out-db Database Output Directory or path to output the Ladybug DB files. .
-c, --out-csv CSV Output Directory to output the CSV files. .
-l, --lombok Enable Lombok Enable Lombok preprocessing before parsing. false
-f, --fast Fast Resolution Use fast AST heuristic resolution instead of exact symbol solver. false
-t, --threads Thread Count Number of threads for parallel processing. 4
--help Help Show standard help message and exit. N/A
--version Version Show version information and exit. N/A

Querying the Result

Once the extraction completes, the data is structured natively for LadybugDB queries via Open Cypher.

Discover Unresolved Method Calls:

MATCH (caller:Method)-[c:Calls]->(callee:Method)
WHERE callee.id CONTAINS "<unresolvedNamespace>" 
RETURN count(c);

Find Interface Implementations:

MATCH (c:Class)-[:Implements]->(i:Interface)
RETURN c.fqn, i.fqn;

License

Java2Graph is developed and maintained by Neuvem.

About

A java source code to graph db converter

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors