[jdk21u-dev] RFR: 8335638: Calling VarHandle.{access-mode} methods reflectively throws wrong exception
Paul Hohensee
phh at openjdk.org
Wed Sep 10 16:06:32 UTC 2025
On Wed, 3 Sep 2025 02:52:36 GMT, Rui Li <duke at openjdk.org> wrote:
> A clean backport for https://bugs.openjdk.org/browse/JDK-8335638.
>
> According to [the API specification](https://github.com/openjdk/jdk/blob/d7b941640638b35f9ac1ef11cd6bf6ccb795c29a/src/java.base/share/classes/java/lang/invoke/VarHandle.java#L435-L442), invoking VarHandle.{access-mode} methods reflectively throws an `UnsupportedOperationException`. However, it currently throws exception is an `UnsatisfiedLinkError` instead. (Pretty much what's in the `Problem` section of the [CSR](https://bugs.openjdk.org/browse/JDK-8335805))
>
> Low risk. See Hannes Greule's comment in CSR: https://bugs.openjdk.org/browse/JDK-8335805:
>
>> it only applies when invoking those methods reflectively - doing that always results in some form of Throwable being thrown - MethodHandle already throws UnsupportedOperationException in the same case - The exception is wrapped by an InvocationTargetException
>
>
> Note: I'm not sure if there are any additional processes aside from a pr itself when backporting a fix requiring a CSR to previous versions. Let me know if it requires something else.
At Amazon (and perhaps other large scale Java shops), we generally don't adopt new LTS releases immediately because we need to wait until the release is stable, typically at the .02 or even .03 releases. So we'd like to backport to 21u in the meantime.
-------------
PR Comment: https://git.openjdk.org/jdk21u-dev/pull/2144#issuecomment-3275597301
More information about the jdk-updates-dev
mailing list