Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8237524

AArch64: String.compareTo() may return incorrect result

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 11, 12, 13, 14, 15
    • Fix Version/s: 15
    • Component/s: hotspot
    • Subcomponent:
    • Introduced In Version:
      11
    • Resolved In Build:
      b08
    • CPU:
      aarch64
    • OS:
      linux

      Description

      AArch64 String.compareTo() may return incorrect result in some corner
      cases. This issue can be reproduced in below program by constructing two
      strings from the same byte array but with different encoding options.

      import java.lang.reflect.Constructor;

      public class Test {
        public static void main(String[] args) throws Exception {
          Constructor<String> c = String.class.getDeclaredConstructor(byte[].class, byte.class);
          c.setAccessible(true);

          byte[] bytes = new byte[] {
            'Y', 'm', '_', 'l', 'V', 'n', 'W', 'S', 'w', 'm', 'W', 'S'
          };

          String s1 = c.newInstance(bytes, (byte) 0);
          String s2 = c.newInstance(bytes, (byte) 1);
          System.out.println(s1.compareTo(s2));
        }
      }

      // $ java -Xint Test
      // -27904
      // $ java -Xcomp -XX:-TieredCompilation Test
      // 6

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pli Pengfei Li
                Reporter:
                pli Pengfei Li
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: