RFR: 8314592: Add shortcut to SymbolLookup::find [v7]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Apr 22 13:49:37 UTC 2024
On Mon, 22 Apr 2024 08:46:53 GMT, Per Minborg <pminborg at 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.
>
> Per Minborg has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 12 additional commits since the last revision:
>
> - Simplify tests
> - Add a test for null arg
> - Add a test for findOrThrow()
> - Merge branch 'master' into symbol-lookup-findorthrow
> - Change exception type
> - Update src/java.base/share/classes/java/lang/foreign/package-info.java
>
> Co-authored-by: Jorn Vernee <JornVernee at users.noreply.github.com>
> - Update src/java.base/share/classes/java/lang/foreign/SymbolLookup.java
>
> Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com>
> - Update src/java.base/share/classes/java/lang/foreign/SymbolLookup.java
>
> Co-authored-by: Maurizio Cimadamore <54672762+mcimadamore at users.noreply.github.com>
> - Fix typo
> - Update after PR comments
> - ... and 2 more: https://git.openjdk.org/jdk/compare/9a68d47d...0e06e0d6
test/jdk/java/foreign/loaderLookup/TestSymbolLookupFindOrThrow.java line 41:
> 39:
> 40: static {
> 41: System.loadLibrary("Foo");
Where is this lib defined?
test/jdk/java/foreign/loaderLookup/TestSymbolLookupFindOrThrow.java line 58:
> 56: @Test
> 57: void findOrThrowNullArg() {
> 58: assertThrows(NullPointerException.class, () ->
I believe this should already be checked by the TestNulls test - which is a test that automatically checks that _all_ API methods handle nulls accordingly. Please check that, and maybe remove this?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18474#discussion_r1574788219
PR Review Comment: https://git.openjdk.org/jdk/pull/18474#discussion_r1574786946
More information about the core-libs-dev
mailing list