[Nestmates] RFR: 8187768 and 8189940 - nest host resolution and exceptions

David Holmes david.holmes at oracle.com
Wed Nov 1 22:23:45 UTC 2017


Hi Maurizio,

On 1/11/2017 11:53 PM, Maurizio Cimadamore wrote:
> Looks good - sorry for the delay.

No problem, thanks for taking a look.

> Not sure about this message: "nest-host is not an instance class". That 
> term doesn't make a lot of sense in terms of Java, nor bytecode. 
> Basically, what you want to rule out here is some spurious Class_info 
> which contains something that is not a class - e.g. an array type or 
> even a value type. Perhaps you can rephrase by leaving out the term 
> "instance" - e.g. "nest-host is not a class" ?

The ClassInfo has to refer to a class else it gets rejected, but it 
can't be a class for a primitive or array type, or ?? - it has to be an 
instance class. As I don't really expect anyone to ever encounter this 
in practice I'm not too concerned if it seems a little cryptic. The full 
message looks like this:

  Type TestNestmateMembership$CallerNotInstanceHost is not a nest member
  of [Ljava.lang.Object;: nest-host is not an instance class!

I have to admit the verbosity here is to support testing as not being an 
instance class is a specific validation check.

Thanks,
David

> Maurizio
> 
> 
> On 31/10/17 21:23, David Holmes wrote:
>> As I need to move on I'll push these changes today even though no one 
>> has had an opportunity to provide feedback.
>>
>> David
>>
>> On 30/10/2017 11:24 AM, David Holmes wrote:
>>> On 27/10/2017 6:04 PM, David Holmes wrote:
>>>> Combined webrev: http://cr.openjdk.java.net/~dholmes/8187768/webrev/
>>>>
>>>> bug: https://bugs.openjdk.java.net/browse/JDK-8187768
>>>>
>>>> 8187768: [Nestmates] Improve exception information related to 
>>>> bad/missing nest-host class
>>>>
>>>> This work implements the latest specification proposal for nest-host 
>>>> resolution and validation exceptions:
>>>>
>>>> http://cr.openjdk.java.net/~dlsmith/nestmates.html
>>>>
>>>> and also provides better diagnostic information for the exceptions 
>>>> that occur. Key features:
>>>>
>>>> - instanceKlass::nest_host():
>>>>    - passes through most resolution related exceptions
>>>>    - replaces NoClassDefFoundError with a  new NCDFE with the 
>>>> original as the cause and a message "Unable to load nest-host class 
>>>> of %s" to give context to the exception
>>>>    - throws IllegalAccessError when nest membership validation fails 
>>>> (as per updated spec) with appropriate error message
>>>
>>> I realized that nest_host() should only throw IllegalAccessError when 
>>> called from has_nestmate_access_to(). I'll address that when adding 
>>> the reflection API support.
>>>
>>> David
>>> -----
>>>
>>>> - Reflection::verify_field_access can now more obviously result in 
>>>> pending exceptions
>>>> - All callers of Reflection::verify_field_access watch for pending 
>>>> exceptions and don't replace them with their own IllegalAccessErrors.
>>>> - runtime/Nestmates/membership tests have been completely rewritten 
>>>> to test updated spec - including the need to test for failures in 
>>>> the calling class's nest-host resolution and in the target class's 
>>>> nest-host resolution.
>>>>
>>>> While working here I rediscovered the Xcomp problem where the JIT 
>>>> tries to load a nest-host class when not allowed to:
>>>>
>>>> bug: https://bugs.openjdk.java.net/browse/JDK-8189940
>>>> 8189940:  [Nestmates] VM Compiler thread needs to load nest-host class!
>>>>
>>>> The fix here was to check in InstanceKlass::nest_host() if we are on 
>>>> a thread that can't call java, and that we may have to load a 
>>>> nest-host class. In that case we return NULL, causing 
>>>> has_nestmate_access_to to return false, it's callers post 
>>>> IllegalAccessError and the JIT sees that failure and falls back to 
>>>> going through the interpreter to complete its work.
>>>>
>>>> runtime/Nestmates tests all pass in normal and Xcomp mode now.
>>>>
>>>> Thanks,
>>>> David
> 



More information about the valhalla-dev mailing list