RFR: 8199149: Improve the exception message thrown by VarHandle of unsupported operation [v4]
Jorn Vernee
jvernee at openjdk.org
Thu Jul 20 15:13:46 UTC 2023
On Thu, 20 Jul 2023 01:04:08 GMT, Mandy Chung <mchung at 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
Marked as reviewed by jvernee (Reviewer).
src/java.base/share/classes/java/lang/invoke/VarHandleGuards.java line 2:
> 1: /*
> 2: * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
I think you've updated the wrong copyright header?
-------------
PR Review: https://git.openjdk.org/jdk/pull/14928#pullrequestreview-1539490370
PR Review Comment: https://git.openjdk.org/jdk/pull/14928#discussion_r1269597027
More information about the core-libs-dev
mailing list