JDK-6448787 : Regression: UnicodeLittle broken on 1.4.2_12
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 1.4.2_12
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris_8
  • CPU: generic,sparc
  • Submitted: 2006-07-13
  • Updated: 2014-02-27
  • Resolved: 2006-10-16
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.
Other
1.4.2_13 b06Fixed
Related Reports
Duplicate :  
Relates :  
Description
UnicodeLittle is broken on 1.4.2_12, the following test fails on 1.4.2_12 and works on older versions such as 1.4.2_06:
public class TestUnicodeLittle {
        public static void main(String[] args) throws Exception {
                byte[] unicodeLittleBytes = new byte[]{68,0,83,0,75,0,80,0,79,0,79,0,76,0,53,0,51,0};
                String unicodeLittleStr = new String(unicodeLittleBytes, "UnicodeLittle");

                System.out.println("Actual output: " + unicodeLittleStr);
                System.out.println("Expected output: DSKPOOL53");
                if ("DSKPOOL53".equals(unicodeLittleStr)) {
                        System.out.println("Test passed");
                } else {
                        System.out.println("Test failed");
                }

        }

}

Test output on 1.4.2_06:
$ java -version
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
$ java -cp . TestUnicodeLittle
Actual output: DSKPOOL53
Expected output: DSKPOOL53
Test passed
$

Output on 1.4.2_12: 
$ java -version
java version "1.4.2_12"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_12-b03)
Java HotSpot(TM) Client VM (build 1.4.2_12-b03, mixed mode)
$ java -cp .  TestUnicodeLittle
Actual output: ?????????
Expected output: DSKPOOL53
Test failed
$

Comments
EVALUATION This will be in 1.4.2_14, defaulting to little-endian encoding and not requiring the BOM.
11-10-2006

EVALUATION Obviously we have to keep our "compatibility is king" promise, especially when IBM and EE raised their hands. We have fixed the similar issue in Mustang 6.0/b81 under #6407730, I would expect the 1.4.2_12 to do the same thing. The webrev for the fix we put into 6.0 is at http://javaweb.sfbay/~sherman/Webrevs/6407730. I re-opened the bug for CTE to give this one a second consideration.
04-10-2006

EVALUATION Closing as not a bug. While there is a change in behaviour, it's a correction. The api now behaves as it is documented - the app was previously exploiting a point where the api didn't do what it really said it should (ie. if you want to use UnicodeLittleUnmarked, you need to say so).
07-08-2006