RFR: 8304947: Unnecessary Vector usage in java.awt.MenuBar.shortcuts

Sergey Bylokhov serb at openjdk.org
Tue Mar 28 19:53:39 UTC 2023


On Wed, 22 Mar 2023 19:12:34 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

> Method `'java.awt.MenuBar#shortcuts` creates a 'Vector<MenuShortcut>', fills it and then returns its 'Enumeration elements()' as return value.
> Instead of usage of legacy synchronized Vector here we can use ArrayList instead. Wrap it in Collections.enumeration to adapt to 'Enumeration' result type.

looks fine then

src/java.desktop/share/classes/java/awt/MenuBar.java line 350:

> 348:             }
> 349:         }
> 350:         return shortcuts.elements();

Can you please confirm the old and new enumerations have the same behavior during iteration/adding/removing/etc elements?

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

PR Comment: https://git.openjdk.org/jdk/pull/13149#issuecomment-1483351227
PR Review Comment: https://git.openjdk.org/jdk/pull/13149#discussion_r1146902747



More information about the client-libs-dev mailing list