JDK-8313865 : Always true condition in sun.nio.cs.CharsetMapping#readINDEXC2B
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 17,21
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-08-07
  • Updated: 2023-09-18
  • Resolved: 2023-09-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22
22 b15Fixed
Related Reports
Relates :  
Description
In the method 'sun.nio.cs.CharsetMapping#readINDEXC2B'

    void readINDEXC2B() {
        char[] map = readCharArray();
        for (int i = map.length - 1; i >= 0; i--) {
            if (c2b == null && map[i] != -1) {
                c2b = new char[map[i] + 256];
                Arrays.fill(c2b, (char)UNMAPPABLE_ENCODING);
                break;
            }
        }
        c2bIndex = map;
    }

Condition 'map[i] != -1' is always true. 'char' values range [0..65535]. It can't be equal to '-1'
Comments
Changeset: ac2dfe45 Author: Naoto Sato <naoto@openjdk.org> Date: 2023-09-12 18:19:07 +0000 URL: https://git.openjdk.org/jdk/commit/ac2dfe45d1b7fb9b99b0ba1402189de1791319b8
12-09-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/15672 Date: 2023-09-11 22:21:03 +0000
11-09-2023