Updated JEP: nestmates

Remi Forax forax at univ-mlv.fr
Thu Apr 13 10:37:31 UTC 2017


Re-reading the spec again,
i think it would be clearer if you introduce T the nest-top, and modifying the classloading order has to be listed in the "Risks and Assumptions" section.

Description:
  "The Java compiler compiles a group of nested types into a corresponding group of class files; it uses the InnerClasses and EnclosingMethod attributes to reify the nesting relationship (JVMS 4.7.6 and 4.7.7)."
  We can not re-use these attributes to describe nesting relationship because being part of a nest has to be verified, triggering classloading of the nest-top, thus changing the semantics of the existing attributes.
  ...

  "For types C and D to be nestmates they must either have the same nest-top T. A type C claims to be a member of the nest of D, if both C and D list T in their MemberOfNest attribute. The membership is validated during class loading if T also lists C and D in its NestMembers attribute. This may require loading of nest-top types earlier than might otherwise occur."

  A type classfile has zero or one MemberOfNest attribute and zero or one NestMembers. So a type can only be part of zero or one nest.  

Risks and Assumptions
  This proposal modifies the classloading order because a nest-top of a type needs to be loaded either eagerly when a member of a nest is loaded or more lazily when a member of a nest try to access to another member of a nest.
  This is not a problem for an inner-class because it also has a reference to the enclosing class, so the nest-top class is already loaded, for non inner class (static enclosed class), it will depend on the java compiler implementation, i.e. if the compiler eagerly add nestmates that mirror the InnerClasses attribute even if the enclosed class/interface do not access to a nestmate member or if the compiler add nestmates to the nest only when necessary (like currently it only generates bridges when necessary).

cheers,
Rémi

----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: valhalla-dev at openjdk.java.net
> Envoyé: Mercredi 12 Avril 2017 23:28:17
> Objet: Updated JEP: nestmates

> The "Nestmates" JEP has been updated:
> 
>      https://bugs.openjdk.java.net/browse/JDK-8046171


More information about the valhalla-dev mailing list