Skip to content

feat: add early module import validation for Java#1758

Open
aseembits93 wants to merge 1 commit intoomni-javafrom
feat/early-module-import-validation-java
Open

feat: add early module import validation for Java#1758
aseembits93 wants to merge 1 commit intoomni-javafrom
feat/early-module-import-validation-java

Conversation

@aseembits93
Copy link
Contributor

Summary

  • Add pre-flight can_be_optimized() check for Java that validates module structure (source root, build config, package declaration) before making expensive API calls
  • Create JavaFunctionOptimizer subclass with auto-correction of misconfigured module roots via try_correct_module_root()
  • Use function_optimizer_class dispatch in optimizer.py instead of hardcoded FunctionOptimizer, matching the Python and JavaScript pattern

Changes

File Action
codeflash/code_utils/config_java_validation.py Newvalidate_java_module_resolution() and infer_java_module_root()
codeflash/languages/java/function_optimizer.py NewJavaFunctionOptimizer with validation, context extraction, and method overrides
codeflash/languages/java/support.py Modified — Added function_optimizer_class property
codeflash/optimization/optimizer.py Modified — Use function_optimizer_class dispatch
tests/code_utils/test_config_java_validation.py New — 11 validation unit tests
tests/test_languages/test_java/test_java_function_optimizer_validation.py New — 5 optimizer integration tests

Test plan

  • All 11 validation unit tests pass (test_config_java_validation.py)
  • All 5 optimizer integration tests pass (test_java_function_optimizer_validation.py)
  • Existing Java test suite (646 tests) passes with no new regressions
  • Ruff lint and format checks pass

🤖 Generated with Claude Code

Prevent wasted API calls by validating Java module structure (source
root, build config, package declaration) before optimization. Adds
JavaFunctionOptimizer with auto-correction of misconfigured module
roots, matching the pattern from Python and JavaScript implementations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

@HeshamHM28 HeshamHM28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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