possible problem with JNI GetStringUTFChars

Alan Snyder javalists at cbfiddle.com
Mon Jan 28 22:24:00 UTC 2019

If you search the JDK repo for GetStringUTFChars, you will find several uses that do not appear to involve serialization or data input/output.

It is not obvious whether these uses are correct or not.

Consider test/jdk/java/nio/channels/FileChannel/directio/libDirectIO.c

where GetStringUTFChars is used to convert a file path to pass to open().

At the very least, anyone using GetStringUTFChars as a short cut for true UTF-8 conversion should document why this short cut is correct, as is done in awt_InputMethod, for example.


> On Jan 28, 2019, at 2:10 PM, Stuart Marks <stuart.marks at oracle.com> wrote:
> (From Java code, the Charset encoders/decoders handle real UTF-8, which seems to cover most cases. Modified UTF-8 occurs only within serialization and Data{Input,Output}Stream.)

More information about the core-libs-dev mailing list