- Fix MockTestConfig missing tests_project_rootdir field
- Fix Python line profiler existence check on wrong path (no .lprof suffix)
- Add --release 11 to javac in Java line profiler tests for JDK compat
- Resolve merge conflicts with omni-java (replacement, tests)
- Add replace_function_definitions method to JavaSupport
- Guard against wrong method names in optimized code (standalone + class)
- Add tests for anonymous inner class method hoisting
Replace substring-based assertions with a single exact string
comparison in test_anonymous_iterator_methods_not_hoisted_to_class,
matching the convention used elsewhere in the test file.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace with protocol dispatch via current_language_support():
- create_pr.py: use default_file_extension for path resolution
- verification_utils.py: use default_file_extension/get_test_file_suffix
- parse_test_output.py: compute uses_java_timing_markers once from extension
- instrument_existing_tests.py: remove dead Java branch (already dispatched
via JavaSupport.instrument_existing_test)
The Java test runner was overwriting the env var with the parameter default
(10), ignoring the value set by the test. Now only sets it if not already
present in the env.
- Fix language detection in code_replacer to use lang_support.language
(was None when function_to_optimize absent, blocking Java class member insertion)
- Update discover_functions calls in test_integration.py to pass source param
- Remove inner_iterations kwarg from test_run_and_parse.py (handled internally)
- Use os.path.relpath for main.py path in e2e tests
- Remove pass_fail_only kwarg from JS/Java function optimizers
- Fix Java e2e test to use JavaFunctionOptimizer for code context
- Detect codeflash.toml in e2e test runner (not just pyproject.toml)
- Use os.path.relpath for main.py path (works for any cwd depth)
- Remove pass_fail_only kwarg from JS/Java compare_test_results fallback
(main removed this parameter from equivalence.compare_test_results)
- Fix min/max_outer_loops → pytest_min/max_loops in Java test_run_and_parse
- Update test_replacement.py for new replace_function_definitions_for_language API
- Update JavaSupport.discover_functions signature to match protocol
- Migrate _get_java_sources_root/_fix_java_test_paths to JavaFunctionOptimizer
- Fix test_java_tests_project_rootdir to use set_current_language
Updates canary test to check JavaFunctionOptimizer instead of base
function_optimizer (comparison logic moved to subclass). Renames
min/max_outer_loops back to pytest_min/max_loops to match main's API.
Updates inject_profiling_into_existing_test calls to include test_string
parameter. Takes main's test refactoring for multi-file code replacement
and codeflash capture.
Two bugs in _parse_optimization_source (replacement.py) caused Maven compilation
failures when codeflash optimised aerospike-client-java:
Bug 1 – standalone method with wrong name replaces target
When the LLM generated a standalone method whose name did not match the
optimisation target (e.g. generated `unpackMap` for target `unpackObjectMap`,
or generated `sizeTxn` for target `estimateKeySize`), the function fell back to
using the entire generated snippet as `target_method_source`. This silently
replaced the target with the wrong method, producing:
• a duplicate definition of the wrong method
• removal of the target method (breaking all callers)
Fix: after parsing standalone (class-free) code, verify that at least one
discovered method matches the target name. If no match is found, set
`target_method_source` to the empty string and log a warning. A corresponding
guard in `replace_function` returns the original source unchanged when
`target_method_source` is empty.
The same guard is applied to the full-class path: if the generated class does
not contain the target method, the candidate is also rejected.
Bug 2 – anonymous inner-class methods hoisted as top-level helpers
When an optimised method returned an anonymous class (e.g. `keySetIterator`
returning `new Iterator<LuaValue>() { … }`), tree-sitter's recursive walk
found the anonymous class's `hasNext`, `next`, and `remove` method_declaration
nodes and classified them as helpers to be inserted at the outer-class level.
The inserted methods carried `@Override` annotations that matched nothing in the
outer class and referenced local variables (`it`) that were only in scope inside
the optimised method body, producing compilation errors.
Fix: when extracting helpers from the optimised class, skip any method whose
line range is entirely contained within the target method's line range. Such
methods belong to anonymous/nested classes inside the method body and must not
be hoisted out as standalone class members.
Tests added for both bugs in TestWrongMethodNameGeneration and
TestAnonymousInnerClassMethods.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Java Comparator used only iteration_id as the map key when comparing
test results. Since every test method had iteration_id="1", all rows
collapsed to a single entry and only the last row survived. Because JUnit
test execution order is non-deterministic, the surviving row differed
between baseline and candidate runs, causing false correctness failures.
Fix the key to include test_module_path:test_class_name:test_function_name
for unique identification. Also add an A/A test that runs the original code
through the candidate pipeline to detect verification bugs like this.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>