RFR: 8300517: Refactor VisibleMemberTable (method members) [v2]

Pavel Rappo prappo at openjdk.org
Wed Mar 8 14:58:18 UTC 2023


On Tue, 7 Mar 2023 23:56:29 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> Pavel Rappo has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Respond to feedback
>
> src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java line 1031:
> 
>> 1029:         // TODO: this computation should be eventually delegated to VisibleMemberTable
>> 1030:         Set<TypeElement> alreadySeen = null;
>> 1031:         assert (alreadySeen = new HashSet<>()) != null; // create set conditionally
> 
> I think this use of `assert` (here and lower down) is a step too far.  It's one thing to use asserts to verify invariants; it's too much to use them to conditionally compute state like this.

That hash map is needed iff assertions are enabled. For an ordinary run, creating that hash map could be wasteful.

Perhaps I could create a hash map unconditionally using `HashMap.newHashMap(0)`; would that be to your liking?

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

PR: https://git.openjdk.org/jdk/pull/12887


More information about the javadoc-dev mailing list