Skip to content

feat(java): dispatch interface method calls to their implementers (#5319) - #5323

Open
livingforelvis wants to merge 4 commits into
Graphify-Labs:v8from
livingforelvis:feat/java-interface-dispatch
Open

livingforelvis wants to merge 4 commits into
Graphify-Labs:v8from
livingforelvis:feat/java-interface-dispatch

Conversation

@livingforelvis

@livingforelvis livingforelvis commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Closes #5319.

  • A Java call through an interface-typed field (this.worker.run()) lands on the interface method; nothing joined it to the implementer, so a directed walk stopped at the interface.
  • C# (C#: a call through an interface dead-ends at the interface method, so injected dependencies cut every chain #3003), Swift (feat(swift): dispatch a protocol requirement to its single conformer #4035) and Go (feat(go): dispatch interface method calls to implicit implementers #4934) already add dispatches_to for this; .java had no pass.
  • New graphify/java_dispatch.py: a .java gate over resolve_interface_dispatch, the same shape as swift_dispatch.py.
  • Registered in extract.py as java_interface_dispatch, after the Go dispatch pass.
  • Java already emits implements and the interface's method edges. One extractor change: a Java constructor node now carries kind: "constructor" (as C# does), so the shared resolver's constructor skip applies and interface F { void Widget(); } is never linked to Widget's constructor. _AST_CACHE_SCHEMA 48 -> 49 so cached Java extractions re-run. Fix by @Deepjyoti-Sarmah, cherry-picked with authorship kept.
  • Same rules as the other languages: additive INFERRED edges, 0.85 / 0.75 / 0.65 by implementer count, both ends declared in .java, the calls edge to the interface method kept.
  • Overloads: since the [Bug]: Java overloaded methods collapse into a single node #5251 fixes each Java overload is its own node with signature / arity metadata, so the shared pairing links each interface overload to the implementer overload of the same signature (arity as fallback), and nothing when the match is not unique.
  • One method on each side: resolve_interface_dispatch takes a keyword-only match_arity (default off, so C# and Swift are unchanged); the Java pass turns it on, so a lone implementer method pairs only at the interface method's parameter count. Without it, send(int, int) on a class inheriting send(String) got an edge.
  • interface_dispatch.py module docstring now names Swift, Go and Java beside C# (it still described C# as the only wrapper).
  • Two C# tests asserted a Java corpus gets no dispatch edge, which is no longer true:
    • test_java_interface_and_implementation_are_untouched now calls the C# pass directly on a Java pair (same pattern as the Swift test for a C# pair).
    • test_mixed_corpus_links_only_the_csharp_pair is now test_mixed_corpus_links_each_pair_within_its_own_language and expects the C# and Java pairs, never a cross-language one.

Known limits, documented in the module docstring and pinned by tests:

  • extends (abstract class or superclass override) is not read; a base method may be the real target.
  • Interface hierarchies (interface Task extends Worker) are not walked, as for C#.
  • A default method nobody overrides gets no edge; the call really lands on the default body.
  • One interface method and one implementer method of a name pair up when their parameter counts match, without comparing types: Java signatures are erased (run(T) on Worker<T> records Object, T extends Number records Number), so a type check would drop real generic pairs. send(int) beside an inherited send(String) is still linked; send(int, int) is not.
  • implements a.Worker written fully qualified, with no import, binds to a sourceless stub and gets no edge (fails closed, no edge to a same-named b.Worker); the imported form links.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Tests or CI
  • Refactor
  • Security fix

Verification & Invariants

  • Invariant: a dispatches_to edge only joins an interface method to a same-named method of a type the extractor says implements it, both declared in .java; anything else gets no edge.

  • Cross-language name collisions stay unlinked both ways (Kotlin Worker / Java implementer, Java Worker / C# implementer), and the C# pass still ignores Java pairs.

  • Persisted state: AST cache schema 48 -> 49, so a cached Java file without the constructor tag is re-extracted.

  • Read the CONTRIBUTING.md guide.

  • Reproduced the issue and identified the invariant.

  • Made the smallest fix necessary.

  • Added isolated boundary tests.

  • Kept the PR description synchronized with the final implementation.

  • Documented any limitations / unsupported cases explicitly.

How was this tested?

Environment: macOS arm64, Python 3.13.16, uv 0.13.1, uv sync --all-extras, base v8 at 340268a (0.9.112). Before = clean v8 with the new test file copied in; after = this branch.

New tests: before vs after

uv run pytest tests/test_java_interface_dispatch.py -q -rA --tb=line

Test Clean v8 With this change
test_call_through_an_interface_field_reaches_the_implementer FAIL: :69: AssertionError: assert set() == {('worker_wor...lworker_run')} PASS
test_dispatch_edge_shape_and_the_call_is_kept FAIL: :77: StopIteration (no dispatches_to edge) PASS
test_two_implementers_both_get_an_edge_at_lower_confidence FAIL: :92: AssertionError: assert set() == {('worker_wor...sworker_run')} PASS
test_three_implementers_floor_at_the_weak_inference_tier FAIL: :105: assert 0 == 3 PASS
test_overload_links_only_the_matching_signature FAIL: :125: AssertionError: assert set() == {('sender_sen...sender_send')} PASS
test_overloads_on_both_sides_pair_one_to_one FAIL: :147: AssertionError: assert set() == {('sender_sen...send_12f1a1')} PASS
test_same_arity_overloads_pair_by_parameter_type FAIL: :165: AssertionError: assert set() == {('sender_sen...send_46f8ab')} PASS
test_an_interface_overload_with_no_implementation_gets_no_edge FAIL: :178: AssertionError: assert set() == {('sender_sen...sender_send')} PASS
test_two_candidates_neither_matching_get_no_edge PASS (boundary) PASS
test_a_lone_method_with_another_parameter_count_is_not_linked PASS (boundary) PASS; before the arity check: FAIL AssertionError: assert {('sender_sen...sender_send')} == set()
test_a_lone_method_with_the_same_parameter_count_is_linked FAIL: :222: AssertionError: assert set() == {('sender_sen...sender_send')} PASS
test_constructor_is_not_a_dispatch_target FAIL: :223: AssertionError: assert set() == {('worker_wor...lworker_run')} PASS
test_a_constructor_named_like_the_interface_method_is_not_a_target FAIL: :248: KeyError: 'metadata' (constructor node untagged) PASS; before the constructor tag: FAIL AssertionError: assert {('starter_st...gine_engine')} == set()
test_no_matching_member_produces_no_edge PASS (boundary) PASS
test_abstract_base_class_is_out_of_scope PASS (boundary) PASS
test_interface_hierarchy_is_not_walked_transitively PASS (boundary) PASS
test_an_unoverridden_default_method_is_not_dispatched FAIL: :261: AssertionError: assert set() == {('worker_wor...worker_stop')} PASS
test_enum_record_and_generic_implementers_link FAIL: :271: AssertionError: assert set() == {('worker_wor...ce_once_run')} PASS
test_a_same_named_interface_in_another_language_is_not_linked PASS (boundary) PASS
test_a_same_named_kotlin_interface_is_not_linked PASS (boundary) PASS
test_a_csharp_implementer_of_a_java_interface_is_not_linked PASS (boundary) PASS
test_same_simple_name_in_two_packages_links_only_the_imported_one FAIL: :316: AssertionError: assert set() == {('a_worker_w...lworker_run')} PASS
test_a_qualified_implements_clause_is_a_known_limit PASS (boundary) PASS
test_a_csharp_pair_is_untouched_by_the_java_pass FAIL: :331: ModuleNotFoundError: No module named 'graphify.java_dispatch' PASS
test_java_pass_is_registered_with_the_other_dispatch_passes FAIL: :353: AssertionError: assert 'java_interface_dispatch' in ['terraform_modules', ...] PASS
Summary line 16 failed, 9 passed, 1 warning in 2.42s 25 passed, 1 warning in 0.42s
  • The 9 boundary tests assert "no edge" and so pass on both; they guard against the new pass over-linking.

Fixture graph: before vs after

Fixture: tests/fixtures/java_interface_dispatch/ (Worker.java, EmailWorker.java, Job.java), GRAPHIFY_BACKEND=none graphify extract <copy> --code-only --out <dir>, no API keys.

Measure Clean v8 With this change
extract summary 11 nodes, 13 edges, 3 communities 11 nodes, 14 edges, 3 communities
dispatches_to edges 0 1 (confidence_score 0.85)
graphify path "Job.execute" "EmailWorker.run" No directed path found between 'Job.execute' and 'EmailWorker.run'. Re-run with --undirected to search ignoring edge direction. Shortest path (2 hops): / .execute() --calls [INFERRED 0.85]--> .run() --dispatches_to [INFERRED 0.85]--> .run()

Full checks

Command Clean v8 With this change
uv run pytest on the C#, Go and Swift dispatch test files (+ Java on this branch) 45 passed 70 passed
uv run pytest tests -q -n 6 (pytest-xdist) 22 failed, 11549 passed, 165 skipped, 1 xfailed (run before review, with the 23-test Java file) 7 failed, 11566 passed, 165 skipped, 1 xfailed
uv run ruff check . All checks passed! All checks passed!
uv run pyright 761 errors 760 errors (0 in java_dispatch.py and the Java test file)
uv run python -m tools.skillgen --check check OK: 134 artifact(s) check OK: 134 artifact(s)
  • Clean v8's 22 = the 15 new Java tests + 7 parallel-run failures.
  • Parallel-run failures, all passing serially:
    • Both trees: 6 × test_terraform_modules.py::test_copied_ast_cache_preserves_terraform_ids[parallel-*].
    • Clean v8 only: test_workers_by_work_size.py::test_extract_honours_max_workers_argument.
    • This branch only: test_language_override_lifecycle.py::test_watch_declared_code_updates_graph_on_observer_thread.
    • Serially on this branch: pytest tests/test_language_override_lifecycle.py tests/test_terraform_modules.py gives 69 passed; tests/test_install.py tests/test_terraform_modules.py tests/test_workers_by_work_size.py gave 209 passed on both trees.
  • Pyright: the clean-tree count includes the copied-in Java test importing a module that does not exist there; the rest is pre-existing.

Graphify-specific checklist

  • I updated generated skill artifacts (uv run python -m tools.skillgen --bless) when changing their source fragments. (No skill fragments changed; --check passes.)
  • I confirmed that AST/structural extraction remains deterministic (no ambient state dependencies like ENV variables).
  • I reviewed changes for security implications (no unsafe interpolation into shell/Python).
  • I confirmed no API keys or local-only graph data are included.
  • I disclosed AI authorship in my commit messages.

@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @livingforelvis. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic.

@livingforelvis
livingforelvis marked this pull request as ready for review November 18, 2026 19:13
@Deepjyoti-Sarmah

Copy link
Copy Markdown
Contributor

I ran a small test set against this branch (27e6b42). One case gives a wrong edge: an interface method named like the implementing class gets linked to that class's constructor.

// F.java
public interface F { void Widget(); }

// Widget.java
public class Widget implements F { public Widget() {} }

On this branch the graph gets F.Widget() --dispatches_to--> Widget.Widget() at INFERRED 0.85, and the target is the constructor.

Here's why. resolve_interface_dispatch skips constructors only by metadata.kind == "constructor". The C# extractor sets that tag, but the Java extractor leaves a constructor's metadata at None. So with the Java pass on, the constructor counts as a method named Widget.

The fix is two lines in graphify/extractors/engine.py, next to where Java method metadata is set:

                 elif config.ts_module == "tree_sitter_java" and t == "method_declaration":
                     method_metadata = {**java_sig_meta, "signature": java_sig}
+                elif config.ts_module == "tree_sitter_java" and t == "constructor_declaration":
+                    method_metadata = {"kind": "constructor"}

It changes cached Java nodes, so _AST_CACHE_SCHEMA needs a bump (48 to 49 on v8 340268a). Without the bump, a cached Java file keeps the untagged constructor and the wrong edge comes back. I hit exactly that while testing.

With the tag in place, the case gives no edge. All Java and dispatch tests on v8 still pass (239).

The test I used:

def test_constructor_named_like_interface_method_is_not_a_target(tmp_path):
    d, r = _extract(tmp_path, {
        "F.java": "public interface F { void Widget(); }",
        "Widget.java": "public class Widget implements F { public Widget() {} }"})
    assert d == []
    ctor = _id(r, ".Widget()", "Widget.java")
    assert next(n for n in r["nodes"] if n["id"] == ctor)["metadata"]["kind"] == "constructor"

The commit is 1040335e on my fork if you'd like to cherry-pick it. Otherwise feel free to fold it in however suits the PR.

A separate thing I noticed (not this PR): a Java constructor Widget() and a method void Widget() in the same class get one node id, so the method disappears. I'll file it on its own.

@graphify-labs graphify-labs 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.

Graphify code review View in Graphify

Review completed · e85852c51246

Warning

Merge confidence: 3/5 · Review before merging · 🟠 High impact
2 P2 bugs · 5 possible issues not confirmed
1 not re-checked

The change registers a Java resolver that links interface methods to implementing methods.

Full summary

The change registers a Java resolver that links interface methods to implementing methods. It also marks Java constructors so they are excluded from those links.

Bugs (2)

P2 · Disable arity-only fallback in resolve_java_interface_dispatch: an abstract implementer can leave an interface method unimplemented, but the matcher may link it to a different-signature overload. Inspect source

Detailed review · checked against the code

Java overloads with matching parameter counts can get false dispatch edges

An abstract Java class can be linked to an overload that does not implement the interface method.

Expected: No dispatch edge connects overloads with different signatures.
Actually: After exact matches are taken, the matcher can pair remaining overloads by arity alone, producing a false dispatch edge.

For Java, the resolver enables match_arity=True. In the shared matcher, multi-method overload sets are matched by signature first, then unmatched interface methods fall back to arity. Thus send(String) can pair with send(String), after which an unmatched send(Integer) can pair by arity with the remaining send(Long). That creates a dispatch edge between methods with different signatures. The Java resolver is registered in the extraction pipeline, and an abstract implementer may legally leave an interface method unimplemented.

  • Independent source review: The tests cover matching same-arity signatures and an unmatched interface overload when the implementer has only one method, but do not cover distinct same-arity overloads on both sides. The matching implementation confirms the false edge can occur in that multi-overload case.

  • Some lookups asked for files or lines that do not exist; the review was told and carried on.

P2 · Restrict _overload_pairs to matching parameter signatures for Java dispatch: its arity fallback can link interface overloads to implementation methods with different parameter types. Inspect source

Detailed review · checked against the code

Java overloads can dispatch to methods with the wrong parameter types

When both sides have multiple same-name overloads, Java interface methods can be linked to implementation methods with different parameter types.

Expected: Dispatch edges should only pair overloads that implement the interface method’s parameter signature.
Actually: The matcher falls back from signature matching to arity and can infer an edge to the mismatched overload.

For overloaded methods, _overload_pairs first tries signatures and then falls back to arity. With multiple overloads on each side, a declared method can therefore pair with the sole unused candidate of its arity even when their parameter types differ. For example, interface overloads send(String) and send(int, int) and implementer overloads send(Integer) and send(long, long) produce unique arity matches but no signature matches. The Java wrapper passes match_arity=True, but that flag only checks the one-method-on-each-side case; Java dispatch can consequently include these mismatched pairs. Java’s resolver is registered in extraction, so this path is reachable for Java interface-dispatch graphs.

  • Independent source review: The tests cover matching overload signatures, an interface overload with multiple nonmatching candidates (which yields no edge), and a one-method-per-side same-arity mismatch (which is intentionally linked). They do not cover multiple overloads on each side with unique arity matches but mismatched signatures. The candidate’s wording that all overloads must share one arity is narrower than necessary: distinct arities can each have a unique mismatching candidate.

  • The false pairing requires multiple overloads of the same name and arity on both sides; other overload shapes may be rejected or matched by signature.

Not confirmed (5 possible issues)

Leads worth a look; we didn't double-check these. They don't change the score.

Not confirmed · Same-arity overload test expects an interface send(String) to link to an unrelated send(int) overload Inspect source

Detailed review · not confirmed

The test at line 222 asserts that the interface's send(String) is dispatched to MailSender.send(int). Those are different parameter types, so a real call would run the inherited Base.send(String) instead. The test locks in a wrong edge.

Lines 199 and 214 define Base.send(String), which MailSender inherits. Line 217 declares send(int) on MailSender, which is an overload with a different parameter type and does not override the String method. The comment at lines 210-211 calls the match a known limit of erased signatures, which would make it a missed precision case. But line 222 asserts a concrete edge to the wrong method, not a missing one. The sibling test at lines 194-206 correctly refuses to link a non-matching overload, which shows the intended rule is to match the signature and not only the arity. The expected value here contradicts that rule.

  • Only the one-method-per-side case with a single inherited method is shown; the resolver code that compares erased signatures is not in this file.

  • Found by the per-file sweep; not double-checked.

Not confirmed · With match_arity on, two methods that record no parameter count are paired, although the docstring requires both to record the same count Inspect source

Detailed review · not confirmed

When match_arity is set, a lone interface method is paired with a lone implementer method even when neither records a parameter count. The docstring says the pair needs both to record the same count, so an unknown count should block the pair.

At lines 247-251, _overload_pairs takes the lone-pair branch and runs if match_arity and _meta(source).get("arity") != _meta(target).get("arity"): return []. _meta returns {} when there is no metadata, so .get("arity") returns None for both nodes and the comparison passes. The docstrings at lines 107-109 say match_arity makes the pair happen "only when both record the same parameter count", and lines 240-241 say "the one-of-each pair also needs the same recorded parameter count". Neither condition holds when neither side records a count. The overload branch at lines 253-262 avoids this because it only matches on keys that are not None (want is None is skipped at line 258).

  • Whether the Java extractor records an arity value in method metadata is not visible in this file.

  • Whether the Java wrapper passes match_arity=True is not visible in this diff, so the effect on real Java output is unconfirmed.

  • The case where only one side records an arity is handled by the != comparison and was not traced further.

Not confirmed · The Java no-dispatch test calls only the C# resolver, so it cannot fail if Java dispatch is wrong Inspect source

Detailed review · not confirmed

test_java_interface_and_implementation_are_untouched now calls only resolve_csharp_interface_dispatch on Java nodes and checks that no dispatches_to edge appears. The C# resolver skips non-.cs files, so this assertion passes whatever the Java pass does. The earlier end-to-end check through _extract was removed, so nothing in this file checks the Java pipeline for a Java-only corpus.

Lines 196-212 build Java-labelled nodes and edges, then call resolve_csharp_interface_dispatch([], nodes, edges). The removed version went through _extract with Java files, so it exercised the full extraction path. The new version exercises only the C# resolver, which returns early for .java source files, so the assertion on line 212 is always true. The mixed-corpus test at line 316 covers Java linking only when a C# pair is also present, so a Java-only regression has no assertion at all.

  • Whether a Java-only _extract test exists elsewhere in the repository was not inspected

  • Only this file's diff was available, so the Java pass implementation was not read

  • Found by the per-file sweep; not double-checked.

Not confirmed · The PR title says it dispatches interface calls to implementers, but the changed lines only tag Java constructors with a kind marker Inspect source

Detailed review · not confirmed

The changed lines at 9976-9977 add a {"kind": "constructor"} metadata branch for Java constructor declarations. The PR title describes interface method dispatch, and the description is empty, so nothing in the code shown connects this change to that goal.

Before this change, Java constructor nodes received method_metadata = ruby_method_metadata, which is None for Java. Lines 9976-9977 now replace that with {"kind": "constructor"}. No line in the changed hunk touches interface resolution, implementer lookup, or call edges, and the PR description is blank. So the code and the stated intent do not match.

  • The rest of the PR diff, its commit history, and any tests were not provided, so the dispatch logic may live in other files.

  • The consumers of the node metadata key kind were not in the excerpt, so their handling of the new value is unknown.

  • Found by the per-file sweep; not double-checked.

Not confirmed · Java constructor nodes gain a generic kind metadata key that differs from the namespaced Ruby key and may collide with other readers Inspect source

Detailed review · not confirmed

Constructor nodes now store kind as a top-level metadata key. The neighbouring Ruby logic uses the namespaced ruby_method_kind key, and Java methods store signature metadata under other keys. A reader that looks for a kind key expecting another meaning could misclassify these nodes.

Line 9977 assigns method_metadata = {"kind": "constructor"}. Ruby metadata at line 9963 uses ruby_method_kind, and the sanitize_metadata call at line 9970 is applied only to existing Ruby nodes. The shape of the Java constructor metadata therefore differs from the other method metadata in this function, and this change adds no namespacing for it.

  • The metadata consumers and the sanitize_metadata implementation were not visible, so whether a collision happens is unconfirmed.

  • The function that computes func_nid for Java constructor_declaration nodes was not in the excerpt, so the node identity of constructors could not be checked.

  • Found by the per-file sweep; not double-checked.

What this review covered
  • Some lookups asked for files or lines that do not exist; the review was told and carried on.
  • 10 of 10 changed files inspected. This is scope, not a correctness guarantee.
Code graph and static checks · 6038 functions depend on this change

Impact & health

Impact — 6038 functions depend on the 1079 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: extract() — 1305 callers, 78 callees
  • worse: resolve_interface_dispatch() — 8 callers, 4 callees

Formal checks — 6038 functions this change can affect weren't formally checked in this review. Formal checks are informational only.

Gate & verification

✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 5331 function(s) in the blast radius were not formally verified this run

Test selection

602 of 602 test file(s) selected (100%) via static blast radius.

Escalated to a full run for safety (uncovered-code) — the selection is not trustworthy on its own (see below). CI should run the whole suite.

  • tests/pi.test.ts — full-run-safety
  • tests/test_4874_jvm_resolution.py — impact, full-run-safety
  • tests/test_4909_reference_binding_scale.py — full-run-safety
  • tests/test_4978_reconcile_cost.py — impact, full-run-safety
  • tests/test_4992_ts_import_types.py — impact, full-run-safety
  • tests/test_5072_splittable_under_cap_retry.py — full-run-safety
  • tests/test_affected_cli.py — full-run-safety
  • tests/test_affected_defines.py — full-run-safety
  • tests/test_affected_member_seed.py — full-run-safety
  • tests/test_affected_overrides.py — impact, full-run-safety
  • tests/test_affected_path_file_node.py — full-run-safety
  • tests/test_affected_seed_reference_forms.py — full-run-safety
  • tests/test_agents_platform.py — full-run-safety
  • tests/test_alias_folding.py — impact, full-run-safety
  • tests/test_analyze.py — impact, full-run-safety
  • tests/test_anthropic_custom_endpoint.py — full-run-safety
  • tests/test_antigravity_install.py — full-run-safety
  • tests/test_apm_fallback_version.py — full-run-safety
  • tests/test_architecture_doc.py — full-run-safety
  • tests/test_astro_extraction.py — impact, full-run-safety
  • tests/test_astro_import_ids.py — impact, full-run-safety
  • tests/test_atomic_canvas_export.py — full-run-safety
  • tests/test_atomic_version_stamp.py — full-run-safety
  • tests/test_atomic_writes.py — full-run-safety
  • tests/test_backend_env_isolation.py — full-run-safety
  • tests/test_backend_extras.py — full-run-safety
  • tests/test_backend_opt_in.py — full-run-safety
  • tests/test_benchmark.py — full-run-safety
  • tests/test_benchmark_raw_graph.py — full-run-safety
  • tests/test_benchmark_real_query.py — full-run-safety
  • tests/test_binary_media_words.py — impact, full-run-safety
  • tests/test_blade_extractor.py — impact, full-run-safety
  • tests/test_build.py — impact, full-run-safety
  • tests/test_build_located_semantic_identity.py — impact, full-run-safety
  • tests/test_build_merge_dedup_scope.py — impact, full-run-safety
  • tests/test_build_merge_ghost_fold_4955.py — impact, full-run-safety
  • tests/test_build_merge_hyperedges_and_prune.py — impact, full-run-safety
  • tests/test_build_merge_shrink_guard.py — impact, full-run-safety
  • tests/test_builtin_global_type_refs.py — impact, full-run-safety
  • tests/test_c_include_resolution.py — impact, full-run-safety
  • tests/test_cache.py — impact, full-run-safety
  • tests/test_cache_long_paths.py — impact, full-run-safety
  • tests/test_cache_stale_import_target.py — impact, full-run-safety
  • tests/test_cache_windows_case_4925.py — impact, full-run-safety
  • tests/test_callflow_html.py — full-run-safety
  • tests/test_cargo_introspect.py — full-run-safety
  • tests/test_cargo_missing_manifest.py — full-run-safety
  • tests/test_carried_hyperedge_remap.py — impact, full-run-safety
  • tests/test_case_only_decl_ids_4904.py — impact, full-run-safety
  • tests/test_case_sensitive_resolution.py — impact, full-run-safety
  • … and 552 more

⚠️ changed code file(s) with no mapped test (tests/fixtures/java_interface_dispatch/EmailWorker.java, tests/fixtures/java_interface_dispatch/Job.java, tests/fixtures/java_interface_dispatch/Worker.java) — a coverage gap or a missing link — running the full suite rather than only the selected tests

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

Every flagged function

  • extract() in graphify/extract.py:11751 · 1305 callers, 78 callees: fans out to 78 callees (efferent coupling); 1305 callers depend on it (afferent coupling)
  • resolve_interface_dispatch() in graphify/interface_dispatch.py:94 · 8 callers, 4 callees: 8 callers depend on it (afferent coupling)

@livingforelvis

Copy link
Copy Markdown
Contributor Author

Thanks @Deepjyoti-Sarmah, good catch, and confirmed: on 27e6b42 the case gave F.Widget() --dispatches_to--> Widget.Widget().

  • Cherry-picked your 1040335 as is (authorship kept): Java constructors carry kind: "constructor", _AST_CACHE_SCHEMA 48 -> 49.
  • Added test_a_constructor_named_like_the_interface_method_is_not_a_target on top. It fails on 27e6b42 without the tag and passes with it, and checks the constructor node's kind.
  • PR description updated: one extractor change and a schema bump now, instead of none.

+1 on filing the constructor / same-named method id collision separately; it's outside this PR.

livingforelvis and others added 4 commits November 20, 2026 11:30
…aphify-Labs#5319)

A call through an interface-typed field (`this.worker.run()` where
`worker` is a `Worker`) lands on the interface's method node, and nothing
joins it to `EmailWorker.run()`, so a directed walk stops at the
interface. C# (Graphify-Labs#3003), Swift (Graphify-Labs#4035) and Go (Graphify-Labs#4934) already close this
gap with `dispatches_to`; no pass was registered for `.java`.

The Java extractor already emits `implements` and the interface's
`method` edges, so graphify.java_dispatch is a thin `.java` gate over
resolve_interface_dispatch, registered after the Go pass. Same rules as
the other languages: additive INFERRED edges at 0.85 / 0.75 / 0.65 by
implementer count, both ends declared in `.java`. Each Java overload is
its own node, so the shared pairing links overloads by signature, then
arity. No extractor change, so no AST cache schema bump (as for Swift).

Known limits, pinned by tests: `extends` (abstract classes) is not
read, interface hierarchies are not walked, an unoverridden `default`
method gets no edge, a lone same-named method pairs without a signature
check, and a fully qualified `implements a.Worker` with no import binds
to a sourceless stub and gets no edge (the imported form links).

Two C# tests asserted that a Java corpus gains no dispatch edge; they now
call the C# pass directly, and the mixed-corpus test expects each pair
within its own language.

Co-Authored-By: Claude <noreply@anthropic.com>
A Java constructor node carried no metadata, so nothing told it apart from
a method of the same name. The C# extractor already tags its constructors
this way, and the shared interface-dispatch resolver relies on it to skip
them. Bumps the AST cache schema to 49 so cached Java extractions re-run.

(cherry picked from commit 1040335)
…spatch target (Graphify-Labs#5319)

Pins the constructor tag from the previous commit: an interface method
named after the implementing class gets no dispatches_to edge, and the
Java constructor node carries kind "constructor".

Co-Authored-By: Claude <noreply@anthropic.com>
…od's arity (Graphify-Labs#5319)

With one interface method and one implementer method of a name, the
shared resolver paired them without comparing signatures, so
send(int, int) on a class that inherits send(String) from its base got
a dispatches_to edge. Java signatures are erased (a type variable becomes
its bound), so types cannot be compared without dropping generic pairs;
the parameter count survives erasure. resolve_interface_dispatch takes a
keyword-only match_arity, off by default so C# and Swift are unchanged,
and the Java pass turns it on.

Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

[Feature]: Java: a call through an interface-typed field stops at the interface method (no dispatches_to to implementers)

2 participants