[Nestmates] Add a core reflection API to get nestmate information

David Holmes david.holmes at oracle.com
Mon Nov 20 11:43:51 UTC 2017


Hi Peter,

On 20/11/2017 7:39 PM, Peter Levart wrote:
> Hi David,
> 
> On 11/20/2017 10:20 AM, Peter Levart wrote:
>> Your comment in the issue:
>>
>> https://bugs.openjdk.java.net/browse/JDK-8187768?focusedCommentId=14123862&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14123862
>>
>> ...describes how access checking for private members behaves in VM and 
>> what are the outcomes when class attributes are missing or not 
>> consistent (access is denied - IllegalAccessError is thrown) vs. when 
>> nest-host class can not be resolved (NoClassDefFoundError is thrown). 
>> I think this is sound.
> 
> I found a wording in the spec update that maybe requires some 
> explanation. This is the relevant part:

Latest wording is here:

http://cr.openjdk.java.net/~dlsmith/nestmates.html

> /A class or interface H grants nest membership to a class or interface D 
> if H is declared in the same run-time package as D, H has a NestMembers 
> attribute (4.7.29), and there is some value j in the classes array of 
> the NestMembers attribute of H, such that item j of the run-time 
> constant pool of H is a symbolic reference to D. //
> ////
> //        Because H belongs to the same run-time package as D, it is not 
> necessary to resolve a symbolic reference in H in order to determine 
> whether it references D. It is only necessary to check the unresolved name./
> 
> What does it mean that "H belongs to the same run-time package as D"? 
> Does it mean that package names of H and D are equal, or does it also 
> imply that both H and D are loaded by the same class loader? While 
> jigsaw makes the class loader check unnecessary (either H and D are in 
> the same module and consequently loaded by same class loader or H is not 
> resolvable from D when they share package name), java still has plain 
> ClassLoader(s) and does not always guarantee the absence of split packages.

Same runtime package == same package name + same defining classloader. 
This is as defined for verification (JVMS 4.10) and class creation and 
loading (JVMS 5.3).

David
-----

> Regards, Peter
> 


More information about the valhalla-spec-observers mailing list