JDK 13 RFR of JDK-8146726 : Improve AbstractProcessor to issue warnings for repeated information
Joseph D. Darcy
joe.darcy at oracle.com
Wed May 1 23:54:04 UTC 2019
Hi Stuart,
I think the current patch is a sufficient enough improvement to be
pushed, reserving the ability for further improvements in the future :-)
Thanks,
-Joe
On 5/1/2019 2:01 PM, Stuart Marks wrote:
> Hi Joe,
>
> Thanks for the explanation of annotations and modules. I'll leave the
> exact circumstances of issuing warnings up to you. Since it's just
> about issuing warning messages, it's reasonable that it doesn't need
> to be precise.
>
> My concern is that the deduplication+warning code is hard to
> understand, and that someone in the future (maybe you!) will come
> across it and have a difficult time figuring it out; they might also
> worry about its precise behavior, not realizing that the warning
> policy isn't be precise.
>
> It seems to me like the core of the algorithm can be implemented as
> follows. Given a String[] array, the elements can be deduplicated into
> a set this way:
>
> List<String> dups = new ArrayList<>(Arrays.asList(array));
> Set<String> result = new HashSet<>();
> dups.removeIf(result::add);
>
> Now, 'result' contains the deduplicated items and 'dups' is a list
> (which might itself contain duplicates!) of duplicated items. The
> warning messages, if necessary, can then be generated from the 'dups'
> list after the fact.
>
> I'm not entirely sure of the best way to handle module prefix removal.
> If the index/substring logic were extracted into a message, the
> initialization of 'dups' could be replaced with a short stream that
> calls the module prefix removal function from map(). The exact
> behavior of the for-loop as it stands, though, would be difficult to
> implement this way. Then again, since the warning policy doesn't need
> to be precise, maybe this is ok.
>
> I'll leave it up to you whether you want to continue reworking this code.
>
> s'marks
>
More information about the compiler-dev
mailing list