On Mon, 25 Mar 2024 14:56:23 GMT, Per Minborg <pminb...@openjdk.org> wrote:
> While `SymbolLookup` correctly uses an `Optional` return to denote whether a > symbol has been found by the lookup or not (which enables composition of > symbol lookups), many clients end up just calling `Optional::get`, or > `Optional::orElseThrow()` on the result. > > This PR proposes to add a convenience method `SymbolLookup::findOrThrow` that > will do a lookup and, if no symbol can be found, throws an > `IllegalArgumentException` with a relevant exception message. src/java.base/share/classes/java/lang/foreign/SymbolLookup.java line 152: > 150: > 151: /** > 152: * {@return the address of the symbol with the provided {@code name} > or throws an I suggest using the same javadoc structure as the main `find` method. Note that there we have a summary, then a more detailed `@return` which talks about zero length memory segments. This should do the same. src/java.base/share/classes/java/lang/foreign/SymbolLookup.java line 155: > 153: * {@linkplain IllegalArgumentException} if no such address > can be found} > 154: *<p> > 155: * This is a convenience method that provides better exception > messages compared I would reframe this as: "this is equivalent to the following code, but with better exception message" (for consistency with other API points in FFM where we show what a method boils down to) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/18474#discussion_r1560889723 PR Review Comment: https://git.openjdk.org/jdk/pull/18474#discussion_r1560893974