[nestmates] validation of ClassFile for hidden classes
mandy.chung at oracle.com
Wed Nov 13 00:45:06 UTC 2019
A recent review with Alex and John on  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.
This is the revised webrev:
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.
More information about the valhalla-dev