On Tue, 7 Jun 2022 11:06:06 GMT, Tejesh R <t...@openjdk.org> wrote:

>> test/jdk/javax/swing/JRadioButton/bug4380543.java line 72:
>> 
>>> 70:                     //Adding the Test Frame to handle dispose
>>> 71:                     passFailJFrame.addTestFrame(testObj);
>>> 72:                     passFailJFrame.positionTestFrame(testObj, 
>>> PassFailJFrame.Position.HORIZONTAL);
>> 
>> This was correct: you're calling static methods; such methods should not be 
>> called _via an instance variable_ but via the class name. Alternatively, you 
>> can static-import these methods.
>
> I think it wouldn't make any difference calling static methods via an 
> instance variable or directly with class name.

Yes, the same method would be called. Yet the difference is in the semantics: 
the instance variable isn't used when calling a static method, it can be null 
and it doesn't throw NullPointerException in this case.

The IDE raises a warning for such a usage. _You should use class name when 
calling static methods._ It's just cleaner: the reader would see right away 
it's a static method (without relying on the IDE syntax highlighting) rather 
than an instance method.

Please revert these two lines to using the class name to call the static 
methods.

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

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

Reply via email to