On Tue, 6 May 2025 15:46:22 GMT, Chen Liang <li...@openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/foreign/abi/CapturableState.java 
>> line 59:
>> 
>>> 57:         MemoryLayout[] stateLayouts = new 
>>> MemoryLayout[supported.size()];
>>> 58:         @SuppressWarnings({"unchecked", "rawtypes"})
>>> 59:         Map.Entry<String, CapturableState>[] entries = new 
>>> Map.Entry[supported.size()];
>> 
>> Suggestion:
>> 
>>         CapturableState[] supported;
>> 
>>         if (OperatingSystem.isWindows()) {
>>             supported = new CapturableState[] {
>>                     new CapturableState("GetLastError", JAVA_INT, 1 << 0),
>>                     new CapturableState("WSAGetLastError", JAVA_INT, 1 << 1),
>>                     new CapturableState("errno", JAVA_INT, 1 << 2)
>>             };
>>         } else {
>>             supported = new CapturableState[] {new CapturableState("errno", 
>> JAVA_INT, 1 << 2)};
>>         }
>> 
>>         MemoryLayout[] stateLayouts = new MemoryLayout[supported.length];
>>         @SuppressWarnings({"unchecked", "rawtypes"})
>>         Map.Entry<String, CapturableState>[] entries = new 
>> Map.Entry[supported.length];
>> 
>> Here it might be better to replace List with an array
>
> I think I might ask @JornVernee for opinion as that is the original author.

Either one works I think. Array might be a bit more efficient. Don't think it 
matters much though

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25025#discussion_r2075931062

Reply via email to