Repository navigation
Conversation
ClassInfo defines no equals/hashCode, so the HashSet<ClassInfo> accumulators in Index and CompositeIndex deduplicated by identity. In an overlapping CompositeIndex this let the same fully-qualified class name appear once per index in the known-subclasses/-subinterfaces/-implementors results, inconsistent with getKnownUsers/getClassesInPackage which already deduplicate by name. Replace those internal accumulators with name-keyed Map<DotName, ClassInfo> (LinkedHashMap, first-writer-wins to match getClassByName). Public return types are unchanged; results are now deduplicated by class name and returned as unmodifiable collections. testOverlappingCompositeIndex is updated to expect deduplicated results and a focused regression test is added to CompositeTestCase. Signed-off-by: Tiziano Basile <[email protected]>
Member
|
Handling of duplicate classes is not documented at all in |
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.
Fixes #174.
Problem
ClassInfodefines noequals/hashCode, so theHashSet<ClassInfo>accumulators inIndexandCompositeIndexdeduplicate by object identity. In an overlappingCompositeIndex(the same class indexed in more than one member index) this let the same fully-qualified class name appear once per index in the results of:getKnownDirectSubclasses/getAllKnownSubclassesgetKnownDirectSubinterfaces/getAllKnownSubinterfacesgetKnownDirectImplementationsgetKnownDirectImplementors/getAllKnownImplementorsThis was inconsistent with
getKnownUsers,getClassesInPackage, andgetAllKnownSubinterfaces' worklist, which already deduplicate byclazz.name().Change
Replaced the internal
Set<ClassInfo>accumulators/parameters/locals inIndexandCompositeIndexwith name-keyedMap<DotName, ClassInfo>(LinkedHashMapfor deterministic order;putIfAbsent/containsKey= first-writer-wins, matchinggetClassByName, which returns the first index's match). The traversal/visited-tracking logic (processedClasses, worklists) is unchanged.Set<ClassInfo>still return aSet(materialized from the deduplicated map values at the boundary);Collection<ClassInfo>returners still return aCollection. NoIndexViewsignature, noequals/hashCodeonClassInfo, no on-disk index-format change.Indexeris untouched.Behavior changes (please review)
CompositeIndex. This is the substance of Get rid of Set<ClassInfo> usages #174. Since @Ladicek noted he wasn't fully convinced the identity semantics were safe to drop, I've kept this deliberate and easy to review:IndexNavigationTest.testOverlappingCompositeIndexpreviously asserted the duplicate-preserving behavior and is updated here to assert the deduplicated results. Happy to adjust the direction based on your preference.getAll*methods that previously returned a mutable set now return an unmodifiable collection, consistent with the siblinggetKnownDirect*methods that already did.Tests
CompositeTestCase.testCompositeDeduplicatesByClassName: two indexes each contributing a distinctClassInfoinstance for the same FQCN; asserts the composite returns exactly one entry per name across the affected accessors.IndexNavigationTest.testOverlappingCompositeIndexto expect deduplicated-by-name results.corebuild is green (302 tests) on JDK 21, formatter + impsort clean.