RFR: 8312522: Implementation of Foreign Function & Memory API [v21]
Jorn Vernee
jvernee at openjdk.org
Mon Sep 18 14:17:35 UTC 2023
On Wed, 13 Sep 2023 19:43:53 GMT, ExE Boss <duke at openjdk.org> wrote:
>> Jorn Vernee has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - add missing space + reflow lines
>> - Fix typo
>>
>> Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
>
> src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java line 311:
>
>> 309: };
>> 310:
>> 311: CANONICAL_LAYOUTS = Map.ofEntries(
>
> `LibFallback::wcharSize()` and other getters for `LibFallback.NativeConstants` fields can throw an error when `LibFallback.SUPPORTED` is `false` due to the `fallbackLinker` library not being present, so this static initializer should be made into a method instead:
> Suggestion:
>
> static final Map<String, MemoryLayout> CANONICAL_LAYOUTS = initCanonicalLayouts();
>
> private static Map<String, MemoryLayout> initCanonicalLayouts() {
> if (!isSupported()) {
> return null;
> }
>
> int wchar_size = LibFallback.wcharSize();
> MemoryLayout wchartLayout = switch(wchar_size) {
> case 2 -> JAVA_CHAR; // prefer JAVA_CHAR
> default -> FFIType.layoutFor(wchar_size);
> };
>
> return Map.ofEntries(
Good catch! I've chosen a slightly different solution though.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15103#discussion_r1328794993
More information about the build-dev
mailing list