Repository navigation
Fix inherited method resolution for invokespecial - #228
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #228 +/- ##
==========================================
+ Coverage 87.79% 87.84% +0.04%
==========================================
Files 311 311
Lines 47155 47182 +27
==========================================
+ Hits 41401 41447 +46
+ Misses 5754 5735 -19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔵 Needs a closer look
It modifies core JVM invokespecial dispatch/resolution semantics, a foundational correctness path whose subtle, broad impact warrants final human review despite the clean, well-tested diff.
No open issues 🎉
What changed in this PR
This PR fixes invokespecial method resolution in the core JVM interpreter so that non-constructor super.* calls are correctly resolved through the class hierarchy and executed in the declaring class. Previously invoke_special only looked up the method on the exact named class, so inherited super-calls would fail. Constructors are intentionally kept non-inherited (resolved locally), and static/abstract targets now map to the correct JVM errors. The change is accompanied by new compiled Java fixtures and regression tests.
Changes:
- In
Jvm::invoke_special, resolve non-<init>targets viaresolve_methodup the hierarchy and execute in the declaring class, while keeping constructor lookup local; add anAbstractMethodErrorcheck (alongside the existingIncompatibleClassChangeErrorfor static targets). - Extend
SuperClassinheritance fixture with anInnerLeafClassthat exercises an inheritedsuper.test()call, and update expected output. - Add
test_special_resolution_errorsplusAbstract.javaconstructors to coverNoSuchMethodError(non-inherited constructor),AbstractMethodError, andIncompatibleClassChangeError.
| File | Description |
|---|---|
| jvm/src/jvm.rs | Resolve non-constructor invokespecial through the hierarchy; keep <init> local; add AbstractMethodError guard. |
| tests/test_class.rs | New test_special_resolution_errors regression test for constructor/static/abstract resolution errors. |
| test-data/src/Abstract.java | Add Base() and Base(int) constructors to support the non-inherited-constructor test case. |
| test-data/src/SuperClass.java | Add InnerLeafClass overriding test() and a testSuper() that calls super.test(). |
| test-data/SuperClass.txt | Update expected output to include the new leaf and inherited test lines. |
I verified the resolution logic against resolve_method, confirmed the test compiles (imports, InvokeArg for Vec<JavaValue>, single-variant JavaError), that all referenced .class fixtures exist, and that the expected SuperClass.txt output (7 lines) matches the fixture's control flow. I found no defects.
Review effort: Balanced
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c51a61a88d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Changes
invokespecialtargets through the class hierarchy and execute them in the declaring class; retain constructor and static/abstract error contracts.AGENTS.md.Verification