RFR: 8195129: System.load() fails to load from unicode paths [v2]

Maxim Kartashev github.com+28651297+mkartashev at openjdk.java.net
Thu May 27 16:14:43 UTC 2021


On Thu, 27 May 2021 04:23:16 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Maxim Kartashev has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR. The pull request contains one new commit since the last revision:
>> 
>>   8195129: System.load() fails to load from unicode paths
>
> src/hotspot/os/windows/os_windows.cpp line 1462:
> 
>> 1460:   const int flag_source_str_is_null_terminated = -1;
>> 1461:   const int flag_estimate_chars_count = 0;
>> 1462:   int utf16_chars_count_estimated = MultiByteToWideChar(source_encoding,
> 
> Your local naming style is somewhat excessive. You could just comment the values of the flags when you pass them eg:
> 
> MultiByteToWideChar(source_encoding,
>                                     MB_ERR_INVALID_CHARS,
>                                    source_str,
>                                    -1, //source is null-terminated
>                                   NULL, // no output buffer
>                                   0); // calculate required buffer size
> 
> Or you could just add a comment before the call:
> 
> // Perform a dummy conversion so that we can get the required size of the buffer to
> // allocate. The source is null-terminated.
> 
> Trying to document parameter semantics by variable naming doesn't work in my opinion - at some point if you want to know you have to RTFM for the API.
> 
> And utf16_len is perfectly adequate for the returned size.

Fair enough. Corrected.

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

PR: https://git.openjdk.java.net/jdk/pull/4169


More information about the core-libs-dev mailing list