RFR: 8268328: Upstream: 8267989: Exceptions thrown during upcalls should be handled (Pt. 1)
Jorn Vernee
jvernee at openjdk.java.net
Mon Jun 7 16:04:30 UTC 2021
Hi,
This is part 1 of a two part upstreaming process of the patch mentioned in the subject line. The patch was split into 2 in order to document 2 separate specification changes that arose from a change in the implementation, with 2 separate CSRs.
This patch changes the handling of method handles that might throw checked exceptions, by the var handle combinators found in `jdk.incubator.foreign.MemoryHandles`. Particularly, it makes the check more lenient towards `BoundMethodHandle`s that have fields that are method handles that might themselves throw exceptions, since it is not known whether the enclosing method handle catches such exceptions. For instance, if a target method handle is wrapped using the `catchException` combinator, which handles all exceptions thrown by that target, the current code will still reject such method handles, even though no checked exceptions can be thrown.
The patch fixes this by instead wrapping method handles for which it is not possible to eagerly determine whether they throw exception using the `catchException` combinator, with an exception handler that catches checked exceptions and instead throws an `IllegalStateException` with the original exception as the cause. (See also the CSR).
The main motivation for doing this is having the ability to share the implementation with the `CLinker::upcallStub` API, which also wants to eagerly reject method handles that are determined to throw exceptions.
Thanks,
Jorn
Testing: `jdk_foreign` test suite.
-------------
Commit messages:
- Pt1
Changes: https://git.openjdk.java.net/jdk/pull/4395/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4395&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8268328
Stats: 100 lines in 4 files changed: 49 ins; 18 del; 33 mod
Patch: https://git.openjdk.java.net/jdk/pull/4395.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/4395/head:pull/4395
PR: https://git.openjdk.java.net/jdk/pull/4395
More information about the core-libs-dev
mailing list