On Thu, 20 Jul 2023 01:04:08 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: > > update copyright header src/java.base/share/classes/java/lang/invoke/VarHandle.java line 2010: > 2008: static AccessMode valueFromOrdinal(int mode) { > 2009: return VALUES[mode]; > 2010: } Also, I'll throw this out there, though I'm not sure how big of an issue it is: this array creation might have an effect on startup. But, since it is only used on a slow path right before we throw an exception (at least, at the moment), calling `values()` every time inside the `valueFromOrdinal` method, and avoiding the array creation on startup, might be 'better'. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14928#discussion_r1269616973