RFR: 8286663: Resolve IDE warnings in WTrayIconPeer and SystemTray [v3]

Sergey Bylokhov serb at openjdk.java.net
Wed Jun 1 23:17:35 UTC 2022


On Tue, 24 May 2022 11:16:16 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> It also has a functional implication, in the old code  the "size" on a Vector is called outside of the lock. So the resulted array after "icons.toArray" can be bigger than the number of icons. This is similar to this:
>> https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/java.desktop/share/classes/javax/sound/midi/Sequence.java#L281
>> I think that race can even be triggered by the new test.
>
> I remember IDEs used to suggest using correctly sized arrays in the calls to `toArray`. Now they suggest using zero-sized array.
> 
> My idea was to resolve the warning raised by the IDE to reduce the number of yellow highlights on the file outline.
> 
> I agree the performance gain if any is negligible in this case: we don't expect many icons, probably no more than 3.

The IDE warning was changed based on the article above. Did you have a chance to reproduce a possible race caused by data change after the size() was called?

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

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



More information about the client-libs-dev mailing list