[foreign-memaccess+abi] RFR: 8314592: Add shortcut to SymbolLookup::find
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Aug 22 12:33:28 UTC 2023
On Fri, 18 Aug 2023 17:05:46 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This patch adds a default method in `SymbolLookup`, namely `SymbolLookup::get`. Its implementation is very simple: it calls `SymbolLookup::find` and then `Optional::get` on the result. This allows to simplify many clients that end up calling `Optional::get` or `Optional::orElseThrow` after a symbol lookup, but still retains the compositional advantage of the optional-returning lookup primitive.
I've made the exception message clearer. My general feeling on naming is that if we make it too verbose (e.g. `findOrThrow`), then it's not very different from `find(...).orElseThrow()` ?
If there's no consensus on the naming scheme, I'm also ok leaving it out for now, as this is something that can always be added at a later point.
-------------
PR Comment: https://git.openjdk.org/panama-foreign/pull/871#issuecomment-1688088632
More information about the panama-dev
mailing list