Revisiting default values

Roger Riggs Roger.Riggs at
Tue Jul 14 18:58:37 UTC 2020

Hi Dan,

I don't think its tennable to have inline values around that are not 
valid because they
have not been 'created' without going through the 'constructors'.

I know that is what you are trying to solve (the tradeoffs).

On 7/13/20 1:36 PM, Dan Smith wrote:
>  From valhalla-spec-observers:
>> On Jul 12, 2020, at 10:45 PM, Zheka Kozlov <orionllmain at> wrote:
>> Sorry for a probably stupid question but aren't all classes from Bucket #2 and #3 ref-default? Which means when we are calling new LocalDate[10], all elements of the array are initialized to null. And since the constructors of these classes are private, the external user will never see the instances in their default state.
> True, 'new LocalDate[10]' will continue to allocate an array of nulls. The default instance is only relevant when someone does 'new LocalDate.val[10]'.
If LocalDate becomes the inline class, then 'new LocalDate[10]' will be 
an array of inline instances, not references.
At least that was the expectation when labeling LocalDate as a value class.
And they should be initialized to a value that is provided by or 
consistent with one of the constructors.

So for arrays, that needs to happen before the first reference, some 
lazyness is ok but would need to be
enforced by the VM. This needs to be true for fields as well as arrays.
Having a class defined default value would at least provide a mechanism 
to make that instance be
under control of the class, even if only is able to throw an exception 
because there is no valid
value as in some of your previous examples.

I know this point went by a while back, but allowing the default and 
'withfield' bytecodes outside
of a legatimate constructor seems like integrity problem.  With identity 
classes, the verifier and VM goes to some
lengths to check that a partially/not initialized instance is not published.

I agree with Kevin's concerns.

Regards, Roger

> Regardless of the syntax, if there exists an inline type for instances of an inline class ('LocalDate.val' above), there will also be a semantic question of how we initialize fields/arrays of that inline type.

More information about the valhalla-spec-observers mailing list