RFR: 8356126: Duplication handling and optimization of CaptureCallState [v5]

Chen Liang liach at openjdk.org
Tue May 6 15:51:55 UTC 2025


On Tue, 6 May 2025 09:35:16 GMT, Shaojin Wen <swen at openjdk.org> wrote:

>> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Review remarks
>
> 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.

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

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


More information about the core-libs-dev mailing list