﻿# Defects4J: align buggy and fixed Java versions

Align Defects4J buggy and fixed Java versions using stable bug identities, triggering tests, exported classpaths, and release-specific environment conditions.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/data-guide-defects4j-buggy-fixed-pairs/
Language: en

## Pair versions through the benchmark identity

The [Defects4J repository](https://github.com/rjust/defects4j) describes reproducible Java bugs with minimized fixes and triggering tests. Its inspected README identifies version 3.0.1. A project identifier and bug identifier select the case; buggy and fixed revisions use the `b` and `f` suffixes. These are benchmark-prepared versions, with irrelevant fixing-commit changes pruned by maintainers. Comparing arbitrary adjacent upstream commits can therefore produce a different edit set. Preserve the benchmark release alongside the case identity when extracting a repair example.

## Keep active and deprecated identities distinct

The repository retains deprecated-bug metadata and does not renumber the remaining active bugs. A gap in identifiers is not an extraction error. Newer Java behavior can affect reproducibility, so an earlier paper's population need not equal a current active selection. State whether the study reproduces a historical release or uses today's recorded active set. Store this selection with [provenance information](/journal/document-markdown-json-provenance/) before joining saved predictions, patches, or fault locations to an exported table.

## Export the checked-out version's properties

The [export command](https://defects4j.org/html_doc/d4j/d4j-export.html) returns version-specific properties from a checked-out workspace. These include source and test directories, compilation and test classpaths, modified classes, and test sets. Use those properties rather than inferring a uniform project layout. `tests.trigger` identifies test methods exposing the bug; `tests.relevant` has a broader class-based meaning. A model input made from modified classes is also a localization assumption. Label that assumption explicitly if evaluating repair rather than unrestricted repository diagnosis.

## Validate both sides under the same test scope

The [test command documentation](https://defects4j.org/html_doc/d4j/d4j-test.html) distinguishes normal test execution, a selected method, and supplied external suites. Record which was used and retain the failing-test report. First confirm the intended contrast between the prepared buggy and fixed versions under that protocol. The repository documents Java 11 and the `America/Los_Angeles` timezone for its current reproducibility setup. Changing the runtime or timezone can introduce unrelated failures. Environment incompatibility should remain a separate outcome from a candidate patch failing the triggering regression.

## Interpret a passing patch as bounded evidence

A generated repair that passes available tests may differ from the developer fix without being wrong; conversely, passing does not prove correctness on untested behavior. Preserve patch identity and exact executed tests. For learning experiments, keep paired versions and related fixes from crossing partitions, following [leakage guidance](/journal/document-level-data-split-leakage/). Defects4J is useful for controlled Java testing, localization, and repair comparisons. It does not supply a universal train/test split or make one successful regression check an exhaustive specification of the application.
