RFR: 8276794: Change nested classes in java.desktop to static nested classes

Alexey Ivanov aivanov at openjdk.java.net
Wed Nov 17 14:54:37 UTC 2021


On Thu, 14 Oct 2021 07:47:33 GMT, Andrey Turbanov <duke at openjdk.java.net> wrote:

> Non-static classes hold a link to their parent classes, which in many cases can be avoided.
> I updated only private and package-private classes. Didn't touch public/protected to not break external code.
> Similar cleanup in java.base - [JDK-8261880](https://bugs.openjdk.java.net/browse/JDK-8261880)

There are a couple of classes where a space before the opening brace in the class declaration can be added: you're changing the declaration anyway. By adding the space there, the declaration will follow Java Code Conventions.

In some cases, you're remove unused imports. Does it make sense to convert all wildcard imports into explicit imports? I noticed wildcards imports have been replaced with explicit ones in JDK source code recently.

I do not suggest changing the imports in all the modified classes, only those where imports are modified.

For example, you're removing redundant imports in `XTextFieldPeer.java`, there are quite a few of them. There are also lots of explicit imports in the file. I think expanding wildcard imports to explicit ones and sorting them will make the file cleaner.

Another example where such a change seems appropriate is `XTextAreaPeer.java` where Swing classes are imported class by class but `java.awt.*` by wildcard.

What do you think?

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java line 3949:

> 3947:     @SuppressWarnings("serial") // Superclass is not serializable across versions
> 3948:     private static class ScrollableTabButton extends BasicArrowButton implements UIResource,
> 3949:                                                                             SwingConstants {

Maybe, wrap the line before implements?

src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java line 2300:

> 2298: 
> 2299: @SuppressWarnings("serial") // JDK-implementation class
> 2300:  static class PrintToFileErrorDialog extends Dialog implements ActionListener{

There's an extra space before `static` modifier which breaks the common indentation.
I'd also add a space before the opening brace, it's there in the following code of the class.

src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java line 165:

> 163:      */
> 164:     @SuppressWarnings("serial") // JDK-implementation class
> 165:      static class ScrollEvent extends PeerEvent {

There's an extra space before `static` modifier. Is it intentional?

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

Marked as reviewed by aivanov (Reviewer).

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



More information about the client-libs-dev mailing list