hg: valhalla/valhalla: Scanner, parser, semantic analysis and attribution support for value types

Srikanth srikanth.adayapalam at oracle.com
Mon Feb 5 10:48:29 UTC 2018

On Friday 02 February 2018 08:30 PM, Karen Kinnear wrote:
> Srikanth,
> Thank you for the thoughtful discussion.
> Had a long chat with Brian and it sounds like he is in agreement with 
> the model of having javac
> perform compile time checks.

Hi Karen,

Thanks for sharing this information. I think there is a precedent for 
such dual checks in javac as well as jvm (e.g: javac would reject casts 
that can be statically ascertained to be impossible conversions and the 
jvm would throw a CCE for the ones that looks plausible at compile time, 
but are found to be flawed casts) and such dual checks is the right 
design choice for the present scenario too.


>> You asked: "would it also make sense for an instance method that sets 
>> a field to create a new value instance using the current values of 
>> the starting instance fields and explicitly set a field (or set of 
>> fields)"
>> Ans: No. This is not supported in VVT and also not in Lworld: 
>> Assignment to blank finals cannot be allowed anywhere else (outside 
>> of constructors and static value factories) without calling into 
>> question the very meaning of finality.
> So how would set a value instance’s fields to other than default?
> I presume by having factories with arguments?


> Is there a way to take a value type with two fields, one initialized, 
> and create a new value type containing the
> values of an existing value type and adding one more? I think that is 
> the model John is looking for.
> So perhaps that would be another static factory that takes an existing 
> value instance and sets a specific field,
> so might be called ValueType = setField1(starterValueType ,field1contents)
> That is what I meant by a setter.

Yes. While __MakeDefault can be used only in a static value factory, a 
static value factory is not required to invoke __MakeDefault first. 
OIOW, it can operate on existing value instances and using its privilege 
modify one or more fields to compose a new value.


More information about the valhalla-dev mailing list