JDK-8242283 - Java Issue Tracker
(For example, "C:\Program Files\java\jdk-11.0.6" does not exceed MAX_PATH) ... And the documentation says the *A functions use the Ansi Code Page by default.
(For example, "C:\Program Files\java\jdk-11.0.6" does not exceed MAX_PATH) ... And the documentation says the *A functions use the Ansi Code Page by default.
It's an error in java.lang.String source code which is the same for all JDK distributions.I have created a more simple example class which demonstrates this behaviour very clearly. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : See bug ID 4637640.
This problem only occurs if a String constructor has been passed a StringBuffer object as a parameter (which causes the StringBuffer's "shared" flag to be set to true) *AND* the StringBuffer's length is later set to zero. The coding error is in the "StringBuffer.setLength()" method.
The code-snippet referenced in the third suggestion is, as speculated, a result of auto-generated code. The value of $LG_BYTES_PER_VALUE$ for byte is 0. I have verified that the javac compiler optimizes this shift out of the generated byte code.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1. Compile to sample program 2. Run java KeyReader 3. Press Control+x. EXPECTED VERSUS ACTUAL BEHAVIOR : The method should return a string that can be passed to KeyStroke.getKeyStroke.