defaultvalue and enclosing instances

Srikanth srikanth.adayapalam at oracle.com
Sat Sep 15 01:26:16 UTC 2018



On Friday 14 September 2018 09:47 PM, Victor Nazarov wrote:
>
>
> пт, 14 сент. 2018 г., 19:06 John Rose <john.r.rose at oracle.com 
> <mailto:john.r.rose at oracle.com>>:
>
>     On Sep 14, 2018, at 1:32 AM, Srikanth
>     <srikanth.adayapalam at oracle.com
>     <mailto:srikanth.adayapalam at oracle.com>> wrote:
>     >
>     > ... (d) other solutions ...
>
>     The simplest one comes to mind:  Allow T.default to have a default
>     up-reference
>     of null, as a special case for inner values.  Referring to the
>     outer instance from
>     a default inner instance will thus fail with NPE.  "It hurts when
>     I do this, Doctor"
>     "Then don't do that."
>
>
> But this means that you can't use enclosed value type instances.

Not quite. Properly enclosed value instances can be created via the 
classic constructor notation: e.g:
new Outer().new InnerValue();

Srikanth



More information about the valhalla-dev mailing list