Harmony
  1. Harmony
  2. HARMONY-308

[classlib][nio charset] java.nio.charset.Charset.encode(CharBuffer) returns bytes in a different order in Harmony and RI for the UTF-16 charset

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None

      Description

      java.nio.charset.Charset.encode(CharBuffer) returns bytes in a different order.
      Please look at the output of a test case that I am going to attach.

      RI:
      --8<--
      bb.order()=BE
      cb.order()=LE
      result.order()=BE
      The result is
      result = java.nio.HeapByteBuffer[pos=0 lim=28 cap=52]
      bb = java.nio.HeapByteBuffer[pos=0 lim=28 cap=28]
      The result is OK.
      --8<--

      Harmony (At revision 391577):
      --8<--
      bb.order()=BE
      cb.order()=LE
      result.order()=BE
      The result is
      result = java.nio.ReadWriteHeapByteBuffer, status: capacity=28 position=0 limit=28
      bb = java.nio.ReadWriteHeapByteBuffer, status: capacity=28 position=0 limit=28
      The result is not correct.
      0 elements are not equal (ffffffff != fffffffe)
      1 elements are not equal (fffffffe != ffffffff)
      2 elements are not equal (1b != 4)
      3 elements are not equal (4 != 1b)
      4 elements are not equal (35 != 4)
      5 elements are not equal (4 != 35)
      6 elements are not equal (42 != 4)
      7 elements are not equal (4 != 42)
      8 elements are not equal (3e != 4)
      9 elements are not equal (4 != 3e)
      10 elements are not equal (20 != 0)
      11 elements are not equal (0 != 20)
      12 elements are not equal (32 != 4)
      13 elements are not equal (4 != 32)
      14 elements are not equal (20 != 0)
      15 elements are not equal (0 != 20)
      16 elements are not equal (20 != 4)
      17 elements are not equal (4 != 20)
      18 elements are not equal (3e != 4)
      19 elements are not equal (4 != 3e)
      20 elements are not equal (41 != 4)
      21 elements are not equal (4 != 41)
      22 elements are not equal (41 != 4)
      23 elements are not equal (4 != 41)
      24 elements are not equal (38 != 4)
      25 elements are not equal (4 != 38)
      26 elements are not equal (38 != 4)
      27 elements are not equal (4 != 38)
      --8<--

      1. test9.java
        2 kB
        Dmitry M. Kononov

        Activity

        Hide
        Alexey Petrenko added a comment -

        Yes, I can not reproduce it too.

        Show
        Alexey Petrenko added a comment - Yes, I can not reproduce it too.
        Hide
        Mikhail Markov added a comment -

        Since Harmony has moved to the new charsets implementation this issue is not reproducible anymore and could be closed.

        Show
        Mikhail Markov added a comment - Since Harmony has moved to the new charsets implementation this issue is not reproducible anymore and could be closed.
        Hide
        Tony Wu added a comment -

        It encodes in Big Endian in icu4jni3.6 now but the testcase still fails due to ICU does not prepend a BOM.
        But spec says the BOM is optional,
        "UTF-16 Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark ".

        I suggest that we close this issue then open another to record the difference in BOM.

        Show
        Tony Wu added a comment - It encodes in Big Endian in icu4jni3.6 now but the testcase still fails due to ICU does not prepend a BOM. But spec says the BOM is optional, "UTF-16 Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark ". I suggest that we close this issue then open another to record the difference in BOM.
        Hide
        Dmitry M. Kononov added a comment -

        The included (by me) attachment is submitted under the terms of the Apache License v2 and the terms of the ICLA.

        Show
        Dmitry M. Kononov added a comment - The included (by me) attachment is submitted under the terms of the Apache License v2 and the terms of the ICLA.
        Hide
        Alexey Petrenko added a comment -

        Just FYI...
        Here is a corresponding ICU4JNI bug: http://bugs.icu-project.org/cgi-bin/icu-bugs/conversion?id=5179

        Show
        Alexey Petrenko added a comment - Just FYI... Here is a corresponding ICU4JNI bug: http://bugs.icu-project.org/cgi-bin/icu-bugs/conversion?id=5179

          People

          • Assignee:
            Alexey Petrenko
            Reporter:
            Dmitry M. Kononov
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development