----- Mail original -----
> De: "Brian Goetz" <brian.go...@oracle.com>
> À: "Remi Forax" <fo...@univ-mlv.fr>
> Cc: "John Rose" <john.r.r...@oracle.com>, "amber-spec-experts" 
> <amber-spec-experts@openjdk.java.net>
> Envoyé: Vendredi 6 Septembre 2019 00:29:14
> Objet: Re: Draft JLS spec for records

>> from the same mail:
>> "the canonical constructor should follow the same rule as the default
>> constructor".
> 
> This isn't an obviously terrible idea, but it's also not a very
> important distinction, because the difference isn't observable -- if the
> class isn't accessible to the caller, they still can't invoke the
> constructor. 

apart if you have a Lookup object, yes.

> And it does have additional complexity, and leaves users
> in a position of guessing what the accessibility should be if they
> implement the methods explicitly.

It's a constructor, not a method, so there is no need to match the default 
constructor accessibility.
Like with a class, if you write the constructor explicitly, you can choose the 
accessibility you want. 

> Do you have a reason for preferring
> this additional complexity, other than "for consistency"?  (And why
> would we do it differently for the constructor than for the accessors?
> That's just pure accidental complexity.)

A constructor and an accessor doesn't have a lot in commmon in term of 
semantics at Java level,
the argument that the canonical constructor should be public because the 
accessors are is not something i've ever heard in Java,
so for me, that's the additional complexity.

And yes, consistency is important, as you said,
"In fact, one by one, we've been _removing_ gratuitous differences between 
records and classes, and each time we did, the design seems to have gotten 
better."

Saying the constructor generated by the compiler for a record or a class use 
the same accessibility rules seems the right thing to do.

Rémi

Reply via email to