|
|
|
|
|
|
|
|
MigrationBench provides an automated and robust framework for evaluating code migration success.
1.1 MigrationBench: Dataset and Evaluation Framework
The name MigrationBench is used for both the dataset and the evaluation framework for code migration success:
- π€ MigrationBench
is a large-scale code migration benchmark dataset at the repository level,
across multiple programming languages.
- Current and initial release includes
java 8repositories with themavenbuild system, as of May 2025.
- Current and initial release includes
- MigrationBench
(current Github package)
is the evaluation framework to assess code migration success,
from
java 8to17or any other long-term support (LTS) versions.
The evaluation is an approximation for functional equivalence by checking the following:
- The repo is able to build and pass all tests
- Compiled classes' major versions are consistent with the target
javaversion52and61forjava 8and17respectively
- Test methods are invariant after code migration
- Number of test cases is non-decreasing after code migration
- The repos' dependency libraries match their latest major versions
- Optional for minimal migration by definition, while
- Required for maximal migration
1.2 JavaMigration: Migration with LLMs
JavaMigration is a separate Github package to conduct code migration with LLMs as a baseline solution, and it relies on the current package for the final evaluation.
2. π€ MigrationBench Datasets
There are three datasets in π€ MigrationBench:
- All repositories included in the datasets are available on GitHub, under the
MITorApache-2.0license.
| 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 |
| 3 | π€ AmazonScience/migration-bench-java-utg |
4,814 | The unit test generation (utg) dataset, disjoint with π€ migration-bench-java-full |
MigrationBench supports two evaluation modes:
- Docker Mode (Recommended): Runs evaluations in isolated Docker containers. No need to install Java or Maven locally.
- Local Mode: Runs evaluations directly on your machine. Requires Java 17 and Maven 3.9.6 installed locally.
Docker mode provides a consistent evaluation environment without requiring local Java/Maven installation. Each evaluation runs in an isolated container, making it ideal for batch processing and reproducible results.
Benefits:
- β No local Java/Maven installation needed
- β Consistent environment across different machines
- β Parallel execution (multiple containers)
- β Easy setup and onboarding
1. Install Docker:
Follow the official Docker installation guide:
- macOS: https://docs.docker.com/desktop/install/mac-install/
- Windows: https://docs.docker.com/desktop/install/windows-install/
- Linux: https://docs.docker.com/engine/install/
2. Verify Docker:
docker --version3. Install MigrationBench:
git clone https://github.com/amazon-science/MigrationBench.git
cd MigrationBench
pip install -r requirements.txt -e .That's it! The Docker image will be built automatically on first run.
To run a single repository evaluation in Docker:
GITHUB_URL=https://github.com/0xShamil/java-xid
GIT_DIFF_FILE=/path/to/java-xid.diff
python run_eval.py --github_url $GITHUB_URL --git_diff_filename $GIT_DIFF_FILE --use_dockerEvaluate with a migrated repository directory:
MIGRATED_DIR=/path/to/migrated/repo
python run_eval.py --github_url $GITHUB_URL --migrated_root_dir $MIGRATED_DIR --use_dockerForce rebuild the Docker image:
python run_eval.py --github_url $GITHUB_URL --git_diff_filename $GIT_DIFF_FILE --use_docker --build_docker_imageTo run batch evaluations in Docker:
PREDICTIONS=predictions.json
# Run batch evaluation in Docker
python run_eval.py --predictions_filename $PREDICTIONS --use_dockerWith parallel processing (recommended for large batches):
# Run 8 Docker containers in parallel (each evaluates one repo)
python run_eval.py --predictions_filename $PREDICTIONS --use_docker --max_workers 8Important Notes:
- File paths in the predictions file should be absolute paths on your host system
- The Docker container will automatically mount these paths as read-only volumes
- Each repository is evaluated in its own isolated container
- Docker mode automatically handles environment isolation and cleanup
Local mode runs evaluations directly on your machine. This requires Java 17 and Maven 3.9.6 installed locally.
Install Java 17:
- macOS:
brew install openjdk@17 - Ubuntu/Debian:
sudo apt-get install openjdk-17-jdk - Windows: Download from https://adoptium.net/
Install Maven 3.9.6:
- macOS:
brew install maven - Ubuntu/Debian:
sudo apt-get install maven - Windows: Download from https://maven.apache.org/download.cgi
Verify installations:
java -version # Should show version 17
mvn -version # Should show version 3.9.6git clone https://github.com/amazon-science/MigrationBench.git
cd MigrationBench
pip install -r requirements.txt -e .GITHUB_URL=https://github.com/0xShamil/java-xid
GIT_DIFF_FILE=/path/to/java-xid.diff
python run_eval.py --github_url $GITHUB_URL --git_diff_filename $GIT_DIFF_FILEPREDICTIONS=predictions.json
# Sequential processing
python run_eval.py --predictions_filename $PREDICTIONS
# Parallel processing (8 workers)
python run_eval.py --predictions_filename $PREDICTIONS --max_workers 8For batch evaluation (both Docker and Local modes), provide a predictions file in JSON format.
For each repository, specify the GitHub URL and one of the following:
git_diff_file: Path to a file containing the git diffgit_diff: Git diff content as a string (can be empty for no changes)migrated_root_dir: Absolute path to the migrated repository directory
Example predictions.json:
[
{
"github_url": "https://github.com/0xShamil/java-xid",
"git_diff_file": "/absolute/path/to/java-xid.diff"
},
{
"github_url": "https://github.com/0xShamil/java-xid",
"git_diff": "diff --git a/pom.xml b/pom.xml\n--- a/pom.xml\n+++ b/pom.xml\n..."
},
{
"github_url": "https://github.com/0xShamil/java-xid",
"migrated_root_dir": "/absolute/path/to/migrated/java-xid"
}
]@misc{liu2025migrationbenchrepositorylevelcodemigration,
title={MigrationBench: Repository-Level Code Migration Benchmark from Java 8},
author={Linbo Liu and Xinle Liu and Qiang Zhou and Lin Chen and Yihan Liu and Hoan Nguyen and Behrooz Omidvar-Tehrani and Xi Shen and Jun Huan and Omer Tripp and Anoop Deoras},
year={2025},
eprint={2505.09569},
archivePrefix={arXiv},
primaryClass={cs.SE},
url={https://arxiv.org/abs/2505.09569},
}