[foreign-abi] RFR: 8253430: Improve the LibraryLookup API

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon Sep 21 14:02:55 UTC 2020


On Mon, 21 Sep 2020 13:55:56 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:

>> This patch implements a couple of suggestion which were made a couple of weeks ago by @BlueGoliath - here:
>> 
>> https://mail.openjdk.java.net/pipermail/panama-dev/2020-July/010140.html
>> 
>> Two ideas here:
>> * Change the signature of `LibraryLookup::ofPath` to actually take a `Path` (rathar than a `String`)
>> * Tweak `LibraryLookup::lookup` to return `Optional` (rather than throw)
>> 
>> Both suggestions seem to change the API for the better. The second one is probably more controversial: on the one hand
>> it removes the need for having exception handling logic and makes it for more composable logic. On the other hand
>> clients have to manually call `get` on the lookup result. But overall seems a win.
>
> src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/LibraryLookup.java line 116:
> 
>> 114:     static LibraryLookup ofPath(Path path) {
>> 115:         Objects.requireNonNull(path);
>> 116:         String absolutePath = path.toAbsolutePath().toString();
> 
> Path.toAbsolutePath itself is a secure operation (could potentially throw SecurityException).  Should insist on
> absolute Path (that way it is up to the client to manage absolute Path object)?

I think it's nice, from an usability perspective, that any path is accepted - but I'm open to change here

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

PR: https://git.openjdk.java.net/panama-foreign/pull/348


More information about the panama-dev mailing list