Fix BytecodeComplianceMojo skipping checks on recompiled classes#5216
Open
shai-almog wants to merge 1 commit into
Open
Fix BytecodeComplianceMojo skipping checks on recompiled classes#5216shai-almog wants to merge 1 commit into
shai-almog wants to merge 1 commit into
Conversation
The compliance skip-gate compared only source mtimes against the compliance_check.txt marker. The check's invocation rewrites (String.replaceAll/replaceFirst/split -> JdkApiRewriteHelper) mutate target/classes in place, so a later compile pass that regenerates the classes with unchanged sources silently sheds the rewrites and the gate keeps skipping. The unrewritten bytecode then reaches ParparVM, which emits calls to virtual_java_lang_String_replaceAll etc. that its JavaAPI never declares, failing iOS builds deep inside xcodebuild. The skip is now only taken when, in addition to unchanged sources: - no .class under the output directory (or the kotlin-ic incremental output tree) is newer than the marker. The marker is written after the rewrites, so an untouched output tree still skips and there is no always-rerun regression; the rewrites themselves are idempotent. - the marker records a success. Previously a rerun after a FAILED check skipped straight past the violations that had just failed the build. The failure header is now a shared constant so the report writer and the gate cannot drift apart. Verified end-to-end on scripts/hellocodenameone: unchanged second run still skips; touching a compiled class triggers a full re-run. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
Author
|
Compared 128 screenshots: 128 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Collaborator
Author
|
Compared 105 screenshots: 105 matched. Benchmark Results
|
Collaborator
Author
|
Compared 128 screenshots: 128 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 124 screenshots: 124 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 121 screenshots: 121 matched. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
BytecodeComplianceMojo.hasChangedSinceLastCheck()gated the compliance check purely on source mtimes vs thecompliance_check.txtmarker. But the check's invocation rewrites (String.replaceAll/replaceFirst/split→JdkApiRewriteHelper, added in #4893) mutatetarget/classesin place. When a later build recompiles those classes with unchanged sources (e.g. a secondmvn packagere-running javac), the rewrites are silently lost — and the source-only gate keeps skipping, so they are never re-applied.The unrewritten bytecode then reaches ParparVM, which emits calls to
virtual_java_lang_String_replaceAll___...that its JavaAPI never declares, and the iOS build fails deep inside xcodebuild:(Hit in practice while iterating on local iOS builds of
scripts/hellocodenameone; the only recovery was wipingcommon/target.)A second hole in the same gate: after a failed check writes its violation report into the marker file, a rerun with unchanged sources skipped the check entirely — the build that had just failed would silently pass.
Fix
The skip is now only taken when, in addition to unchanged sources:
.classfiles under the output directory and thetarget/kotlin-ic/compile/classesincremental Kotlin tree. The marker is written after the rewrites, so an untouched output tree still skips (no always-rerun perf regression), and the rewrites are idempotent when a re-run does happen.Testing
BytecodeComplianceMojoTestcovering: recompiled classes invalidate the skip (and older classes do not), newer classes in the kotlin-ic tree invalidate the skip, and a previous failure report forces a re-run.scripts/hellocodenameonewith the installed plugin: an unchanged second run still logs "Sources haven't changed since the last compliance check. Skipping check"; touching a compiled class triggers a full re-run instead of the silent skip.🤖 Generated with Claude Code