[nestmates] validation of ClassFile for hidden classes

Mandy Chung mandy.chung at oracle.com
Wed Nov 13 00:45:06 UTC 2019


A recent review with Alex and John on [1][2] specifically on:
- Hidden classes cannot participate in static nest membership as
   they do not have names. NestHost/NestMembers attributes on hidden
   classes are ignored.

Instead of making validation of ClassFile for hidden classes and ordinary
classes somewhat different, the alternative is to have the validation
for hidden classes and ordinary classes identical.  When another class
(whether ordinary or hidden) names a hidden class as its declaring class
or class member (via |InnerClasses| attribute), or as its nest host
(via |NestHost| attribute), or as a member of its nest
(via |NestMembers| attribute), the class may successfully be created
while it may fail at run time where there is any attempt to resolve
a hidden class by name via any of these attributes per existing
specification.  No special rule for validation of hidden classes.

David,

This is the revised webrev:
http://cr.openjdk.java.net/~mchung/valhalla/webrevs/8171335/webrev-hidden-class-validation/

If a hidden nestmate class has a `NestHost` or `NestMembers` attribute,
and it's created to add to a member of a dynamic nest host (H), then
the runtime nest host is set to `H` and these attributes will not
be validated subsequently.

If a hidden class has a `NestHost` or `NestMembers` attribute and
created with Lookup::defineHiddenClass without NESTMATE option,
then the behavior is the same as an ordinary class with a bad
`NestHost` or `NestMembers` attribute (e.g. HC's nest host is
not yet validated.  When it attempts to access NH's private member,
it would fail to resolve NH.)

I'm not sure if this is the best way to implement
InstanceKlass::set_nest_host.  When there is a proposed JVMS draft,
we may make more adjustment to the implementation.  So I hope
this patch is good to push in the time being.

This patch also includes a small javadoc change.

Mandy
[1] http://hg.openjdk.java.net/valhalla/valhalla/rev/ad257875959a
[2] 
https://mail.openjdk.java.net/pipermail/valhalla-dev/2019-September/006420.html


More information about the valhalla-dev mailing list