Skip to content

Fix inherited method resolution for invokespecial - #228

Merged
dlunch merged 4 commits into
mainfrom
fix/invokespecial-superclass
Oct 26, 2026
Merged

dlunch merged 4 commits into
mainfrom
fix/invokespecial-superclass

Conversation

@dlunch

@dlunch dlunch commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Changes

  • Resolve non-constructor invokespecial targets through the class hierarchy and execute them in the declaring class; retain constructor and static/abstract error contracts.
  • Select maximally-specific inherited interface methods independent of declaration order, excluding private methods and deduplicating shared ancestors.
  • Exercise superclass calls, default-method selection, and linkage errors through the existing compiled Java fixture runner.
  • Clarify fixture reuse and reproducible linkage-error testing in AGENTS.md.

Verification

  • Workspace tests: 581 passed, 2 existing tests ignored.
  • Oracle JDK 25 comparisons: inherited superclass/default calls and constructor/static/abstract errors match.
  • Native all-targets and wasm32 Clippy with warnings denied; formatting and diff checks passed.

Copilot AI balanced review requested due to automatic review settings October 26, 2026 08:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T09:49:27.038632Z 3debcd4 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.84%. Comparing base (f39c6a0) to head (3debcd4).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 via resolve_method up the hierarchy and execute in the declaring class, while keeping constructor lookup local; add an AbstractMethodError check (alongside the existing IncompatibleClassChangeError for static targets).
  • Extend SuperClass inheritance fixture with an InnerLeafClass that exercises an inherited super.test() call, and update expected output.
  • Add test_special_resolution_errors plus Abstract.java constructors to cover NoSuchMethodError (non-inherited constructor), AbstractMethodError, and IncompatibleClassChangeError.
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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread jvm/src/jvm.rs
@dlunch dlunch changed the title Fix superclass method lookup for invokespecial Fix inherited method resolution for invokespecial Oct 26, 2026
@dlunch
dlunch merged commit e90048c into main Oct 26, 2026
15 checks passed
@dlunch
dlunch deleted the fix/invokespecial-superclass branch October 26, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants