Updated JEP: nestmates

David Holmes david.holmes at oracle.com
Tue Apr 18 05:35:32 UTC 2017


Just to reiterate comments I made in other responses ...

On 15/04/2017 6:34 AM, John Rose wrote:
> On Apr 13, 2017, at 3:12 PM, Brian Goetz <brian.goetz at oracle.com
> <mailto:brian.goetz at oracle.com>> wrote:
>>
>> We can't rely on javac (or other compilers) to always generate "nest
>> of one" attributes, so the VM would have to, on seeing a class with no
>> nest attributes, set "nestTop = me".  But I think that would be the
>> only change in the implementation?  And then nestTop(C) becomes a
>> total function, which simplifies things.
>
> Confirmed.
>
> Regarding javac: It would be polite if javac were to agree that if
> the output classfile has an InnerClasses attribute, and the current
> class either records an outer-class or the current class *is* an
> outer-class, then the classfile will also have one of the nestmate
> attributes.

Currently nestmate attribute generation is completely independent of 
innerclass atrributes and only enabled for "-release 10" or later.

> But the system has to be robust if javac drops the ball once in a while.

Not sure what that means. The spec will define legal use of the new 
attributes and the VM will reject any non-conformant use.

> And it certainly has to read down-rev class files correctly.

Yes, as I said, pre 54 classfiles are expected to continue to use 
innerclass attributes (and only those - though IIUC we can't reject 
unexpected attributes, only ignore them).

> On Apr 13, 2017, at 2:57 PM, David Holmes <david.holmes at oracle.com
> <mailto:david.holmes at oracle.com>> wrote:
>>
>> Do you want javac to generate a self-referential MemberOfNest
>> attribute? If you want this then the definitions need a rewrite. This
>> is not where we are today.
>
> FTR, the form of a degenerate nest is not a self-referential MON
> attribute, but an empty NMs attribute.  That's allowed by the spec.

Are you saying that is what you want javac to generate? The current 
proposed definition of the NM attribute prohibits it:

https://bugs.openjdk.java.net/browse/JDK-8177020

Add: 4.7.26 The `NestMembers` Attribute

The `NestMembers` attribute is a variable-length attribute in the 
attributes table of a `ClassFile` structure (§4.1).

If the constant pool of a class or interface `C` contains at least one
`CONSTANT_Class_info` entry (§4.4.1) which represents a class or 
interface that is not a member of a package, then there must be exactly 
one `NestMembers` attribute in the attributes table of the `ClassFile` 
structure for `C`. If `C` itself is not a member of a package, then 
there must not be a `NestMembers` attribute in the attributes table of 
the `ClassFile` structure for `C`.
---

Cheers,
David

> — John


More information about the valhalla-dev mailing list