fix(java): make Type.Methods Identity.Name and Graph relations deterministic#191
Merged
Conversation
…inistic Two sources of non-determinism in Java IPC parsing surfaced as method-name flapping in `Type.Methods[k].Name` and reordered `Graph.*.References` between runs: 1. exportSymbol stored the new *Identity in `visited` with the bare method name and only updated `id.Name` to the prefixed form (`Receiver.method` or `Receiver::method`) after recursing into the receiver. The receiver's SKStruct branch iterates its `receivers[R]` map and value-copies `*mid` into `Type.Methods[k]`; if that recursion landed on the very method that started the chain, it captured the still-bare name. Which method flapped per Type depended on Go map iteration order. Fix: pre-compute the prefixed Identity.Name for SKMethod/SKFunction in non-Cpp languages before inserting into `visited`, so cyclic visits read the final name. 2. BuildGraph fills `Node.References/Dependencies/Implements/Inherits/ Groups` while iterating `pkg.Functions/Types/Vars` maps, so insertion order varied. Sort those slices by (Identity.Full(), Line, Kind) at the end of BuildGraph to make JSON byte-stable. Adds TestRepository_BuildGraph_Deterministic which marshals the localsession fixture 5x and asserts byte-equality. End-to-end: running `abcoder parse java testdata/java/4_full_maven_repo` 8x now produces byte-identical output; previously every run differed.
Duslia
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
fix
Check the PR title.
(Optional) Translate the PR title into Chinese.
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
Two sources of non-determinism in Java IPC parsing surfaced as method-name flapping in
Type.Methods[k].Nameand reorderedGraph.*.Referencesbetween runs:exportSymbol stored the new *Identity in
visitedwith the bare method name and only updatedid.Nameto the prefixed form (Receiver.methodorReceiver::method) after recursing into the receiver. The receiver's SKStruct branch iterates itsreceivers[R]map and value-copies*midintoType.Methods[k]; if that recursion landed on the very method that started the chain, it captured the still-bare name. Which method flapped per Type depended on Go map iteration order. Fix: pre-compute the prefixed Identity.Name for SKMethod/SKFunction in non-Cpp languages before inserting intovisited, so cyclic visits read the final name.BuildGraph fills
Node.References/Dependencies/Implements/Inherits/ Groupswhile iteratingpkg.Functions/Types/Varsmaps, so insertion order varied. Sort those slices by (Identity.Full(), Line, Kind) at the end of BuildGraph to make JSON byte-stable.zh(optional):
(Optional) Which issue(s) this PR fixes:
(optional) The PR that updates user documentation: