RFR: 8293595: tstrings::any() is missing an overload

Julian Waters jwaters at openjdk.org
Mon Sep 19 18:10:53 UTC 2022


On Mon, 19 Sep 2022 17:27:29 GMT, Alexey Semenyuk <asemenyuk at openjdk.org> wrote:

>> tstrings::any() has an overload for std::wstring (if required) but is missing the corresponding operator overload for std::string, leaving only the templated one as a fallback, which will expand into a std::wostringstream << std::string operation. This isn't particularly safe on Windows, considering that JDK-8292008 and JDK-8247283 have been recently merged, and can sporadically cause build failures. This change simply adds the missing overload with the appropriate format handling that jpackage expects from std::string. Also contains minor name changes to fit the rest of the parameter names in the other overloads.
>
> src/jdk.jpackage/share/native/common/tstrings.h line 363:
> 
>> 361:             return *this;
>> 362:         }
>> 363: 
> 
> I guess you also need 
> 
>         any& operator << (LPSTR v) {
>             data << (v ? fromUtf8(v) : "NULL");
>             return *this;
>         }
> 
>         any& operator << (LPCSTR v) {
>             data << (v ? fromUtf8(v) : "NULL");
>             return *this;
>         }
> 
> to make a complete set of overloads

I deliberately left those 2 out since the comments accompanying them seem to suggest that they're Windows specific overloads that are there for different reasons (As opposed to the one this PR is aimed at, which takes in a regular std::wstring), moreover not providing overloads for them don't seem to be causing issues either. I'm unsure if adding them too would be correct, I'll wait for more reviews before doing so

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

PR: https://git.openjdk.org/jdk/pull/10231


More information about the hotspot-dev mailing list