Add relocation rules for org.kohsuke (args4j) and com.vladium (EMMA RT)
to prevent classpath conflicts from unshaded JaCoCo CLI transitive deps.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2. JFR tool not found — missing JAVA_HOME fallback
3. JaCoCo coverage broken — -DargLine was overwriting JaCoCo's agent flag
4. runtime=0 dropped — if result.runtime: was falsy for zero-nanosecond result
Relocate Gson, Kryo, Objenesis, SLF4J, JaCoCo, and ASM under
com.codeflash.shaded.* in both Maven (shade plugin) and Gradle
(shadow plugin). SQLite is left unshaded due to native lib loading.
Also adds jarHell/thirdPartyAudit to the Gradle skip-validation init
script as a defensive measure, and adds Gradle wrapper + syncs JaCoCo
deps to the Gradle build.
Fixes OpenSearch jar-hell failures caused by duplicate com.google.gson
classes between the fat JAR and project dependencies.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add JaCoCo runtime and CLI dependencies to Gradle build. Split Maven validation
skip properties into true/false groups so failOnViolation flags are set to false
instead of true. Add Gradle wrapper and integration tests for Java auto-config.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TODO-34: TracingClassVisitor hardcoded line number to 0 because ASM's
visitMethod() doesn't provide line info. Added a pre-scan pass in
TracingTransformer.instrumentClass() that collects first line numbers
via visitLineNumber() before the instrumentation pass.
TODO-38: Serialization timeouts/failures silently dropped captures with
no visibility. Added AtomicInteger droppedCaptures counter and included
it in flush() metadata output.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ReplayHelper now reads CODEFLASH_MODE env var and produces the same
output as the existing test instrumentation:
- Behavior mode: captures return value via Kryo serialization, writes
to SQLite (test_results table) for correctness comparison, prints
start/end timing markers
- Performance mode: runs inner loop for JIT warmup, prints timing
markers for each iteration matching the expected format
- No mode: just invokes the method (trace-only or manual testing)
This achieves feature parity with the existing test instrumentation
for replay tests, which call functions via reflection and can't be
wrapped by text-level instrumentation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Java projects no longer need a standalone config file. Codeflash reads
config from pom.xml <properties> or gradle.properties, and auto-detects
source/test roots from build tool conventions.
Changes:
- Add parse_java_project_config() to read codeflash.* properties from
pom.xml and gradle.properties
- Add multi-module Maven scanning: parses each module's pom.xml for
<sourceDirectory> and <testSourceDirectory>, picks module with most
Java files as source root, identifies test modules by name
- Route Java projects through build-file detection in config_parser.py
before falling back to pyproject.toml
- Detect Java language from pom.xml/build.gradle presence (no config needed)
- Fix project_root for multi-module projects (was resolving to sub-module)
- Fix JFR parser / separators (JVM uses com/example, normalized to com.example)
- Fix graceful timeout (SIGTERM before SIGKILL for JFR dump + shutdown hooks)
- Remove isRecording() check from TracingTransformer (was preventing class
instrumentation for classes loaded during serialization)
- Delete all codeflash.toml files from fixtures and code_to_optimize
- Add 33 config detection tests
- Update docs for zero-config Java setup
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The test was creating SQLite tables with the old schema (iteration_id,
loop_index, return_value) but Comparator.readTestResults() now expects
test_module_path, test_class_name, and test_function_name columns.
Also configure javadoc plugin with doclint=none and failOnError=false
to prevent malformed HTML in comments from blocking the release build.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add central-publishing-maven-plugin to the release profile and developer
ID for Sonatype namespace verification.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix mypy error: assert coverage_xml_path is not None before
generate_jacoco_report call (control flow guarantees it but mypy
can't infer it)
- Remove unused _JAVA_RESOURCES_DIR constant from build_tools.py
- Make AgentDispatcher routing robust: check startsWith("config=") or
contains(",config=") instead of bare substring match, preventing
false positive on paths containing "config="
- Drop redundant exception arg from logger.exception call
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge JaCoCo agent and CLI into the runtime JAR instead of shipping 3
separate JARs. JaCoCo already self-shades its internals with a version
hash, so no relocation is needed.
- Add AgentDispatcher premain that routes to profiler (config=) or
JaCoCo (destfile=) based on agent args
- Update shade plugin: Premain-Class → AgentDispatcher, add
ServicesResourceTransformer and DontIncludeResourceTransformer
- Rewrite build_jacoco_agent_arg() and generate_jacoco_report() to use
the runtime JAR instead of separate JaCoCo JARs
- Delete org.jacoco.agent-0.8.13-runtime.jar and
org.jacoco.cli-0.8.13-nodeps.jar from resources/
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add required metadata for Maven Central publishing:
- Project URL, Apache-2.0 license, developer info, SCM URLs
- Release profile (-Prelease) with source, javadoc, and GPG signing plugins
- Plugins only activate during release builds, no impact on normal development
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Guard against two correctness gaps where the comparator could return
equivalent=true with zero evidence: empty databases and identical
DeserializationError maps. Add tracking counters and stderr logging.
Co-Authored-By: Claude Opus 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>
Merged omni-java base into PR #1279 to resolve conflicts.
Resolution approach:
1. test_discovery.py: Used refactored method call resolution from base
- New approach uses sophisticated type tracking (jedi-like "goto")
- Already includes duplicate checking (line 141)
- Removed old Strategy 3 (class-based fallback) as it's not needed
and caused single-function optimization issues
2. test_instrumentation.py: Combined both changes
- Added API key setup from PR #1279
- Kept FunctionToOptimize imports from base
The refactored code is more accurate and fixes the single-function
optimization issue that existed in the original PR.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add CODEFLASH_API_KEY for test_instrumentation.py tests that instantiate Optimizer
- Create pom.xml for codeflash-java-runtime with Gson and SQLite JDBC dependencies
- Add CI step to build and install JAR before running tests
- Update .gitignore to allow pom.xml in codeflash-java-runtime
- All 348 Java tests now pass including 5 Comparator JAR integration tests
The Comparator was reading from an `invocations` table, but Java instrumentation
writes to a `test_results` table. This aligns the Comparator with the cross-language
schema consistency requirement.
Changes:
- Update SQL query to SELECT from test_results table
- Map columns: iteration_id + loop_index → call_id
- Map return_value → resultJson for comparison
- Construct method_id from test_class_name.function_getting_tested
- Add parseIterationId() helper to extract numeric ID from string format
- Set args_json and error_json to null (not captured in test_results schema)
This enables behavior verification to work correctly by reading the data
that instrumented tests actually write.
Test results: All 336 Java tests pass (18 comparator tests + 318 others)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>