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

Jorn Vernee jvernee at openjdk.java.net
Wed May 5 16:52:09 UTC 2021

On Wed, 5 May 2021 16:16:50 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:

> LibraryLookup removed. CLinker.findNative added. System.loadLibrary has to be used to load library

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

> 420:                 FunctionDescriptor.of(C_POINTER, C_LONG_LONG));
> 421: 
> 422:         static final MethodHandle MH_FREE = linker.downcallHandle(CLinker.findNative("free").get(),

These symbol lookups fail on Windows.

test/jdk/java/foreign/libStdLibTest.h line 43:

> 41: EXPORT void libc_qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*));
> 42: EXPORT int libc_rand(void);
> 43: EXPORT int vprintf(const char *format, va_list arg);

This declaration of `vprintf` gives an error on Windows, is it needed? The test passes without as well.  (should came of stdio.h I'd think)

test\jdk\java\foreign\libStdLibTest.h(43): error C2375: 'vprintf': redefinition; different linkage
c:\progra~2\wi3cf2~1\10\include\100183~1.0\ucrt\stdio.h(738): note: see declaration of 'vprintf'
   ... (rest of output omitted)


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

More information about the panama-dev mailing list