Implicit constructor of the super class of a null restricted value class
forax at univ-mlv.fr
forax at univ-mlv.fr
Sat Oct 21 14:03:55 UTC 2023
> From: "daniel smith" <daniel.smith at oracle.com>
> To: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "valhalla-spec-experts" <valhalla-spec-experts at openjdk.java.net>
> Sent: Saturday, October 21, 2023 3:48:31 PM
> Subject: Re: Implicit constructor of the super class of a null restricted value
> class
>> On Oct 21, 2023, at 12:27 AM, Remi Forax <forax at univ-mlv.fr> wrote:
>> In [ https://bugs.openjdk.org/browse/JDK-8317765 |
>> https://bugs.openjdk.org/browse/JDK-8317765 ] ,
>> an implicit constructor must be public and the super class is either Object or a
>> super class with an implicit constructor.
>> This means that we can NOT create a null restricted value record because the
>> constructor of Record is protected.
>> I think the constraints on the implicit constructor of the super class should be
>> relaxed. The implicit constructor of the super class does not have to be
>> public.
> Sure, we could relax the rule. But why?
> Specifically, when it comes to Record, is there any reason the constructor can't
> be made public?
> (My interpretation of the code is that somebody wanted to emphasize that Record
> is an abstract class by making the constructor protected. But 'abstract' and
> 'protected' have the same effect here, you don't need them both.)
Record is an example, even if we change the constructor of Record to public, an implicit constructor of a super class does not have to be public, being visible to the value class seems enough.
One reason we want to support super classes for value class is to be able to retrofit existing classes, in that case, why not allowing classes that have a superclass with an empty constructor non public to be retrofitted.
regards,
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-spec-experts/attachments/20231021/43108708/attachment-0001.htm>
More information about the valhalla-spec-experts
mailing list