[jdk21u-dev] RFR: 8335638: Calling VarHandle.{access-mode} methods reflectively throws wrong exception

Rui Li duke at openjdk.org
Wed Sep 3 04:28:45 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.

The auto updated pr notes asks to create a CSR:

> Change requires a CSR request matching fixVersion 21.0.9 to be approved (needs to be created)

I'm not sure if there's anything additional to add on top of https://bugs.openjdk.org/browse/JDK-8335805, aside from marking it with a different version number. If a new CSR jbs is required for tracking, let me know and I'll copy JDK-8335805 to new one.

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

PR Comment: https://git.openjdk.org/jdk21u-dev/pull/2144#issuecomment-3247639251


More information about the jdk-updates-dev mailing list