JDK 16 RFR of JDK-8071961: Add javac lint warning when a default constructor is created

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Aug 12 17:01:43 UTC 2020


On 31/07/2020 17:23, Alex Buckley wrote:
> On 7/30/2020 10:39 PM, Joe Darcy wrote:
>> PS In the next iteration of the webrev,
>>
>>      http://cr.openjdk.java.net/~darcy/8071961.6
>>
>> the messages have been updated to
>>
>>   185 javac.opt.Xlint.desc.missing-declared-ctor=\
>>   186     Warn about missing declared constructors in public classes 
>> in exported packages.
>>
>> 1763 # 0: symbol, 1: symbol, 2: symbol
>> 1764 compiler.warn.missing-declared-ctor=\
>> 1765     class {0} in exported package {1} of module {2} does not 
>> declare any explicit constructors, exposing a default constructor to 
>> clients
>
> These messages look very good.

I'm afraid I disagree on the second message :-(

I'm having issues to parse it - mostly for two reasons:

1) the ceremony of class/package/module takes the first half of the 
message, w/o significantly add info (provided that javac would also have 
generated the file name somewhere in the diagnostic)
2) the use of "ing" (as in "exposing") seems confusing, and leaves the 
reader wondering as to what exactly the problem with the code is

I'd go for something more direct, like:

class {0} exposes a default constructor to clients of module {2}

Maurizio

>
> Alex


More information about the compiler-dev mailing list