On Mon, 7 Jun 2021 15:14:39 GMT, Jorn Vernee <[email protected]> wrote:

> 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.
> 
> See also the original review for the panama-foreign repo: 
> https://github.com/openjdk/panama-foreign/pull/543
> 
> Thanks,
> Jorn
> 
> Testing: `jdk_foreign` test suite.

Deferred until a better solution is available.

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

PR: https://git.openjdk.java.net/jdk/pull/4395

Reply via email to