On Wed, 13 Sep 2023 19:43:53 GMT, ExE Boss <d...@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-b...@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

Reply via email to