Return as soon as the instrumentation decision is known - #831
Conversation
(Suggested by Michael Ernst in review of PR 685) Several paths set targetInstrumented to false and broke out of the search only to reach the return. They now return directly. That requires moving the INVOKESPECIAL handling to the top of the method: it records that a super(...) or this(...) call has left the receiver initialized, and left at the end it would be skipped by the new early returns. Nothing between the two positions reads the flag; its only reader is tag_fields_ok, reached from load_store_field. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A1De2wQi77Zz4pnapvnFJz
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthrough
Suggested reviewers: Priority: ⬇️ Low Change: Bug fix Merge Risk: ⚪ Minimal · up to The instrumentation changes preserve constructor initialization before early exits, with no current merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Suggested by Michael Ernst in review of PR #685. Independent of #828 and #830.
isTargetInstrumented(BCEL) and its counterpart inDCInstrument24decide whether an invoke's target is instrumented. Several paths settargetInstrumented = falseand broke out of the search only to fall through to thereturn. They now return directly.Why the two halves of this change belong together
The early returns are only safe because the
INVOKESPECIALhandling moved to the top of the method. That block records that asuper(...)orthis(...)call has left the receiver initialized:Left at the end, every new early-return path would silently skip it. That is not hypothetical: the same flag going unset is what produced a comparability regression in
Hanoiduring the Java 24 port, where a delegating constructor's field write emitteddiscard_taginstead of the field'sset_tagaccessor, moving the field out of the parameter's comparability set.Moving it is safe because nothing between the old and new positions reads the flag. Its only reader is
tag_fields_ok, reached fromload_store_field-- a different method, applied to field-access instructions later in the walk. So a field read before thesuper()call still sees the flag unset, and one after still sees it set.Note on test coverage
The
DCInstrument24half is covered: removing the flag assignment makesdelegatingConstructorInitializesReceiverfail.The
DCInstrumenthalf is not.AllTestsSuitecontains noDCInstrumenttests, so removing the same assignment there leaves the whole suite green. That half rests on compilation and on symmetry with the verified sibling. Flagging it because this change is specifically about preserving a side effect, and because the originalHanoiregression was caught only by the system tests.Testing
make compile,make JAVA24=1 junit(105 + 13),make check-format,javadoc -Xdoclint:all, and all sixtypecheck-part1checkers against the bundled Checker Framework are clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01A1De2wQi77Zz4pnapvnFJz