Repository navigation
fix(java): keep _name/name and case-only member twins apart in node ids - #5152
rohit-jsfreaky wants to merge 1 commit into
Conversation
…de ids make_id strips a leading `_` and folds case, so in one Java class body `_testFoo()` / `testFoo()`, `getId()` / `getID()` and a constructor `HashCode()` / method `hashCode()` minted ONE id. add_node kept the first declaration and dropped the second: the method vanished, the calls it makes were credited to its twin, and calls to it landed on the twin (or, when the survivor's name no longer matched, fell back to a supertype's method or to another file's method). Apply the Python/C#/Solidity rule (Graphify-Labs#3302, Graphify-Labs#4415, Graphify-Labs#5058): group the methods and constructors of each class/interface/record/enum body by the id they would get and run each through `_underscore_salted_nid`. The one public name keeps the plain id, every other spelling is salted. Members that collide with nothing keep their ids; overloads share one name, so they are not a collision. Measured on jsoup, commons-lang, jackson-core, jackson-databind and guava: 160 colliding groups (131 of them `_x`/`x`), 160 methods that had no node on v8 now do, and 612 call edges that v8 credited to a differently-named method now hit the right one. No id changed outside a colliding group, and no edge away from those groups changed. Bump _AST_CACHE_SCHEMA to 44 so cached Java extractions re-run. Co-Authored-By: Claude <[email protected]>
|
Thanks for the pull request, @rohit-jsfreaky. 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.10 and 3.13, and that the change keeps extraction deterministic. |
|
Note: my open #5052 also bumps |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).
Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 unsupported).
Not verified on this run: \_extract\_generic (unsupported).
Graphify review — findings
Bumps _AST_CACHE_SCHEMA to 43 so cached Python and C++ extractions re-run. The new extraction behaviour: a dotted Python subscript annotation (mod.MyBox[Foo]) walks its value once as the type, so the false generic_arg reference no longer displaces the real parameter_type/return_type edge. C++ gains forward-declaration folding into a unique exactly-qualified definition and member-declaration folding into its out-of-line definition. Member receivers now resolve through scoped type aliases and inherited fields/methods, and calls in #if-guarded initializers are recovered. Ambiguous, virtual, diamond and dependent cases stay unresolved. The diff is truncated, so the engine-side changes behind the other listed symbols aren't visible here.
No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 4530 functions depend on the 534 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 1207 callers, 78 callees - worse:
walk()— 1 callers, 90 callees
Verification — 4530 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 2958 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
98 of 555 test file(s) selected (18%) via static blast radius.
tests/test_4992_ts_import_types.py— impacttests/test_astro_extraction.py— impacttests/test_binary_media_words.py— impacttests/test_build.py— impacttests/test_cache.py— impacttests/test_cache_long_paths.py— impacttests/test_cache_stale_import_target.py— impacttests/test_cache_windows_case_4925.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_cjs_module_extension.py— impacttests/test_code_only_scope_4923.py— impacttests/test_cpp_alias_member_resolution.py— impacttests/test_cpp_conditional_initializers.py— impacttests/test_cpp_inherited_member_resolution.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_cpp_template_members.py— impacttests/test_csharp_extension_calls.py— impacttests/test_csharp_extension_metadata.py— impacttests/test_csharp_extension_resolution.py— impacttests/test_csharp_partial_classes.py— impacttests/test_definition_file_portability.py— impacttests/test_detect.py— impacttests/test_dotnet.py— impacttests/test_ejs_extractor.py— impacttests/test_ext_tagged_id_clash.py— impacttests/test_extract.py— impacttests/test_extract_cache_location.py— impacttests/test_extract_cli.py— impacttests/test_extract_php_closures.py— impacttests/test_grammar_cache_key.py— impacttests/test_hook_content_freshness.py— impacttests/test_ignore_file_encoding.py— impacttests/test_import_extension_resolution.py— impacttests/test_incremental_mtime_collision.py— impacttests/test_indirect_call_block_scoped_shadow.py— impacttests/test_indirect_dispatch.py— impacttests/test_indirect_dispatch_assign_return.py— impacttests/test_indirect_dispatch_getattr.py— impacttests/test_java_member_calls.py— impacttests/test_java_underscore_ids.py— impact, changed-testtests/test_js_exported_scalar_bindings.py— impacttests/test_js_member_collisions.py— impacttests/test_language_override_lifecycle.py— impacttests/test_language_overrides.py— impacttests/test_languages.py— impacttests/test_linked_worktree_reconcile.py— impacttests/test_llm_backends.py— impacttests/test_manifest_ingest.py— impacttests/test_msbuild_dir_evidence.py— impact- … and 48 more
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.
Docs that may be stale (advisory)
ARCHITECTURE.md§ Testing (lines 268-345): references changed symbolsFooCHANGELOG.md§ 0.9.106 (2026-11-10) (lines 5-23): references changed symbolsFooCHANGELOG.md§ 0.9.105 (2026-11-09) (lines 24-50): references changed symbolsFooCHANGELOG.md§ 0.9.103 (2026-11-05) (lines 79-100): references changed symbolsFooCHANGELOG.md§ 0.9.101 (2026-11-02) (lines 132-155): references changed symbolsFooCHANGELOG.md§ 0.9.100 (2026-11-01) (lines 156-179): references changed symbolsFooCHANGELOG.md§ 0.9.94 (2026-10-22) (lines 295-316): references changed symbolsFooCHANGELOG.md§ 0.9.86 (2026-10-11) (lines 464-485): references changed symbolsFooCHANGELOG.md§ 0.9.78 (2026-10-06) (lines 587-602): references changed symbolsFooCHANGELOG.md§ 0.9.66 (2026-09-22) (lines 765-779): references changed symbolsFoo
…and 10 more.
Formal verification
Could not verify: Could not verify \_extract\_generic.
The verifier did not have enough to check \_extract\_generic, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: parameter `config` is annotated `LanguageConfig` — outside the synthesizable primitive/collection set
· 2 more finding(s) on lines outside this diff (see the check run).
|
Landed on v8 as bd720f1 via authorship-preserving cherry-pick, released in graphify 0.9.107. Thanks @rohit-jsfreaky. |
Closes #5151
What does this PR do?
Java methods and constructors whose names differ only by a leading
_or by case in one class, interface, record or enum body now get separate node ids, the same way as Python and C# (#3302, #4415) and Solidity (#5058).A small helper
_java_member_nidgroups the members of one body by the id they would get, then runs each group through the existing_underscore_salted_nid: the one public name keeps its id and the others get a salted id. Nothing outside a colliding group changes._AST_CACHE_SCHEMA43 -> 44 (Java output changes).Diff:
engine.py+44,cache.py+1/-1, 4 tests.Numbers
The answer key is a separate tree-sitter-java scan that counts declarations per class.
_(HashCode()/hashCode(),getId/getID), so both names are salted, as in Python and C#.WriterBasedJsonGenerator._writeString(name)went to a method in a test class on v8. It now goes to the right method in the same class.prop.depositSchemaProperty()calls fell back to the abstractPropertyWriter. They now bindBeanPropertyWriter's own override.new Range<>(...)calls now target the constructor node, as v8 already does for a class with no collision..withClassPathLocations(...).withFilePrefixes(...)) now resolve through the builder's return type.Limitations
EXECUTOR/executor(): 4 in guava, 2 in spring) are not covered, to keep this small.foo(int)/foo(String)) still share one node. That's an older, separate limitation.Type of change
Verification & Invariants
Invariant: every Java method and constructor declaration gets its own node, and a call is credited to the member it is written in. Ids outside a colliding group are unchanged. Persisted state: the AST cache is bumped, so cached Java extractions re-run.
How was this tested?
Tests cover
_bar/bar, case-only twins, enum and interface bodies, and cross-file member calls (obj._bar()vsobj.bar()).Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.