C and C++ have had a language type which is properly meant to encode UTF-16 characters for a long time by this point: char16_t. Its underlying type is an unsigned short, making it entirely backwards compatible with the Java Native Interface's requirement that a jchar is an unsigned 16 bit type. With these types underlying the jchar typedef special support for jchar can be used within native C and C++ code in the JDK, as well as solving certain casting issues with native APIs, such as on Windows, all in a backwards compatible way
Caveat: Although all the platforms we support do have an unsigned 16 bit number as the underlying type of char16_t, a new platform we may add support for in the future might technically not do so. An assert can be very easily added in such a case
Caveat: Although all the platforms we support do have an unsigned 16 bit number as the underlying type of char16_t, a new platform we may add support for in the future might technically not do so. An assert can be very easily added in such a case