|
|
|
|
|
|
|
π Repository for automated Java code migration research, part of the MigrationBench project.
JavaMigrationAgent is a library for automated code migration from Java 8 to Java 17 (21) using LLM-based agents built on the Strands Agents framework.
It provides multiple agent strategies for migration:
- Baseline: Direct LLM-based migration
- PE (Prompt Engineering) (Baseline + PE): Baseline with enhanced prompts for dependency updates
- RAG (Baseline + PE + RAG): Uses retrieval-augmented generation for dependency version lookup
- Hybrid (Seed change, followed by baseline + PE): Pre-processes dependencies before LLM migration (More cost effective)
The agent relies on the MigrationBench package for evaluation.
2. π€ MigrationBench Datasets
| Index | Dataset | Size | Notes |
|---|---|---|---|
| 1 | π€ AmazonScience/migration-bench-java-full | 5,102 | Each repo has a test directory or at least one test case |
| 2 | π€ AmazonScience/migration-bench-java-selected | 300 | A subset of migration-bench-java-full |
Verify you have java 17 and maven 3.9.6 installed:
# java
$ java --version
openjdk 17.0.15 2025-04-15 LTS
OpenJDK Runtime Environment Corretto-17.0.15.6.1 (build 17.0.15+6-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.15.6.1 (build 17.0.15+6-LTS, mixed mode, sharing)# maven
$ mvn --version
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: /usr/local/bin/apache-maven-3.9.6
Java version: 17.0.15, vendor: Amazon.com Inc., runtime: /usr/lib/jvm/java-17-amazon-corretto.x86_64If you haven't done it yet, follow the instructions in MigrationBench to install Maven.
# cd .../JavaMigration/
pip install -r requirements.txt -e .Or with uv:
# cd .../JavaMigration/
uv pip install -e .See the full binary script at src/java_migration_agent/main.py.
| Agent Type | Description |
|---|---|
baseline |
Direct LLM migration with mvn clean verify |
pe |
Baseline with prompt engineering for dependency updates |
rag |
Uses dependency version lookup tool for migration |
hybrid |
Pre-processes pom.xml dependencies before LLM migration |
Run batch migration on the MigrationBench dataset:
python -m java_migration_agent \
--agent-type baseline \
--exp-id exp-001 \
--hf-dataset AmazonScience/migration-bench-java-selected \
--model-id global.anthropic.claude-sonnet-4-5-20250929-v1:0 \
--max-workers 8 \
--output-dir ./migration_results| Flag | Type | Default | Description |
|---|---|---|---|
--agent-type |
str |
(required) | Agent type: baseline, pe, rag, or hybrid |
--exp-id |
str |
(required) | Experiment identifier for organizing results |
--hf-dataset |
str |
AmazonScience/migration-bench-java-selected |
HuggingFace dataset name |
--model-id |
str |
global.anthropic.claude-sonnet-4-5-20250929-v1:0 |
Bedrock model ID |
--temperature |
float |
1.0 |
Model temperature |
--max-messages |
int |
80 |
Maximum messages per conversation |
--max-workers |
int |
8 |
Maximum parallel workers |
--output-dir |
str |
./migration_results |
Output directory for results |
Agent trajectories and execution results are stored in the data/ folder.
- π€ MigrationBench (Hugging Face)
- π» MigrationBench (GitHub)
- π arXiv Paper
@inproceedings{liu2026migrationbench,
title={Migrationbench: Repository-level code migration benchmark from java 8},
author={Liu, Linbo and Liu, Xinle and Zhou, Qiang and Chen, Lin and Liu, Yihan and Nguyen, Hoan and Tehrani, Behrooz Omidvar and Shen, Xi and Huan, Jun and Tripp, Omer and others},
booktitle={Proceedings of the 32nd ACM SIGKDD Conference on Knowledge Discovery and Data Mining V. 2},
pages={9427--9438},
year={2026}
}