<Swing Dev> RFR: 8252722: More Swing plaf APIs that rely on default constructors [v2]

Phil Race prr at openjdk.java.net
Thu Sep 24 04:53:08 UTC 2020


On Tue, 22 Sep 2020 14:01:04 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> Please review a fix for issue where it was seen that several classes in plaf package rely on default constructors as
>> part of their public API.
>> It's to be noted that "A no-arg public constructor is generated by the compiler for a class if it does not declare an
>> explicit constructor. While convenient, this is inappropriate for many kinds of formal classes, both because the
>> constructor will have no javadoc and because the constructor may be unintended."
>> 
>> For the JDK, classes intended to be used outside of the JDK, public classes in exported packages, should not rely on
>> default constructors.
>> 
>> Proposed fix is to add explicit public no-arg constructors for public classes and protected no-arg constructor for
>> protected classes for javax.swing module
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Modified construct javadic pattern

Marked as reviewed by prr (Reviewer).

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java line 737:

> 735:     protected class InvocationMouseHandler extends MouseAdapter {
> 736:         /**
> 737:          * Constructor for subclasses to call.

IMO this wording is not right here. This class is concrete isn't it ? So any code in this package can create one - not
just a subclass.

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java line 651:

> 649:         /**
> 650:          * Constructs a {@code InternalFramePropertyChangeListener}.
> 651:          */

a -> an

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java line 673:

> 671:      * Constructs a {@code InternalFrameLayout}.
> 672:      */
> 673:     public InternalFrameLayout() {}

a -> an

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

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


More information about the swing-dev mailing list