Skip to content

Conversation

@Priyank-Shethia3
Copy link

Add Java Procedural Bug Generation

Summary

Implements procedural bug generation for Java, matching the existing implementations for Python adn Go. This adds support for automatically generating diverse, realistic bugs in Java repositories for training and evaluation purposes.

Implementation Details

Core Components

  • 10 Procedural Modifiers (matching Python/Go/Rust coverage):

    • 5 Operation modifiers: change operators, flip operators, swap operands, change constants, break chains
    • 2 Control flow modifiers: invert if-else branches, shuffle independent lines
    • 3 Remove modifiers: remove loops, conditionals, assignments
  • Enhanced JavaEntity: Added property analysis and cyclomatic complexity calculation for accurate candidate filtering

  • Registration: Integrated with MAP_EXT_TO_MODIFIERS for .java file handling

Files Added/Modified

swesmith/bug_gen/procedural/java/
├── __init__.py           # Exports all Java modifiers
├── base.py               # JavaProceduralModifier base class
├── operations.py         # 5 operation-related modifiers
├── control_flow.py       # 2 control flow modifiers
└── remove.py             # 3 removal modifiers

swesmith/bug_gen/adapters/java.py  # Enhanced with property analysis
swesmith/bug_gen/procedural/__init__.py  # Registered Java modifiers

Testing

Successfully tested on Gson repository (google__gson.dd2fe59c):

  • Extracted 1030 Java entities
  • Generated 200+ diverse bugs across all modifier types
  • Each bug includes both .json metadata and .diff patch files
  • Verified on both Windows (standalone) and Linux/WSL (official script)

Usage

# Generate bugs for Java repository
python -m swesmith.bug_gen.procedural.generate google__gson.dd2fe59c --seed 42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants