<Swing Dev> RFR JDK-8250811: Address reliance on default constructors in the javax.swing.plaf.multi APIs

Philip Race philip.race at oracle.com
Tue Aug 4 21:05:33 UTC 2020


Section 6.4 of the 23 year old coding guidelines
https://www.oracle.com/technetwork/java/codeconventions-150003.pdf
appear to suggest {} for empty methods.

However I know this only because I went to look.
I would have guessed the opposite .. and prefer that opposite.

-phil.

On 8/3/20, 11:44 PM, Prasanta Sadhukhan wrote:
>
> On 04-Aug-20 12:01 PM, Sergey Bylokhov wrote:
>> Hi, Prasanta.
>>
>> I think a good place for a constructor is after the declaration of
>> the fields and before the methods.
>>
>> BTW I am not sure about the "one line" "{}" type of brackets, do we 
>> use it somewhere?
>> For example in some classes like a java.awt.Canvas uses brackets on 
>> different lines.
>>
> Let me know if I need to use like that. I used as was used for other 
> fix for these kind of issues as in
>
> https://hg.openjdk.java.net/jdk/jdk/rev/f7c85b7e231b
>
> https://hg.openjdk.java.net/jdk/jdk/rev/2a617462275c
>
> etc
>
> Regards
>
> Prasanta
>
>> On 31.07.2020 07:20, Prasanta Sadhukhan wrote:
>>> Hi All,
>>>
>>> Please review a fix for issue where it was seen that several classes 
>>> 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 create no-arg default constructor for 
>>> javax.swing.plaf.multi module (as one part of overalll java.desktop 
>>> change)
>>>
>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8250811
>>>
>>> webrev: http://cr.openjdk.java.net/~psadhukhan/8250811/webrev.0/
>>>
>>> CSR: https://bugs.openjdk.java.net/browse/JDK-8250812
>>>
>>> Regards
>>> Prasanta
>>>
>>
>>


More information about the swing-dev mailing list