On Wed, 19 Jul 2023 02:19:58 GMT, Mandy Chung <mch...@openjdk.org> wrote:

>> `VarForm::getMemberName` currently throws UOE with no information if the 
>> requested access mode is unsupported.   To provide the var handle 
>> information, move the access mode check to `VarHandle` so that the exception 
>> message can include the var handle information.  Changes include:
>> 
>> 1. change `VarHandle::checkAccessModeThenIsDirect` to check if the access 
>> mode is unsupported.  This check is only needed for direct var handle.
>> 2. change `VarHandle::getMethodHandleUncached` to call `getMemberNameOrNull` 
>> and throw UOE with an informative exception message if the access mode is 
>> unsupported
>> 
>> The error message looks like:
>> 
>> java.lang.UnsupportedOperationException: compareAndSet is not supported for 
>> VarHandle[varType=java.lang.String, coord=[class Foo$Goo]]
>
> Mandy Chung has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   review feedback

I got feedback from @PaulSandoz.   The patch is updated to include only the 
access mode information.

`checkAccessModeThenIsDirect` is on a performance sensitive path.   We only 
need to modify `VarForm::getMemberName` to print out the access mode.   Also 
mark `getMemberName` as `@Hidden` which then shows the call site from the top 
of the stack trace.    The user can find out which VarHandle from the callsite 
from the stack trace location.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14928#issuecomment-1642902785

Reply via email to