On Sun, 4 May 2025 19:35:15 GMT, Luca Kellermann <d...@openjdk.org> wrote:

>> Chen Liang has updated the pull request with a new target base due to a 
>> merge or a rebase. The incremental webrev excludes the unrelated changes 
>> brought in by the merge/rebase. The pull request contains five additional 
>> commits since the last revision:
>> 
>>  - Merge branch 'master' of https://github.com/openjdk/jdk into exp/ffm-lcms
>>  - Use more simple function descriptor
>>  - Simplify FFM linker warmup
>>  - Merge branch 'master' of https://github.com/openjdk/jdk into exp/ffm-lcms
>>  - Wip work trying to speed up FFM
>
> src/java.base/share/classes/java/lang/foreign/Linker.java line 866:
> 
>> 864:                     .map(CapturableState::forName)
>> 865:                     .mapToInt(state -> 1 << state.ordinal())
>> 866:                     .sum();
> 
> Using `sum` means the result will be incorrect if `capturedState` contains a 
> valid name multiple times:
> 
> var option = 
> (LinkerOptions.CaptureCallState)Linker.Option.captureCallState("WSAGetLastError",
>  "WSAGetLastError");
> 
> // will print [ERRNO] on Windows
> System.out.println(option.saved());
> 
> 
> option = 
> (LinkerOptions.CaptureCallState)Linker.Option.captureCallState("errno", 
> "errno");
> 
> // will throw IndexOutOfBoundsException on all platforms
> option.saved();

Hmm, I intentionally checked `toSet` does not reject duplicates but forgot 
about this part. Anyways this stream code is problematic; will fix this in a 
patch that removes this stream code wholesale.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24742#discussion_r2072703688

Reply via email to