-
CSR
-
Resolution: Approved
-
P3
-
None
-
behavioral
-
minimal
-
The reflective invocations always terminate abnormally with an exception, so users likely rarely used it.
-
Java API
-
SE
Summary
Adjust the exception thrown by invoking VarHandle.{access-mode} methods reflectively to match the specification.
Problem
According to the API specification, invoking VarHandle.{access-mode} methods reflectively throws an UnsupportedOperationException
(https://github.com/openjdk/jdk/blob/d7b941640638b35f9ac1ef11cd6bf6ccb795c29a/src/java.base/share/classes/java/lang/invoke/VarHandle.java#L435-L442). However, the currently thrown exception is an UnsatisfiedLinkError
instead.
Solution
MethodHandle.invoke/invokeExact methods are equally special-cased in the specification. We can extend the existing solution that implements the behavior for MethodHandle to also cover VarHandle.
This way, invoking the methods reflectively will throw an UnsupportedOperationException
as specified.
Specification
No specification changes.
- csr of
-
JDK-8335638 Calling VarHandle.{access-mode} methods reflectively throws wrong exception
- Resolved