RFR: 8211163: UNIX version of Java_java_io_Console_echo does not return a clean boolean

Andrew Haley aph at redhat.com
Wed Sep 26 15:51:43 UTC 2018

Java_java_io_Console_echo looks like this:

Java_java_io_Console_echo(JNIEnv *env, jclass cls, jboolean on)
    DWORD fdwMode;
    jboolean old;
    old = (fdwMode & ENABLE_ECHO_INPUT);
    return old;

It only works by accident. jboolean is an unsigned byte.
ENABLE_ECHO_INPUT on the systems I know of is 0000010, so fdwMode &
ENABLE_ECHO_INPUT fits into the result, but only by accident. We
should do things properly and return a clean boolean.

Note that the Windows version of the code is correct: I assume the
UNIX version is an oversight.



Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671

More information about the jdk-dev mailing list