JDK 16 RFR of JDK-8071961: Add javac lint warning when a default constructor is created
Joe Darcy
joe.darcy at oracle.com
Fri Jul 31 05:39:24 UTC 2020
On 7/30/2020 6:33 PM, Joe Darcy wrote:
> On 7/30/2020 11:17 AM, Alex Buckley wrote:
>> On 7/30/2020 10:15 AM, Joe Darcy wrote:
>>> On 7/30/2020 12:51 AM, Alex Buckley wrote:
>>>> On 7/29/2020 9:32 PM, Joe Darcy wrote:
[snip]
>>
> Like most javac lint warnings, this one being proposed to be triggered
> by inclusion of a default constructor is localized in nature. From my
> perspective, the situation being noted is a not a separate
> (re)compilation hazard or even indirectly an issue for the clients.
> (From earlier in the thread, since the MANDATED information is not
> persisted into the class file, the compiler cannot reliably warn
> callers of a default constructor such a constructor is being called,
> if that is a concern.) Rather, the message is to the author/maintainer
> of class Foo being compiled -- "BTW, since you left one out, clients
> of your class Foo will see a constructor not present in your source
> code. Make sure your are okay with that and all it implies."
>
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
Cheers,
-Joe
More information about the compiler-dev
mailing list