RFR: 8326458: Menu mnemonics don't toggle in Windows LAF when F10 is pressed [v6]

Alexey Ivanov aivanov at openjdk.org
Tue Mar 5 12:19:46 UTC 2024


On Tue, 5 Mar 2024 12:13:05 GMT, Abhishek Kumar <abhiscxk at openjdk.org> wrote:

>> test/jdk/javax/swing/JMenuBar/TestMenuMnemonic.java line 58:
>> 
>>> 56:     public static void main(String[] args) throws Exception {
>>> 57:         UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
>>> 58:         final int EXPECTED = 5;
>> 
>> I meant making it `private static final` outside of main.
>> 
>> I suggest something like this:
>> 
>> 
>>     private static JFrame frame;
>>     private static JMenuBar menuBar;
>>     private static JMenu fileMenu;
>> 
>>     private static final AtomicInteger mnemonicHideCount = new AtomicInteger(0);
>>     private static final AtomicInteger mnemonicShowCount = new AtomicInteger(0);
>> 
>>     private static final int EXPECTED = 5;
>> 
>> 
>> The blank lines separate the blocks of related fields.
>
>>private static final int EXPECTED = 5;
> 
> this var is used only in main, so I kept it as local variable.

There's a difference between _a local variable_ that it is now and _a constant_ declared at the class level. In the latter case, the compiler may eliminate the constant and inline its value; in the former case, it can't do it.

I am still for making it a real constant declared at the class level as per my suggestion above.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17961#discussion_r1512723625


More information about the client-libs-dev mailing list