[foreign-memaccess+abi] RFR: 8265222: revisit foreign library loading [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu May 6 13:40:13 UTC 2021


On Thu, 6 May 2021 13:25:41 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:

>> LibraryLookup removed. CLinker.findNative added. System.loadLibrary has to be used to load library
>
> Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Windows hack for malloc/free. fixed javadoc comments. benchmarks use new APIs. removed psapi.h header include.

Looks good - added some javadoc suggestions

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CLinker.java line 134:

> 132: 
> 133:     /**
> 134:      * Looks up a symbol with the given name in the native libraries loaded by the caller's classloader.

Suggestion:

     * Finds the address of a symbol with given name in one of the native libraries associated with the caller's classloader (that is, libraries loaded using {@link System#loadLibrary} or {@link System#load}).

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CLinker.java line 142:

> 140:      * restricted methods, and use safe and supported functionalities, where possible.
> 141:      *
> 142:      * @param name the symbol name.

Suggestion:

     * @param the name of the symbol to be searched.

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CLinker.java line 143:

> 141:      *
> 142:      * @param name the symbol name.
> 143:      * @return the memory address associated with the library symbol (if any).

Suggestion:

     * @return the address of a symbol with given name in one of the native libraries associated with the caller's classloader (if any).

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/package-info.java line 120:

> 118:  * }</pre>
> 119:  *
> 120:  * Here, we lookup the {@code strlen} symbol. C runtime library should have been loaded earlier using {@link System#loadLibrary(String)}.

Suggestion:

 * Here, we lookup the {@code strlen} symbol; this assumes that a library containing the `strlen` symbol has been loaded earlier, e.g. using {@link System#loadLibrary(String)}.

src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/SharedUtils.java line 419:

> 417: 
> 418:         private static final CLinker linker = getSystemLinker();
> 419:         // FIXME: This should go away. This is temporary hack to get testing on Windows going.

Move the fixme closer to the hack, right before the `if` in the static block

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

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


More information about the panama-dev mailing list