RFR: 8282483: Ensure that Utils.getAllInterfaces returns unique instances [v4]

Pavel Rappo prappo at openjdk.java.net
Thu Mar 3 13:22:41 UTC 2022


> Instances of TypeMirror that are equal (TypeMirror::equals), aren't necessarily the same (Types::isSameType). If care is not taken when putting instances of TypeMirror into a set, that set might end up containing the same instances.
> 
> If Utils.getAllInterfaces is called on a type that extends or implements a particular interface multiple times (on different levels of that type's hierarchy), the returned set might contain multiple representations of that interface. For example, I've seen a case where getAllInterfaces that was passed a TypeElement corresponding to java.util.ArrayList returned a set containing 3 instances of TypeMirror corresponding to `java.util.Collection<E>`.
> 
> A bit of archaeology. The old standard doclet (removed in JDK-8177511, commit 33ab1995) collected instances of com.sun.javadoc.Type in a TreeMap, keying them by instances of com.sun.tools.javadoc.main.ClassDocImpl (removed in JDK-8215584, commit 151e628) which implemented Comparable. ClassDocImpl.compareTo worked by comparing instances of CollationKey derived from FQNs of types represented by respective instances of ClassDocImpl.
> 
> I'm not sure why `TreeMap<ClassDocImpl, Type>` was changed to `LinkedHashSet<TypeMirror>`.

Pavel Rappo has updated the pull request incrementally with one additional commit since the last revision:

  Revert inadvertently expanded imports

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/7659/files
  - new: https://git.openjdk.java.net/jdk/pull/7659/files/00259e26..208d8ed1

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=7659&range=03
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=7659&range=02-03

  Stats: 52 lines in 1 file changed: 0 ins; 48 del; 4 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7659.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7659/head:pull/7659

PR: https://git.openjdk.java.net/jdk/pull/7659


More information about the javadoc-dev mailing list