defaultvalue and enclosing instances

Victor Nazarov asviraspossible at gmail.com
Fri Sep 14 16:17:08 UTC 2018


пт, 14 сент. 2018 г., 19:06 John Rose <john.r.rose at oracle.com>:

> On Sep 14, 2018, at 1:32 AM, Srikanth <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. The whole
point of enclosed instances is guarateed presence of enclosing instance.
Then why not to forbid enclosed value type instances altogeather in
compiler and class-file verifier?

--
Victor Nazarov

>


More information about the valhalla-dev mailing list